From 2a14a16b5a6774b67afee2e114e15f8af5de6b82 Mon Sep 17 00:00:00 2001 From: Mickey wu Date: Mon, 25 May 2026 21:30:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8F=90=E5=8F=96=20ProviderThemeV?= =?UTF-8?q?ars=20=E7=B1=BB=E5=9E=8B=E5=B9=B6=E7=A7=BB=E9=99=A4=E5=86=97?= =?UTF-8?q?=E4=BD=99=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/types/theme.ts | 4 ++++ src/pages/mine/settings/theme/index.vue | 4 ++-- src/store/modules/theme.ts | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/composables/types/theme.ts b/src/composables/types/theme.ts index a70d74f..9817480 100644 --- a/src/composables/types/theme.ts +++ b/src/composables/types/theme.ts @@ -34,3 +34,7 @@ export const themeColorOptions: ThemeColorOption[] = [ { name: "紫罗兰", value: "purple", primary: "#8A2BE2" }, { name: "朱砂红", value: "red", primary: "#FF4757" }, ]; + +export interface ProviderThemeVars extends ConfigProviderThemeVars { + colorTheme: string; +} \ No newline at end of file diff --git a/src/pages/mine/settings/theme/index.vue b/src/pages/mine/settings/theme/index.vue index 9611bd8..97885a6 100644 --- a/src/pages/mine/settings/theme/index.vue +++ b/src/pages/mine/settings/theme/index.vue @@ -101,7 +101,7 @@ }); // 使用主题组合函数 - const { isDark, themeVars, themeColorOptions, toggleTheme, setThemeColor } = useTheme(); + const { isDark, themeColorOptions, toggleTheme, setThemeColor } = useTheme(); const toast = useToast(); const { confirm } = useDialog(); @@ -115,7 +115,7 @@ // 当前选中的主题色 const currentThemeColor = computed(() => { - return themeVars.colorTheme || themeColorOptions[0].primary; + return themeColorOptions[0].primary; }); // 选择预设颜色 diff --git a/src/store/modules/theme.ts b/src/store/modules/theme.ts index 6d6027b..556299b 100644 --- a/src/store/modules/theme.ts +++ b/src/store/modules/theme.ts @@ -1,7 +1,7 @@ import { defineStore } from "pinia"; import { Storage } from "@/utils/storage"; import { THEME_MODE_KEY, THEME_COLOR_KEY } from "@/constants"; -import type { ThemeColorOption, ThemeMode } from "@/composables/types/theme"; +import type { ProviderThemeVars, ThemeColorOption, ThemeMode } from "@/composables/types/theme"; import type { ConfigProviderThemeVars } from "@wot-ui/ui"; import { themeColorOptions } from "@/composables/types/theme"; @@ -36,12 +36,12 @@ export const useThemeStore = defineStore("theme", () => { const darkThemeVars = {}; /** 主题变量(计算属性,根据模式动态切换) */ - const themeVars = computed(() => { + const themeVars = computed(() => { const base = { colorTheme: currentThemeColor.value.primary }; if (theme.value === "dark") { - return { ...base, ...darkThemeVars } as ConfigProviderThemeVars; + return { ...base, ...darkThemeVars } as ProviderThemeVars; } - return base as ConfigProviderThemeVars; + return base as ProviderThemeVars; }); // ==========================================================================