From 3e60ff29701970e5b591e7104b5214a455a0156c Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Tue, 6 Dec 2022 16:12:54 +0800 Subject: [PATCH] feat: add cache key --- yudao-ui-admin-vue3/src/App.vue | 6 +- .../src/components/Setting/src/Setting.vue | 8 +-- .../src/components/UserInfo/src/UserInfo.vue | 4 +- .../src/directives/permission/hasPermi.ts | 4 +- .../src/directives/permission/hasRole.ts | 4 +- yudao-ui-admin-vue3/src/hooks/web/useCache.ts | 10 ++++ yudao-ui-admin-vue3/src/router/index.ts | 14 ++--- yudao-ui-admin-vue3/src/store/modules/app.ts | 14 ++--- yudao-ui-admin-vue3/src/store/modules/dict.ts | 6 +- .../src/store/modules/locale.ts | 8 +-- .../src/store/modules/permission.ts | 8 +-- yudao-ui-admin-vue3/src/store/modules/user.ts | 4 +- yudao-ui-admin-vue3/src/utils/auth.ts | 12 ++-- yudao-ui-admin-vue3/src/utils/routerHelper.ts | 6 +- yudao-ui-admin-vue3/src/views/Home/Index.vue | 7 ++- .../src/views/Login/components/LoginForm.vue | 57 +++++++++++-------- .../src/views/Login/components/MobileForm.vue | 6 +- .../src/views/system/menu/index.vue | 3 + 18 files changed, 100 insertions(+), 81 deletions(-) diff --git a/yudao-ui-admin-vue3/src/App.vue b/yudao-ui-admin-vue3/src/App.vue index 8236a03e9..353c701ac 100644 --- a/yudao-ui-admin-vue3/src/App.vue +++ b/yudao-ui-admin-vue3/src/App.vue @@ -4,7 +4,7 @@ import { isDark } from '@/utils/is' import { useAppStore } from '@/store/modules/app' import { useDesign } from '@/hooks/web/useDesign' import { ConfigGlobal } from '@/components/ConfigGlobal' -import { useCache } from '@/hooks/web/useCache' +import { CACHE_KEY, useCache } from '@/hooks/web/useCache' const { getPrefixCls } = useDesign() const prefixCls = getPrefixCls('app') @@ -15,8 +15,8 @@ const { wsCache } = useCache() // 根据浏览器当前主题设置系统主题色 const setDefaultTheme = () => { - if (wsCache.get('isDark')) { - if (wsCache.get('isDark') || wsCache.get('isDark') === 'true') { + if (wsCache.get(CACHE_KEY.IS_DARK)) { + if (wsCache.get(CACHE_KEY.IS_DARK) || wsCache.get(CACHE_KEY.IS_DARK) === 'true') { appStore.setIsDark(true) } else { appStore.setIsDark(false) diff --git a/yudao-ui-admin-vue3/src/components/Setting/src/Setting.vue b/yudao-ui-admin-vue3/src/components/Setting/src/Setting.vue index f48267672..9cad96d91 100644 --- a/yudao-ui-admin-vue3/src/components/Setting/src/Setting.vue +++ b/yudao-ui-admin-vue3/src/components/Setting/src/Setting.vue @@ -3,7 +3,7 @@ import { ElDrawer, ElDivider, ElMessage } from 'element-plus' import { ref, unref, computed, watch } from 'vue' import { useCssVar, useClipboard } from '@vueuse/core' import { useI18n } from '@/hooks/web/useI18n' -import { useCache } from '@/hooks/web/useCache' +import { CACHE_KEY, useCache } from '@/hooks/web/useCache' import { useDesign } from '@/hooks/web/useDesign' import { trim, setCssVar } from '@/utils' @@ -188,9 +188,9 @@ const copyConfig = async () => { // 清空缓存 const clear = () => { const { wsCache } = useCache() - wsCache.delete('layout') - wsCache.delete('theme') - wsCache.delete('isDark') + wsCache.delete(CACHE_KEY.LAYOUT) + wsCache.delete(CACHE_KEY.THEME) + wsCache.delete(CACHE_KEY.IS_DARK) window.location.reload() } diff --git a/yudao-ui-admin-vue3/src/components/UserInfo/src/UserInfo.vue b/yudao-ui-admin-vue3/src/components/UserInfo/src/UserInfo.vue index 33dd11ddd..cdce9ddf5 100644 --- a/yudao-ui-admin-vue3/src/components/UserInfo/src/UserInfo.vue +++ b/yudao-ui-admin-vue3/src/components/UserInfo/src/UserInfo.vue @@ -1,7 +1,7 @@