chore: 初始化仓库,导入项目基线代码
Academy v0.8.3 完整代码基线:Go 后端(internal/cmd/cli/mcp-server/docreader)、 Vue 前端(frontend)、数据库迁移(migrations)、部署编排(docker/helm/deploy)与文档。 今日开发的培训推送管理改动随后单独提交。
This commit is contained in:
commit
7ec21f35b0
5767 files changed
+1436788
No files matched your search
@@ -0,0 +1,39 @@
|
||||
// VitePress uses this same key and the values light / dark / auto.
|
||||
export const themeStorageKey = "vitepress-theme-appearance";
|
||||
|
||||
export const themeInitializationScript = `(function(){var t='auto';try{t=localStorage.getItem('${themeStorageKey}')||'auto'}catch(e){}document.documentElement.classList.toggle('dark',t==='dark'||(t!=='light'&&matchMedia('(prefers-color-scheme: dark)').matches))})()`;
|
||||
|
||||
export function getThemeSnapshot() {
|
||||
return document.documentElement.classList.contains("dark");
|
||||
}
|
||||
|
||||
export function subscribeToTheme(notify: () => void) {
|
||||
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
const applyPreference = () => {
|
||||
let preference = "auto";
|
||||
try { preference = localStorage.getItem(themeStorageKey) || "auto"; } catch { /* Storage can be disabled. */ }
|
||||
document.documentElement.classList.toggle("dark", preference === "dark" || (preference !== "light" && media.matches));
|
||||
notify();
|
||||
};
|
||||
const onStorage = (event: StorageEvent) => {
|
||||
if (event.key === themeStorageKey || event.key === null) applyPreference();
|
||||
};
|
||||
const observer = new MutationObserver(notify);
|
||||
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
|
||||
media.addEventListener("change", applyPreference);
|
||||
window.addEventListener("storage", onStorage);
|
||||
window.addEventListener("pageshow", applyPreference);
|
||||
applyPreference();
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
media.removeEventListener("change", applyPreference);
|
||||
window.removeEventListener("storage", onStorage);
|
||||
window.removeEventListener("pageshow", applyPreference);
|
||||
};
|
||||
}
|
||||
|
||||
export function toggleTheme() {
|
||||
const dark = !getThemeSnapshot();
|
||||
document.documentElement.classList.toggle("dark", dark);
|
||||
try { localStorage.setItem(themeStorageKey, dark ? "dark" : "light"); } catch { /* The current page still switches. */ }
|
||||
}
|
||||
Reference in new issue
Block a user