feat: 长期计划(目标→每日任务物化+进度条) / 详情页Markdown范围导出 / 记账与详情页改内容优先弹窗新增

This commit is contained in:
root
2026-10-26 12:16:14 +08:00
parent 284f8ebd46
commit 0f268a495e
20 changed files with 535 additions and 268 deletions
+21 -2
View File
@@ -13,7 +13,7 @@ import { DEFAULT_SYNC_BASE, getSyncBase as baseOf, getToken, setToken, setSyncBa
// 最近一次自动同步的错误(设置页展示用)
export const syncLastError = ref('')
const TABLES = ['project', 'work_log', 'log_item', 'attendance', 'weekly_note', 'setting', 'memo', 'credential', 'transaction', 'plan']
const TABLES = ['project', 'work_log', 'log_item', 'attendance', 'weekly_note', 'setting', 'memo', 'credential', 'goal', 'transaction', 'plan']
// 本地临时性键不参与同步,也不能从服务端写回本地缓存
const EXCLUDE_SETTING_KEYS = new Set(['sync_cursor', 'sync_last_time', 'sync_token', 'last_project', 'last_category'])
@@ -175,6 +175,7 @@ export async function flushAfterWrite(): Promise<void> {
interface RefMaps {
workLog: Map<number, AnyRow>
project: Map<number, AnyRow>
goal: Map<number, AnyRow>
}
function normalizeRow(t: string, row: AnyRow, refs: RefMaps): AnyRow {
@@ -191,15 +192,22 @@ function normalizeRow(t: string, row: AnyRow, refs: RefMaps): AnyRow {
const pj = row.project_id ? refs.project.get(row.project_id) : null
if (pj && pj.uuid) clean.puuid = pj.uuid
}
if (t === 'plan') {
delete clean.goal_id
const g = row.goal_id ? refs.goal.get(row.goal_id) : null
if (g && g.uuid) clean.guuid = g.uuid
}
return clean
}
async function buildRefMaps(): Promise<RefMaps> {
const wlRows = await db.work_log.toArray()
const pjRows = await db.project.toArray()
const gRows = await db.goal.toArray()
return {
workLog: new Map(wlRows.map(r => [r.id as number, r])),
project: new Map(pjRows.map(p => [p.id as number, p]))
project: new Map(pjRows.map(p => [p.id as number, p])),
goal: new Map(gRows.map(r => [r.id as number, r]))
}
}
@@ -398,6 +406,7 @@ async function applySnapshot(
let removed = 0
const wlIds: { [uuid: string]: number } = {}
const pjIds: { [uuid: string]: number } = {}
const goalIds: { [uuid: string]: number } = {}
for (const t of TABLES) {
const table = db.table(t)
@@ -431,6 +440,15 @@ async function applySnapshot(
srow.project_id = srow.puuid ? (pjIds[srow.puuid] ?? null) : null
delete srow.puuid
}
if (t === 'plan') {
if (srow.guuid) {
const gid = goalIds[srow.guuid]
srow.goal_id = gid ?? null
delete srow.guuid
} else {
srow.goal_id = null
}
}
let id: any = pkOf(t, srow0)
if (t === 'setting') id = srow0.key
else {
@@ -445,6 +463,7 @@ async function applySnapshot(
hydrated.push(rowOut)
if (t === 'work_log') wlIds[srow0.uuid] = id
if (t === 'project') pjIds[srow0.uuid] = id
if (t === 'goal') goalIds[srow0.uuid] = id
}
void importance
const outRows = hydrated.concat(inflight)