diff --git a/src/components/common/app-loading.vue b/src/components/common/app-loading.vue index eb72b10..565c3be 100644 --- a/src/components/common/app-loading.vue +++ b/src/components/common/app-loading.vue @@ -48,7 +48,13 @@ import { hexToRgba } from "@/utils" const SYSTEM_NAME = "WindAdmin" const setting = JSON.parse(localStorage.getItem("setting") || "{}") -const themeColor = setting.themeColor || "#1890ff" +const themeColor = setting.themeColor || "#5ac8fa" +const setThemeByCache = () => { + document.documentElement.style.setProperty("--theme-color", themeColor) + document.documentElement.style.setProperty("--menu-color-hover", hexToRgba(themeColor, 0.3)) + document.documentElement.style.setProperty("--tabbar-color-hover", hexToRgba(themeColor, 0.2)) +} +setThemeByCache() \ No newline at end of file + diff --git a/src/layouts/logo/Logo.vue b/src/layouts/logo/Logo.vue index 02ad8a2..b66b154 100644 --- a/src/layouts/logo/Logo.vue +++ b/src/layouts/logo/Logo.vue @@ -1,16 +1,15 @@ @@ -32,7 +31,8 @@ const settingStore = useSettingStore() .title { padding: 0 10px; .text { - @apply text-16px font-bold text-primary transition duration-300 ease-in-out; + color: var(--theme-color); + @apply text-16px font-bold transition duration-300 ease-in-out; } } } diff --git a/src/layouts/setting/SystemSet.vue b/src/layouts/setting/SystemSet.vue index d758ada..5f11b2a 100644 --- a/src/layouts/setting/SystemSet.vue +++ b/src/layouts/setting/SystemSet.vue @@ -3,6 +3,15 @@ import { ref, watchEffect, watch, computed } from "vue" import { useSettingStore } from "@/store" import themeColorConfig from "@/assets/themes/themeColor.json" import OtherColor from "@/assets/themes/color.json" +import { useDark, useToggle } from "@vueuse/core" + +const isDark = useDark({ + selector: "html", + attribute: "color-scheme", + valueDark: "dark", + valueLight: "light", +}) +const toggleDark = useToggle(isDark) const colorDialogV = ref(false) const activeTab = ref("红色系") @@ -53,7 +62,7 @@ const animateModeList = [ inactive-value="light" active-action-icon="Moon" inactive-action-icon="Sunny" - @change="settingStore.setThemeBg" + @change="toggleDark()" style="--el-switch-on-color: #18181c; --el-switch-off-color: #dadada"> @@ -63,7 +72,7 @@ const animateModeList = [ - + 左右 - + { const setThemeColor = computed(() => { return router.currentRoute.value.path === props.item.path - ? settingStore.themeColor - : defaultThemeColor[settingStore.themeBg].menuTextColor + ? 'var(--theme-color)' + : 'var(--text-color)' }) const visitedViewStore = useVisitedViewStore() @@ -78,7 +77,7 @@ const handleClick = item => { z-index: 1; margin: 3px 8px; border-radius: 5px; - background-color: v-bind(activeMenuBg); + background-color: var(--menu-color-hover); } .is-active::before { @extend #before; diff --git a/src/layouts/sidebar/MenuScroll.vue b/src/layouts/sidebar/MenuScroll.vue index 4ba2e56..3cb8cc8 100644 --- a/src/layouts/sidebar/MenuScroll.vue +++ b/src/layouts/sidebar/MenuScroll.vue @@ -1,6 +1,4 @@ @@ -46,9 +43,7 @@ onMounted(() => {}) :mode="mode" :collapse-transition="false" :ellipsis="false" - popper-effect="dark" - :background-color="defaultThemeColor[settingStore.themeBg].menuColor" - :text-color="defaultThemeColor[settingStore.themeBg].menuTextColor"> + popper-effect="dark"> @@ -71,9 +66,7 @@ onMounted(() => {}) width: 100%; height: 100%; border: none; - background: transparent; transition: all 0.3s; - .el-sub-menu { background: inherit !important; } diff --git a/src/layouts/sidebar/MenuSub.vue b/src/layouts/sidebar/MenuSub.vue index 6519593..b0c3bb7 100644 --- a/src/layouts/sidebar/MenuSub.vue +++ b/src/layouts/sidebar/MenuSub.vue @@ -1,12 +1,6 @@ @@ -57,7 +47,7 @@ const setThemeColor = computed(() => { z-index: 1; margin: 4px 8px; border-radius: 5px; - background-color: v-bind(activeMenuBg) !important; + background-color: var(--menu-color-hover); } :deep(.el-sub-menu__title) { diff --git a/src/layouts/tabbar/TabBar.vue b/src/layouts/tabbar/TabBar.vue index 1211ef5..93531c5 100644 --- a/src/layouts/tabbar/TabBar.vue +++ b/src/layouts/tabbar/TabBar.vue @@ -13,14 +13,6 @@ useTabBarEvent() const activeTableTabsValue = ref("/index/home") -const activeMenuBg = computed(() => { - return settingStore.getMenuActiveBg(0.1) -}) - -const activeColor = computed(() => { - return settingStore.themeColor -}) - watch( router.currentRoute, newValue => { @@ -164,14 +156,14 @@ const closeTab = (type, event) => { height: 30px; font-size: 12px; border-radius: 5px; - background-color: v-bind(activeMenuBg); + background-color: var(--tabbar-color-hover); border: none; &:hover { - color: v-bind(activeColor); + color: var(--theme-color); } } .is-active { - color: v-bind(activeColor); + color: var(--theme-color); } } } diff --git a/src/layouts/themes/ClassicTheme.vue b/src/layouts/themes/ClassicTheme.vue index bb1f569..264bc27 100644 --- a/src/layouts/themes/ClassicTheme.vue +++ b/src/layouts/themes/ClassicTheme.vue @@ -1,5 +1,4 @@