From a09d805bd948a4212c456f5dc6b507ab45236a0f Mon Sep 17 00:00:00 2001 From: MengStack Dev Date: Sat, 3 Oct 2026 01:42:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=89=E5=B1=82=E6=98=8E=E6=9A=97?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=20+=20=E7=A7=BB=E5=8A=A8=E7=AB=AF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=9D=97=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 useTheme.js 单例主题管理器:用户手动选择 > 系统偏好 > 时间自动切换(8AM/6PM) - config.ts 添加 head 内联脚本防止主题闪烁 - 移动端导航按钮右对齐(margin-left:auto) - 首页和文档页代码块移动端溢出修复 --- .vitepress/config.ts | 12 ++++ .vitepress/theme/Home.vue | 18 ++--- .vitepress/theme/Layout.vue | 3 + .vitepress/theme/custom.css | 29 ++++++++ .vitepress/theme/useTheme.js | 125 +++++++++++++++++++++++++++++++++++ 5 files changed, 179 insertions(+), 8 deletions(-) create mode 100644 .vitepress/theme/useTheme.js diff --git a/.vitepress/config.ts b/.vitepress/config.ts index da8f442..71b3c69 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -63,6 +63,18 @@ export default defineConfig({ ['link', { rel: 'icon', href: '/favicon.png' }], ['meta', { property: 'og:image', content: '/og-image.png' }], ['meta', { name: 'theme-color', content: '#C8963E' }], + ['script', {}, ` + (function(){ + var E='mengstack-theme-explicit',V='vitepress-theme-appearance'; + var d=false,e=localStorage.getItem(E); + if(e!==null){d=e==='true'} + else if(window.matchMedia&&window.matchMedia('(prefers-color-scheme:dark)').matches){d=true} + else if(window.matchMedia&&window.matchMedia('(prefers-color-scheme:light)').matches){d=false} + else{var h=new Date().getHours();d=h<8||h>=18} + if(d)document.documentElement.classList.add('dark'); + try{localStorage.setItem(V,String(d))}catch(x){} + })() + `], ], transformHead({ pageData }) { diff --git a/.vitepress/theme/Home.vue b/.vitepress/theme/Home.vue index 3ea2929..35ebe69 100644 --- a/.vitepress/theme/Home.vue +++ b/.vitepress/theme/Home.vue @@ -18,7 +18,7 @@ 社区
- @@ -338,18 +338,14 @@ Check /health