This commit is contained in:
bietiaop
2025-02-09 00:18:14 +08:00
parent 1702f429b4
commit 024a3eb760

View File

@@ -84,17 +84,17 @@ export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapp
// 如果是自定义色彩构建一个css文件 // 如果是自定义色彩构建一个css文件
app.use('/files/theme.css', async (_req, res) => { app.use('/files/theme.css', async (_req, res) => {
const colors = await WebUiConfig.GetTheme(); const colors = await WebUiConfig.GetTheme();
// 生成css分为亮色和暗色靠class和[data-theme="light"]
let css = '.dark, [data-theme="dark"] {'; let css = ':root, .light, [data-theme="light"] {';
for (const key in colors.dark) {
css += `${key}: ${colors.dark[key]};`;
}
css += '}';
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 += '}';
css += '.dark, [data-theme="dark"] {';
for (const key in colors.dark) {
css += `${key}: ${colors.dark[key]};`;
}
css += '}';
res.send(css); res.send(css);
}); });