From 9337c3cf960b60078558b7f942fd27f1ab39364b Mon Sep 17 00:00:00 2001
From: 李凌 <344137771@qq.com>
Date: Tue, 16 Dec 2025 18:29:46 +0800
Subject: [PATCH] 改黑夜样式

---
 src/main.js |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/main.js b/src/main.js
index 947c03e..063cd07 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,6 +1,7 @@
 import { createApp } from 'vue'
 import './assets/css/index.scss'
 import './assets/css/init.scss'
+import './assets/theme/index.scss'
 import 'vant/lib/index.css'
 import fxHeader from '@/components/fx-header'
 import 'default-passive-events'
@@ -13,8 +14,12 @@
 import pinia from '@/store'
 import store from '@/store/store'
 import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
+import { getStorage } from '@/utils/utis'
 pinia.use(piniaPluginPersistedstate)
 
+// 初始化主题为黑夜模式
+const theme = getStorage('theme') || 'dark'
+window.document.documentElement.setAttribute('data-theme', theme)
 
 const app = createApp(App)
 const title = import.meta.env.VITE_APP__TITLE
@@ -26,4 +31,11 @@
 app.use(pinia)
 app.use(store)
 
+// 确保store中的主题状态与DOM同步
 app.mount('#app')
+// 在应用挂载后初始化主题
+if (store.state.vant && store.state.vant.theme !== theme) {
+  store.commit('vant/SET_THEME', theme)
+} else if (!store.state.vant || !store.state.vant.theme) {
+  store.commit('vant/SET_THEME', theme)
+}

--
Gitblit v1.9.3