diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.ts index 60c7145..23f6fce 100644 --- a/apps/desktop/src/main/index.ts +++ b/apps/desktop/src/main/index.ts @@ -4,6 +4,7 @@ import nodePath from 'node:path'; import { fileURLToPath } from 'node:url'; import { VaultService } from './services/vault-service.js'; import { registerIpc } from './ipc/handlers.js'; +import { MigrationService } from './services/migration-service.js'; import { IPC } from '@hunter/shared'; const __dirname = nodePath.dirname(fileURLToPath(import.meta.url)); @@ -32,6 +33,11 @@ function createWindow() { app.whenReady().then(async () => { const vault = new VaultService(); await vault.init(); // 确保有当前库 + // 旧版数据迁移检测(FR-D1/D2/D3):幂等,无旧数据则跳过 + const migrator = new MigrationService(app.getPath('userData')); + const oldDataDir = nodePath.join(app.getPath('userData'), 'legacy-data'); + const r = await migrator.migrate(oldDataDir, vault.fileService?.getRoot() ?? '').catch(() => null); + if (r?.migrated) console.log('[MIGRATION] migrated', r.count, 'items'); registerIpc(vault); createWindow(); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); }); diff --git a/apps/desktop/src/renderer/index.html b/apps/desktop/src/renderer/index.html index 98e0b05..0b91e42 100644 --- a/apps/desktop/src/renderer/index.html +++ b/apps/desktop/src/renderer/index.html @@ -3,10 +3,11 @@ + 狩夜人笔记
- + \ No newline at end of file