refactor: 提取 ProviderThemeVars 类型并移除冗余变量
This commit is contained in:
@@ -34,3 +34,7 @@ export const themeColorOptions: ThemeColorOption[] = [
|
|||||||
{ name: "紫罗兰", value: "purple", primary: "#8A2BE2" },
|
{ name: "紫罗兰", value: "purple", primary: "#8A2BE2" },
|
||||||
{ name: "朱砂红", value: "red", primary: "#FF4757" },
|
{ name: "朱砂红", value: "red", primary: "#FF4757" },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export interface ProviderThemeVars extends ConfigProviderThemeVars {
|
||||||
|
colorTheme: string;
|
||||||
|
}
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 使用主题组合函数
|
// 使用主题组合函数
|
||||||
const { isDark, themeVars, themeColorOptions, toggleTheme, setThemeColor } = useTheme();
|
const { isDark, themeColorOptions, toggleTheme, setThemeColor } = useTheme();
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const { confirm } = useDialog();
|
const { confirm } = useDialog();
|
||||||
@@ -115,7 +115,7 @@
|
|||||||
|
|
||||||
// 当前选中的主题色
|
// 当前选中的主题色
|
||||||
const currentThemeColor = computed(() => {
|
const currentThemeColor = computed(() => {
|
||||||
return themeVars.colorTheme || themeColorOptions[0].primary;
|
return themeColorOptions[0].primary;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 选择预设颜色
|
// 选择预设颜色
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { Storage } from "@/utils/storage";
|
import { Storage } from "@/utils/storage";
|
||||||
import { THEME_MODE_KEY, THEME_COLOR_KEY } from "@/constants";
|
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 type { ConfigProviderThemeVars } from "@wot-ui/ui";
|
||||||
import { themeColorOptions } from "@/composables/types/theme";
|
import { themeColorOptions } from "@/composables/types/theme";
|
||||||
|
|
||||||
@@ -36,12 +36,12 @@ export const useThemeStore = defineStore("theme", () => {
|
|||||||
const darkThemeVars = {};
|
const darkThemeVars = {};
|
||||||
|
|
||||||
/** 主题变量(计算属性,根据模式动态切换) */
|
/** 主题变量(计算属性,根据模式动态切换) */
|
||||||
const themeVars = computed<ConfigProviderThemeVars>(() => {
|
const themeVars = computed<ProviderThemeVars>(() => {
|
||||||
const base = { colorTheme: currentThemeColor.value.primary };
|
const base = { colorTheme: currentThemeColor.value.primary };
|
||||||
if (theme.value === "dark") {
|
if (theme.value === "dark") {
|
||||||
return { ...base, ...darkThemeVars } as ConfigProviderThemeVars;
|
return { ...base, ...darkThemeVars } as ProviderThemeVars;
|
||||||
}
|
}
|
||||||
return base as ConfigProviderThemeVars;
|
return base as ProviderThemeVars;
|
||||||
});
|
});
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user