fix(styles): synchronize accent across open apps
This commit is contained in:
@@ -745,6 +745,17 @@ 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;
|
||||
|
||||
@@ -803,6 +814,10 @@ 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{
|
||||
|
||||
Reference in New Issue
Block a user