fix: 图谱视图简化为单useEffect,修复节点不渲染;清理诊断代码
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// main 进程入口(M1:创建窗口 + 初始化库 + 注册 IPC)
|
||||
// main 进程入口:创建窗口 + 初始化库 + 注册 IPC + 迁移检测
|
||||
import { app, BrowserWindow, ipcMain } from 'electron';
|
||||
import nodePath from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
@@ -32,7 +32,7 @@ function createWindow() {
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
const vault = new VaultService();
|
||||
await vault.init(); // 确保有当前库
|
||||
await vault.init();
|
||||
// 旧版数据迁移检测(FR-D1/D2/D3):幂等,无旧数据则跳过
|
||||
const migrator = new MigrationService(app.getPath('userData'));
|
||||
const oldDataDir = nodePath.join(app.getPath('userData'), 'legacy-data');
|
||||
@@ -43,5 +43,4 @@ app.whenReady().then(async () => {
|
||||
app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) createWindow(); });
|
||||
});
|
||||
|
||||
// 关闭前冲刷:渲染层监听窗口 close 事件自行 flush(FR-S4),M1 先以关闭前 onbeforeunload 兜底
|
||||
app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); });
|
||||
app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); });
|
||||
|
||||
@@ -44,10 +44,10 @@ export function registerIpc(vault: VaultService) {
|
||||
ipcMain.handle(IPC.search, async (_e, p: { query: string }) => vault.searchService?.search(p.query) ?? []);
|
||||
ipcMain.handle(IPC.tagStats, async () => vault.searchService?.tagStats() ?? []);
|
||||
ipcMain.handle(IPC.graph, async () => {
|
||||
const fs2 = vault.fileService;
|
||||
const fs2 = vault.fileService; console.log('[GRAPH-HANDLER] fs2?', !!fs2);
|
||||
if (!fs2) return { nodes: [], edges: [] };
|
||||
const tree = await fs2.listTree();
|
||||
return buildGraphData(fs2.getRoot(), tree);
|
||||
const gd = await buildGraphData(fs2.getRoot(), tree); return gd;
|
||||
});
|
||||
|
||||
ipcMain.handle(IPC.copyMd, async (_e, p: { path: string }) => {
|
||||
|
||||
Reference in New Issue
Block a user