This commit is contained in:
bietiaop
2025-02-08 23:45:33 +08:00
parent a6a11a7026
commit 96d79cf495
3 changed files with 7 additions and 3 deletions

View File

@@ -13,7 +13,6 @@
content="viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" content="viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
name="viewport" /> name="viewport" />
<link href="/favicon.ico" rel="icon" /> <link href="/favicon.ico" rel="icon" />
<link href="/files/theme.css" rel="stylesheet" />
</head> </head>
<body> <body>

View File

@@ -22,6 +22,11 @@ if (theme && !theme.startsWith('"')) {
localStorage.setItem(key.theme, JSON.stringify(theme)) localStorage.setItem(key.theme, JSON.stringify(theme))
} }
const themeStyle = document.createElement('link')
themeStyle.rel = 'stylesheet'
themeStyle.href = '/files/theme.css'
document.head.appendChild(themeStyle)
ReactDOM.createRoot(document.getElementById('root')!).render( ReactDOM.createRoot(document.getElementById('root')!).render(
// <React.StrictMode> // <React.StrictMode>
<BrowserRouter basename="/webui/"> <BrowserRouter basename="/webui/">

View File

@@ -87,12 +87,12 @@ export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapp
// 生成css分为亮色和暗色靠class和[data-theme="light"] // 生成css分为亮色和暗色靠class和[data-theme="light"]
let css = '.dark, [data-theme="dark"] {'; let css = '.dark, [data-theme="dark"] {';
for (const key in colors.dark) { for (const key in colors.dark) {
css += `--${key}: ${colors.dark[key]};`; css += `${key}: ${colors.dark[key]};`;
} }
css += '}'; css += '}';
css += '.light, [data-theme="light"] {'; css += '.light, [data-theme="light"] {';
for (const key in colors.light) { for (const key in colors.light) {
css += `--${key}: ${colors.light[key]};`; css += `${key}: ${colors.light[key]};`;
} }
css += '}'; css += '}';