D 工程化:CSP安全策略+启动迁移+UI集成(C1-C7)

This commit is contained in:
hunter-dev
2026-08-24 20:36:29 +08:00
parent 3ebd33536b
commit df22fb2036
2 changed files with 8 additions and 1 deletions
+6
View File
@@ -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(); });