From 6b982984acd56c4e8ec83c3df45c79d28160ecd2 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期三, 17 四月 2024 19:01:49 +0800
Subject: [PATCH] fix 修复 el-select 展示不全问题
---
src/store/modules/app.ts | 37 ++++++++++++++++++-------------------
1 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts
index fd47c82..0205fab 100644
--- a/src/store/modules/app.ts
+++ b/src/store/modules/app.ts
@@ -1,51 +1,50 @@
-import Cookies from 'js-cookie';
-import zhCn from 'element-plus/es/locale/lang/zh-cn';
-import en from 'element-plus/es/locale/lang/en';
+import zhCN from 'element-plus/es/locale/lang/zh-cn';
+import enUS from 'element-plus/es/locale/lang/en';
export const useAppStore = defineStore('app', () => {
- const sidebarStatus = Cookies.get('sidebarStatus');
+ const sidebarStatus = useStorage('sidebarStatus', '1');
const sidebar = reactive({
- opened: sidebarStatus ? !!+sidebarStatus : true,
+ opened: sidebarStatus.value ? !!+sidebarStatus.value : true,
withoutAnimation: false,
hide: false
});
const device = ref<string>('desktop');
- const size = ref(Cookies.get('size') || 'default');
+ const size = useStorage<'large' | 'default' | 'small'>('size', 'default');
+
// 璇█
- const language = ref(Cookies.get('language'));
+ const language = useStorage('language', 'zh_CN');
+ const languageObj: any = {
+ en_US: enUS,
+ zh_CN: zhCN
+ };
const locale = computed(() => {
- if (language?.value == 'en') {
- return en;
- } else {
- return zhCn;
- }
+ return languageObj[language.value];
});
- const toggleSideBar = (withoutAnimation?: boolean) => {
+ const toggleSideBar = (withoutAnimation: boolean) => {
if (sidebar.hide) {
return false;
}
sidebar.opened = !sidebar.opened;
- sidebar.withoutAnimation = withoutAnimation as boolean;
+ sidebar.withoutAnimation = withoutAnimation;
if (sidebar.opened) {
- Cookies.set('sidebarStatus', '1');
+ sidebarStatus.value = '1';
} else {
- Cookies.set('sidebarStatus', '0');
+ sidebarStatus.value = '0';
}
};
const closeSideBar = ({ withoutAnimation }: any): void => {
- Cookies.set('sidebarStatus', '0');
+ sidebarStatus.value = '0';
sidebar.opened = false;
sidebar.withoutAnimation = withoutAnimation;
};
const toggleDevice = (d: string): void => {
device.value = d;
};
- const setSize = (s: string): void => {
+ const setSize = (s: 'large' | 'default' | 'small'): void => {
size.value = s;
- Cookies.set('size', s);
};
const toggleSideBarHide = (status: boolean): void => {
sidebar.hide = status;
--
Gitblit v1.9.3