This commit is contained in:
2026-09-12 13:59:12 +08:00
commit 941ce4baab
71 changed files with 13037 additions and 0 deletions

21
renderer/theme-boot.js Normal file
View File

@@ -0,0 +1,21 @@
'use strict';
/**
* 首屏主题预应用:在首次绘制前从 localStorage 读取上次的主题/强调色,
* 避免等 IPC 返回期间的白屏闪烁。
*
* 必须是「外部脚本」——页面 CSP 为 default-src 'self',未开 script-src 'unsafe-inline'
* 内联 <script> 会被直接拒绝执行。
*/
try {
const cached = JSON.parse(localStorage.getItem('clipboard-theme') || 'null');
if (cached) {
// 优先用 effectiveTheme「跟随系统」开时它就是上次实际显示的主题
// 直接套上去能省一次闪。旧版缓存里只有 theme旧版在 followSystem
// 开时存的是 raw会闪一下这里向后兼容。
const theme = cached.effectiveTheme || cached.theme;
if (theme) {
document.documentElement.setAttribute('data-theme', theme);
document.documentElement.setAttribute('data-accent', cached.accent || 'purple');
}
}
} catch (e) { /* 静默 */ }