Explorar o código

优化 切换组件大小无需刷新页面(不用window.location.reload)

夜鹰 hai 7 meses
pai
achega
a772de927f
Modificáronse 4 ficheiros con 14 adicións e 7 borrados
  1. 2 2
      Web/src/App.vue
  2. 1 1
      Web/src/layout/navBars/topBar/user.vue
  3. 10 3
      Web/src/main.ts
  4. 1 1
      Web/src/utils/other.ts

+ 2 - 2
Web/src/App.vue

@@ -61,9 +61,9 @@ const setLockScreen = computed(() => {
 // 	needUpdate.value = true;
 // }, 60000);
 
-// 获取全局组件大小
+// 获取全局组件大小,直接响应 themeConfig
 const getGlobalComponentSize = computed(() => {
-	return other.globalComponentSize();
+	return themeConfig.value.globalComponentSize;
 });
 // 获取全局 i18n
 const getGlobalI18n = computed(() => {

+ 1 - 1
Web/src/layout/navBars/topBar/user.vue

@@ -219,7 +219,7 @@ const onComponentSizeChange = (size: string) => {
 	themeConfig.value.globalComponentSize = size;
 	Local.set('themeConfig', themeConfig.value);
 	initI18nOrSize('globalComponentSize', 'disabledSize');
-	window.location.reload();
+	//window.location.reload();
 };
 // 语言切换
 const onLanguageChange = (lang: string) => {

+ 10 - 3
Web/src/main.ts

@@ -5,8 +5,7 @@ import router from '/@/router';
 import { directive } from '/@/directive/index';
 import { i18n } from '/@/i18n/index';
 import other from '/@/utils/other';
-import ElementPlus from 'element-plus';
-import { ElTooltip } from 'element-plus'
+import ElementPlus, { ElTooltip } from 'element-plus';
 import '/@/theme/index.scss';
 // 动画库
 import 'animate.css';
@@ -37,4 +36,12 @@ const TooltipProps = ElTooltip.props
 TooltipProps.showAfter = { type: Number, default: 800 }; // 设置全局tooltip延时显示时间为800毫秒
 
 
-app.use(pinia).use(router).use(ElementPlus).use(i18n).use(VueGridLayout).use(VForm3).use(VueSignaturePad).use(vue3TreeOrg).mount('#app');
+app.use(pinia)
+    .use(router)
+    .use(i18n)
+    .use(ElementPlus)
+    .use(VueGridLayout)
+    .use(VForm3)
+    .use(VueSignaturePad)
+    .use(vue3TreeOrg)
+    .mount('#app');

+ 1 - 1
Web/src/utils/other.ts

@@ -102,7 +102,7 @@ export const lazyImg = (el: string, arr: EmptyArrayType) => {
 export const globalComponentSize = (): string => {
 	const stores = useThemeConfig(pinia);
 	const { themeConfig } = storeToRefs(stores);
-	return Local.get('themeConfig')?.globalComponentSize || themeConfig.value?.globalComponentSize;
+	return themeConfig.value.globalComponentSize;
 };
 
 /**