mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 12:02:50 +08:00
fix: consolidate audited dev updates
This commit is contained in:
1 parent
568b8fd8be
commit
0a552f7ee8
58 files changed
+1930
-132
No files matched your search
@@ -7,6 +7,8 @@ import darkCss from "../skins/builtin/dark/skin.css?inline";
|
||||
|
||||
const THEME_KEY = "webspeak:theme";
|
||||
const SKIN_STYLE_ELEMENT_ID = "webspeak-active-built-in-skin";
|
||||
const LIGHT_THEME_COLOR = "#006a64";
|
||||
const DARK_THEME_COLOR = "#101918";
|
||||
let activeThemeMode: ThemeMode = "system";
|
||||
|
||||
const builtinSkins = {
|
||||
@@ -29,11 +31,22 @@ export function applyTheme(theme: ThemeMode, options: { preserveCustomSkins?: bo
|
||||
if (typeof document === "undefined") return;
|
||||
activeThemeMode = theme;
|
||||
const root = document.documentElement;
|
||||
const dark = isDarkTheme(theme);
|
||||
const activeSkin = isDarkTheme(theme) ? builtinSkins.dark : builtinSkins.light;
|
||||
|
||||
// Keep data-theme for the admin console's independent appearance rules.
|
||||
// Built-in skin CSS is scoped to public roots and can never restyle /admin.
|
||||
root.dataset.theme = theme;
|
||||
if (root.style) root.style.colorScheme = dark ? "dark" : "light";
|
||||
if (typeof document.querySelector === "function" && typeof document.createElement === "function" && document.head) {
|
||||
let themeColor = document.querySelector<HTMLMetaElement>('meta[name="theme-color"]');
|
||||
if (!themeColor) {
|
||||
themeColor = document.createElement("meta");
|
||||
themeColor.name = "theme-color";
|
||||
document.head.append(themeColor);
|
||||
}
|
||||
themeColor.content = dark ? DARK_THEME_COLOR : LIGHT_THEME_COLOR;
|
||||
}
|
||||
document.querySelectorAll<HTMLElement>(".ws-skin-root").forEach((clientRoot) => {
|
||||
const currentSkin = clientRoot.dataset.wsSkin;
|
||||
const isCustomSkin = currentSkin !== builtinSkins.light.manifest.id && currentSkin !== builtinSkins.dark.manifest.id;
|
||||
|
||||
Reference in new issue
Block a user