feat: 计划模式(时间段+打卡+计时时钟) / 工作详情范围导出 / 工作与记账分类自定义(含历史迁移)
This commit is contained in:
+47
-12
@@ -48,6 +48,22 @@ export interface WeeklyNote {
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface PlanItem {
|
||||
id?: number
|
||||
date: string // YYYY-MM-DD
|
||||
start_time: string // HH:mm
|
||||
end_time: string // HH:mm
|
||||
title: string // 计划内容,如:产品学习 / 健身
|
||||
kind: string // 类别:学习 / 健身 / 自律 / 其他自定义
|
||||
note: string | null
|
||||
status: string // todo | done | skip
|
||||
actual_minutes: number // 计时时钟累计的实际投入分钟
|
||||
timer_started_at: string | null
|
||||
uuid: string
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface Memo {
|
||||
id?: number
|
||||
title: string
|
||||
@@ -107,6 +123,7 @@ export class WorklogDB extends Dexie {
|
||||
// 因为 db.transaction 会与 Dexie 内置的 transaction() 方法冲突
|
||||
sync_mirror!: Table<SyncMirror, number>
|
||||
tombstone!: Table<SyncTombstone, number>
|
||||
plan!: Table<PlanItem, number>
|
||||
|
||||
constructor(dbName = 'intern_worklog') {
|
||||
super(dbName)
|
||||
@@ -129,6 +146,23 @@ export class WorklogDB extends Dexie {
|
||||
sync_mirror: '++id, table, uuid',
|
||||
tombstone: '++id, table, uuid, deleted_at'
|
||||
})
|
||||
this.version(5).stores({
|
||||
plan: '++id, date, status'
|
||||
}).upgrade(async tx => {
|
||||
// 旧固定分类 key 迁移为用户自定义分类标签(v0.4.0 起分类为用户数据)
|
||||
const map: Record<string, string> = {
|
||||
dev: '项目实操',
|
||||
test: '项目实操',
|
||||
bugfix: '售后服务',
|
||||
learning: '产品学习',
|
||||
meeting: '打杂',
|
||||
doc: '打杂',
|
||||
other: '打杂'
|
||||
}
|
||||
await tx.table('log_item').toCollection().modify((item: { category?: string }) => {
|
||||
if (item.category && map[item.category]) item.category = map[item.category]
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,24 +178,25 @@ export function unbindDatabase(): void {
|
||||
db = undefined
|
||||
}
|
||||
|
||||
export const SCHEMA_VERSION = 4
|
||||
export const SCHEMA_VERSION = 5
|
||||
|
||||
export const EXPENSE_CATEGORIES: string[] = ['餐饮', '交通', '住房', '通讯', '学习', '娱乐', '其他']
|
||||
export const INCOME_CATEGORIES: string[] = ['工资', '报销', '其他']
|
||||
|
||||
export const DEFAULT_LOCATIONS: string[] = ['公司', '客户现场', '出差', '居家办公']
|
||||
|
||||
export const CATEGORIES: { key: string; label: string }[] = [
|
||||
{ key: 'dev', label: '开发' },
|
||||
{ key: 'bugfix', label: 'BUG修复' },
|
||||
{ key: 'test', label: '测试' },
|
||||
{ key: 'learning', label: '学习成长' },
|
||||
{ key: 'meeting', label: '会议沟通' },
|
||||
{ key: 'doc', label: '文档输出' },
|
||||
{ key: 'other', label: '其他' }
|
||||
]
|
||||
// 旧版固定分类 key → 默认标签的映射(仅用于历史数据迁移与展示兜底)
|
||||
export const LEGACY_CATEGORY_LABELS: Record<string, string> = {
|
||||
dev: '项目实操',
|
||||
test: '项目实操',
|
||||
bugfix: '售后服务',
|
||||
learning: '产品学习',
|
||||
meeting: '打杂',
|
||||
doc: '打杂',
|
||||
other: '打杂'
|
||||
}
|
||||
|
||||
// v0.4.0 起分类即用户自定义标签本身;历史 key 在此直通转换
|
||||
export function categoryLabel(key: string): string {
|
||||
const found = CATEGORIES.find(c => c.key === key)
|
||||
return found ? found.label : '其他'
|
||||
return LEGACY_CATEGORY_LABELS[key] || key
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user