update app layout (#17126)
This commit is contained in:
1 parent
73d1a6f468
commit
1f4cda31ac
1 file changed
+39
@@ -81,6 +81,45 @@ export default async function RootLayout({ children }: { children: React.ReactNo
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<script
|
||||
nonce={nonce}
|
||||
id="headScript"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
window.calNewLocale = "${locale}";
|
||||
(function applyTheme() {
|
||||
try {
|
||||
const appTheme = localStorage.getItem('app-theme');
|
||||
if (!appTheme) return;
|
||||
|
||||
let bookingTheme, username;
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i);
|
||||
if (key.startsWith('booking-theme:')) {
|
||||
bookingTheme = localStorage.getItem(key);
|
||||
username = key.split("booking-theme:")[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const onReady = () => {
|
||||
const isBookingPage = username && window.location.pathname.slice(1).startsWith(username);
|
||||
|
||||
if (document.body) {
|
||||
document.body.classList.add(isBookingPage ? bookingTheme : appTheme);
|
||||
} else {
|
||||
requestAnimationFrame(onReady);
|
||||
}
|
||||
};
|
||||
|
||||
requestAnimationFrame(onReady);
|
||||
} catch (e) {
|
||||
console.error('Error applying theme:', e);
|
||||
}
|
||||
})();
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
<style>{`
|
||||
:root {
|
||||
--font-inter: ${interFont.style.fontFamily.replace(/\'/g, "")};
|
||||
|
||||
Reference in new issue
Block a user