diff --git a/app/components/AppHeader.vue b/app/components/AppHeader.vue
deleted file mode 100644
index d8f647d..0000000
--- a/app/components/AppHeader.vue
+++ /dev/null
@@ -1,144 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/components/blog/BlogHeader.vue b/app/components/blog/BlogHeader.vue
index 3c0b0ce..d77c219 100644
--- a/app/components/blog/BlogHeader.vue
+++ b/app/components/blog/BlogHeader.vue
@@ -49,6 +49,15 @@ const handleLoginRegister = (type: 'login' | 'register') => {
mode="modal"
class="bg-gray-50 dark:bg-gray-900"
>
+
+
+
diff --git a/app/components/docs/DocsHeader.vue b/app/components/docs/DocsHeader.vue
index 2cbdeb9..aced9d9 100644
--- a/app/components/docs/DocsHeader.vue
+++ b/app/components/docs/DocsHeader.vue
@@ -49,6 +49,15 @@ const handleLoginRegister = (type: 'login' | 'register') => {
mode="modal"
class="bg-gray-50 dark:bg-gray-900"
>
+
+
+
diff --git a/app/components/shared/wxShare.vue b/app/components/shared/wxShare.vue
index 9e4daa4..a1e7b1a 100644
--- a/app/components/shared/wxShare.vue
+++ b/app/components/shared/wxShare.vue
@@ -98,8 +98,6 @@ function setupShare(appId: string, timestamp: number, nonceStr: string, signatur
console.error('[WxShare] wx.error:', e)
})
}
-
-
diff --git a/app/composables/useTheme.ts b/app/composables/useTheme.ts
index 123e9ca..d79b3df 100644
--- a/app/composables/useTheme.ts
+++ b/app/composables/useTheme.ts
@@ -41,7 +41,7 @@
*
* ```
*/
-import { ref, watch } from 'vue'
+import { ref, watch, getCurrentInstance, onMounted } from 'vue'
// 定义各种选项
const themes = [
@@ -224,18 +224,34 @@ export function useTheme() {
}
}
- // 确保在客户端时立即初始化
+ // 确保在客户端时初始化
if (import.meta.client) {
// 立即初始化,避免闪烁
initializeTheme()
- // 确保在DOM准备好后再次应用
- onMounted(() => {
- applyThemeVariables()
- if (selectedThemeColor.value === 'custom') {
- applyCustomColor()
+ const instance = getCurrentInstance()
+ if (instance) {
+ // 在组件 setup 上下文中,安全使用 onMounted
+ onMounted(() => {
+ applyThemeVariables()
+ if (selectedThemeColor.value === 'custom') {
+ applyCustomColor()
+ }
+ })
+ } else {
+ // 非组件上下文(如插件)中,等待文档就绪后应用
+ const run = () => {
+ applyThemeVariables()
+ if (selectedThemeColor.value === 'custom') {
+ applyCustomColor()
+ }
}
- })
+ if (document.readyState === 'loading') {
+ window.addEventListener('DOMContentLoaded', () => run(), { once: true })
+ } else {
+ run()
+ }
+ }
}
const resetSettings = () => {