初始提交:实习工作日志系统(设计方案 + Vue3 应用 + Electron 打包)

This commit is contained in:
root
2026-10-15 23:55:27 +08:00
commit cfb984627d
50 changed files with 9223 additions and 0 deletions
+125
View File
@@ -0,0 +1,125 @@
import Dexie, { type Table } from 'dexie'
export interface Project {
id?: number
name: string
archived: number
created_at: string
}
export interface WorkLog {
id?: number
date: string
created_at: string
}
export interface LogItem {
id?: number
work_log_id: number
content: string
project_id: number | null
category: string
minutes: number | null
is_milestone: number
needs_followup: number
takeaway: string | null
remark: string | null
sort_order: number
created_at: string
}
export interface Attendance {
id?: number
date: string
clock_in_at: string | null
clock_out_at: string | null
kind: string
note: string | null
location?: string | null
created_at: string
}
export interface WeeklyNote {
id?: number
week_start: string
highlights: string | null
challenges: string | null
plan_next: string | null
created_at: string
}
export interface Memo {
id?: number
title: string
content: string
created_at: string
updated_at: string
}
export interface Credential {
id?: number
system: string
account: string
password: string
remark: string
created_at: string
updated_at: string
}
export class WorklogDB extends Dexie {
project!: Table<Project, number>
work_log!: Table<WorkLog, number>
log_item!: Table<LogItem, number>
attendance!: Table<Attendance, number>
weekly_note!: Table<WeeklyNote, number>
setting!: Table<{ key: string; value: string }, string>
memo!: Table<Memo, number>
credential!: Table<Credential, number>
constructor(dbName = 'intern_worklog') {
super(dbName)
this.version(1).stores({
project: '++id, &name, archived',
work_log: '++id, &date',
log_item: '++id, work_log_id, project_id, category',
attendance: '++id, &date',
weekly_note: '++id, &week_start',
setting: 'key'
})
this.version(2).stores({
memo: '++id, updated_at',
credential: '++id, system, updated_at'
})
}
}
// 当前登录用户绑定的数据库实例:不同用户物理隔离不同库,登录后由 auth 模块注入
export let db: WorklogDB | undefined
export function bindDatabase(instance: WorklogDB): void {
db = instance
}
export function unbindDatabase(): void {
if (db) db.close()
db = undefined
}
export const SCHEMA_VERSION = 2
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: '其他' }
]
export function categoryLabel(key: string): string {
const found = CATEGORIES.find(c => c.key === key)
return found ? found.label : '其他'
}