fix(theme): persist switcher accent for SSR
Quality / quality (ubuntu-latest) (push) Failing after 9m48s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-12 21:17:20 +05:30
parent effed1c3cf
commit dd9b7a289a
8 changed files with 11 additions and 25 deletions
-15
View File
@@ -745,17 +745,6 @@ export function renderThemeRuntime(theme: ResolvedTheme): string {
window.dispatchEvent(new CustomEvent("wrnexus:accent-changed",{detail:{accent:null}}));
}
function syncSharedAccent(){
var cookieAccent=readCookie(ACCENT_COOKIE);
var next=cookieAccent&&ACCENTS.indexOf(cookieAccent)>=0?cookieAccent:DEFAULT_ACCENT;
var current=el.getAttribute("data-accent");
if(next===current)return;
if(next)el.setAttribute("data-accent",next);else el.removeAttribute("data-accent");
syncStylesheet(getTheme(),next);
syncAccentButtons(document);
window.dispatchEvent(new CustomEvent("wrnexus:accent-changed",{detail:{accent:next}}));
}
function bind(root){
var target=root||document;
@@ -814,10 +803,6 @@ export function renderThemeRuntime(theme: ResolvedTheme): string {
};
window.addEventListener("wrnexus:navigated",function(){bind(document);});
window.addEventListener("focus",syncSharedAccent);
window.addEventListener("pageshow",syncSharedAccent);
document.addEventListener("visibilitychange",function(){if(!document.hidden)syncSharedAccent();});
window.setInterval(syncSharedAccent,1000);
if(document.readyState==="loading"){
document.addEventListener("DOMContentLoaded",function(){bind(document);});
}else{