fix: 侧边栏使用SCSS变量

This commit is contained in:
郝先瑞
2022-03-02 22:30:08 +08:00
parent d5394eec68
commit 2791cb7249
2 changed files with 8 additions and 11 deletions

View File

@@ -1,16 +1,13 @@
<template> <template>
<div :class="{'has-logo':showLogo}"> <div :class="{'has-logo':showLogo}">
<logo v-if="showLogo" :collapse="isCollapse"/> <logo v-if="showLogo" :collapse="isCollapse"/>
<!-- :background-color="variables.menuBg"
:text-color="variables.menuText"
:active-text-color="variables.menuActiveText"-->
<el-scrollbar wrap-class="scrollbar-wrapper"> <el-scrollbar wrap-class="scrollbar-wrapper">
<el-menu <el-menu
:default-active="activeMenu" :default-active="activeMenu"
:collapse="isCollapse" :collapse="isCollapse"
background-color="#304156" :background-color="variables.menuBg"
text-color="#bfcbd9" :text-color="variables.menuText"
active-text-color="#409EFF" :active-text-color="variables.menuActiveText"
:unique-opened="false" :unique-opened="false"
:collapse-transition="false" :collapse-transition="false"
mode="vertical"> mode="vertical">
@@ -30,19 +27,18 @@
import {computed, defineComponent} from "vue"; import {computed, defineComponent} from "vue";
import SidebarItem from './SidebarItem.vue' import SidebarItem from './SidebarItem.vue'
import Logo from './Logo.vue' import Logo from './Logo.vue'
import variables from '@/styles/variables.scss' import variables from '@/styles/variables.module.scss'
import { useSettingStoreHook } from "@/store/modules/settings"; import { useSettingStoreHook } from "@/store/modules/settings";
import { useAppStoreHook } from "@/store/modules/app"; import { useAppStoreHook } from "@/store/modules/app";
import { usePermissionStoreHook } from "@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";
import {useRoute} from 'vue-router' import {useRoute} from 'vue-router'
const route =useRoute()
const route =useRoute()
const routes =computed(() => usePermissionStoreHook().routes) const routes =computed(() => usePermissionStoreHook().routes)
const showLogo = computed(() => useSettingStoreHook().sidebarLogo) const showLogo = computed(() => useSettingStoreHook().sidebarLogo)
const isCollapse = computed(() => !useAppStoreHook().sidebar.opened) const isCollapse = computed(() => !useAppStoreHook().sidebar.opened)
const activeMenu = computed(() => { const activeMenu = computed(() => {
const {meta, path} = route const {meta, path} = route
// if set path, the sidebar will highlight the path you set // if set path, the sidebar will highlight the path you set

View File

@@ -10,9 +10,9 @@ import variables from '@/styles/element-variables.module.scss'
export const useSettingStore = defineStore({ export const useSettingStore = defineStore({
id: "setting", id: "setting",
state: (): SettingState => ({ state: (): SettingState => ({
theme: localStorage.get("theme") || variables.theme, theme: variables.theme || localStorage.get("theme"),
showSettings: showSettings, showSettings: showSettings,
tagsView: tagsView, tagsView: localStorage.get("tagsView") != null ? localStorage.get("tagsView") : tagsView,
fixedHeader: fixedHeader, fixedHeader: fixedHeader,
sidebarLogo: sidebarLogo, sidebarLogo: sidebarLogo,
}), }),
@@ -31,6 +31,7 @@ export const useSettingStore = defineStore({
break break
case 'tagsView': case 'tagsView':
this.tagsView = value this.tagsView = value
localStorage.set("tagsView", value)
break break
case 'sidebarLogo': case 'sidebarLogo':
this.sidebarLogo = value this.sidebarLogo = value