perf(renderer): 整体优化响应速度 — rAF 合并编辑器刷新/自动保存缓存/粒子引擎空闲自停

同时: 不透明窗口 + 精简主题(8到2)、TabBar 简化、图谱宽松布局、MoreActions 层级修复
This commit is contained in:
hunter-dev
2026-09-10 00:41:24 +08:00
parent d0dbdfd00a
commit c0ba8df9b6
27 changed files with 417 additions and 178 deletions
@@ -6,8 +6,8 @@ import os from 'node:os';
const MAIN_JS = nodePath.join(process.cwd(), 'dist-electron/main/index.js');
// 透明主题真透明:bgPrimary=transparent 时根背景必须是 alpha=0(配合主进程 transparent:true + backgroundColor:#00000000 + backgroundMaterial:'none' 即可透出下层软件)
test('透明主题:根背景 alpha=0(真透明,可见下层软件)', async () => {
// UI 重新设计:窗口不透明(transparent:false + backgroundColor 空间底色),根背景应为不透明的 L0 空间色
test('窗口不透明:根背景为 L0 空间底色(alpha=1,非透明)', async () => {
const tmp = await fs.mkdtemp(nodePath.join(os.tmpdir(), 'hn-tr-'));
const ud = nodePath.join(tmp, 'ud'); const v = nodePath.join(tmp, 'v');
await fs.mkdir(ud, { recursive: true }); await fs.mkdir(v, { recursive: true });
@@ -15,15 +15,7 @@ test('透明主题:根背景 alpha=0(真透明,可见下层软件)', asy
const page = await app.firstWindow();
await page.waitForLoadState('domcontentloaded');
await page.evaluate(({ root }) => (globalThis as any).dsh.invoke('vault:switch', { root }), { root: v });
// 应用透明主题的 CSS 变量(bgPrimary='transparent'),并移除背景图遮罩
await page.evaluate(() => {
const el = document.documentElement;
el.style.setProperty('--bg-primary', 'transparent');
el.style.setProperty('--bg-secondary', 'rgba(20,20,28,0.5)');
el.style.setProperty('--text-primary', '#ddd');
document.querySelectorAll('div[style*="background-image"]').forEach((n: any) => n.remove());
});
await page.waitForTimeout(400);
await page.waitForTimeout(500);
const rootBg = await page.evaluate(() => {
const root = document.querySelector('#root > div') as HTMLElement;
if (!root) return null;
@@ -31,7 +23,15 @@ test('透明主题:根背景 alpha=0(真透明,可见下层软件)', asy
});
console.log('ROOT_BG', rootBg);
expect(rootBg).not.toBeNull();
// 透明背景应为 alpha=0(rgba(0,0,0,0) 或 transparent)
expect(rootBg).toMatch(/rgba\(0, 0, 0, 0\)|transparent/i);
// 窗口不透明:根背景为不透明空间底色(alpha=1,非 rgba(...,0) / transparent)
const m = rootBg!.match(/rgba\(([\d.]+),\s*([\d.]+),\s*([\d.]+),\s*([\d.]+)\)|^rgb\(([\d.]+),\s*([\d.]+),\s*([\d.]+)\)$/);
expect(m).not.toBeNull();
// 不透明:要么是 rgb(...)(隐式 alpha=1),要么 rgba alpha=1
if (rootBg!.startsWith('rgba')) {
const alpha = parseFloat(m![4]);
expect(alpha).toBe(1);
} else {
expect(rootBg!.startsWith('rgb(')).toBe(true);
}
await app.close();
});