From 168d3e625b591ed87b9e7aab70bdff7ce8caea73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=96=AF=EF=BC=88xiaosi=EF=BC=89?= <1531733886@qq.com> Date: Sat, 24 Dec 2022 22:42:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(locales):=20=F0=9F=90=9B=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=88=B7=E6=96=B0=20=E7=81=B0=E8=89=B2=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=20=E8=89=B2=E5=BC=B1=E6=A8=A1=E5=BC=8F=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 4 -- src/components/Application/AppTheme.vue | 21 +++--- src/config/index.ts | 2 + src/hooks/useTransformTheme.ts | 66 ------------------ .../components/Seting/ThemeSettings/index.vue | 6 +- .../pageLayouts/components/Seting/index.vue | 1 - .../components/SideNavigationBar/index.vue | 2 +- src/store/types.ts | 4 +- src/utils/theme/transformTheme.ts | 69 +++++++++++++++++++ 9 files changed, 84 insertions(+), 91 deletions(-) delete mode 100644 src/hooks/useTransformTheme.ts create mode 100644 src/utils/theme/transformTheme.ts diff --git a/index.html b/index.html index 8ff0a55b..6ea386a8 100644 --- a/index.html +++ b/index.html @@ -172,10 +172,6 @@ if (primaryColor) { const loading = document.getElementById('html_loding'); loading.style.color = primaryColor; - const style = document.getElementById('admin-style-root-color'); - style.innerHTML = `html:root{ --el-color-primary: ${primaryColor};\n}`; - // const body = document.documentElement; - // body.style.setProperty('--el-color-primary', primaryColor); } } diff --git a/src/components/Application/AppTheme.vue b/src/components/Application/AppTheme.vue index fd8f3a24..6276b76f 100644 --- a/src/components/Application/AppTheme.vue +++ b/src/components/Application/AppTheme.vue @@ -2,27 +2,22 @@ import { useColorMode } from '@vueuse/core'; import { watch } from 'vue'; import SvgIcon from '../SvgIcon/index.vue'; - import { useTransformTheme } from '@/hooks/useTransformTheme'; import { useRootSetting } from '@/hooks/setting/useRootSetting'; + import type { AppConfig } from '@/store/types'; + import { updateColor } from '@/utils/theme/transformTheme'; const color = useColorMode(); - const { setAppConfigMode } = useRootSetting(); - - const { updateColor } = useTransformTheme(); + const { appConfig, setAppConfigMode } = useRootSetting(); const toggleDarkMode = () => { - setAppConfigMode({ themeMode: color.value }); + setAppConfigMode({ themeMode: color.value as AppConfig['themeMode'] }); }; - watch( - color, - () => { - toggleDarkMode(); - updateColor(); - }, - { immediate: true }, - ); + watch(color, () => { + toggleDarkMode(); + updateColor(appConfig.value.primaryColor, color.value as AppConfig['themeMode']); + });