feat: implement theme synchronization and loading skeletons across various components, enhancing user experience during content loading
This commit is contained in:
@@ -15,8 +15,58 @@
|
||||
<link rel="apple-touch-icon" sizes="120x120" type="image/png" href="./public/favicon.ico"/>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
(function(){
|
||||
var t=localStorage.getItem('WeKnora_theme')||'light';
|
||||
if(t==='system')t=window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light';
|
||||
document.documentElement.setAttribute('theme-mode',t);
|
||||
/* 与 theme.css 中 --td-bg-color-page 一致,避免样式加载后整页背景从 #fff 跳到 #eee 触发重绘闪动 */
|
||||
var bg=t==='dark'?'#181818':'#eee';
|
||||
document.documentElement.style.background=bg;
|
||||
document.documentElement.style.minHeight='100%';
|
||||
document.documentElement.style.colorScheme=t==='dark'?'dark':'light';
|
||||
document.body.style.background=bg;
|
||||
document.body.style.minHeight='100%';
|
||||
try{
|
||||
var w=window.runtime;
|
||||
if(w){
|
||||
if(t==='dark'){
|
||||
if(w.WindowSetDarkTheme)w.WindowSetDarkTheme();
|
||||
if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(24,24,24,255);
|
||||
}else{
|
||||
if(w.WindowSetLightTheme)w.WindowSetLightTheme();
|
||||
if(w.WindowSetBackgroundColour)w.WindowSetBackgroundColour(238,238,238,255);
|
||||
}
|
||||
}
|
||||
}catch(_){}
|
||||
})();
|
||||
</script>
|
||||
<script>
|
||||
(function(){
|
||||
try {
|
||||
if (localStorage.getItem('weknora_lite_mode') !== 'true') return;
|
||||
var saved = sessionStorage.getItem('weknora_lite_last_path');
|
||||
if (!saved || saved.indexOf('/platform/') !== 0 || saved.indexOf('/platform/organizations') === 0) return;
|
||||
var path = window.location.pathname;
|
||||
if (path !== '/' && path !== '/platform' && path !== '/platform/knowledge-bases') return;
|
||||
var target = saved.indexOf('#') >= 0 ? saved.slice(0, saved.indexOf('#')) : saved;
|
||||
if (!target) return;
|
||||
var current = window.location.pathname + window.location.search;
|
||||
if (target !== current) window.history.replaceState(window.history.state, '', target);
|
||||
} catch (e) {}
|
||||
})();
|
||||
</script>
|
||||
<script src="/config.js"></script>
|
||||
<div id="app"></div>
|
||||
<script>
|
||||
(function(){
|
||||
var t=localStorage.getItem('WeKnora_theme')||'light';
|
||||
if(t==='system')t=window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light';
|
||||
var bg=t==='dark'?'#181818':'#eee';
|
||||
var el=document.getElementById('app');
|
||||
if(el){ el.style.background=bg; el.style.minHeight='100%'; }
|
||||
})();
|
||||
</script>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user