nomadro/apps/nomadvip/app/theme-init.ts
eric 9f8fec1723 Ship portal PC/H5 acceptance, VIP ScrollReader, admin analytics and ops anchors.
Adds /api/health, ntfy notify on config save, /admin/analytics charts, and deploy smoke for miniprogram config/API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 23:52:00 -05:00

26 lines
827 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 主题初始化 - 在 React 水合前执行,避免主题闪烁
* 优先读全局 nomadro-theme,回退 nomadvip-theme;默认夜间
*/
export const themeInitScript = `
(function() {
try {
var theme = localStorage.getItem('nomadro-theme') || localStorage.getItem('nomadvip-theme');
var resolved = theme === 'light'
? 'light'
: (theme === 'dark'
? 'dark'
: (theme === 'system'
? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
: 'dark'));
var root = document.documentElement;
root.classList.remove('light', 'dark');
root.classList.add(resolved);
root.dataset.theme = resolved;
} catch (e) {
document.documentElement.classList.add('dark');
document.documentElement.dataset.theme = 'dark';
}
})();
`;