refactor(projects): perf code

This commit is contained in:
Soybean
2024-03-24 03:02:08 +08:00
parent 187098136e
commit f91ef30bd5
54 changed files with 219 additions and 119 deletions

View File

@ -32,7 +32,7 @@ export const useAppStore = defineStore(SetupStoreId.App, () => {
*
* @param duration Duration time
*/
async function reloadPage(duration = 0) {
async function reloadPage(duration = 300) {
setReloadFlag(false);
if (duration > 0) {

View File

@ -81,7 +81,7 @@ export const useAuthStore = defineStore(SetupStoreId.Auth, () => {
// 2. store user info
localStg.set('userInfo', info);
// 3. update auth route
// 3. update store
token.value = loginToken.token;
Object.assign(userInfo, info);

View File

@ -104,7 +104,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
}
/**
* Re-cache routes by route key
* Re cache routes by route key
*
* @param routeKey
*/
@ -117,7 +117,7 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
}
/**
* Re-cache routes by route keys
* Re cache routes by route keys
*
* @param routeKeys
*/

View File

@ -1,8 +1,7 @@
import type { RouteLocationNormalizedLoaded, RouteRecordRaw, _RouteRecordBase } from 'vue-router';
import type { ElegantConstRoute, LastLevelRouteKey, RouteKey, RouteMap } from '@elegant-router/types';
import { useSvgIconRender } from '@sa/hooks';
import { $t } from '@/locales';
import SvgIcon from '@/components/custom/svg-icon.vue';
import { useSvgIcon } from '@/hooks/common/icon';
/**
* Filter auth routes by roles
@ -130,7 +129,7 @@ export function updateLocaleOfGlobalMenus(menus: App.Global.Menu[]) {
* @param route
*/
function getGlobalMenuByBaseRoute(route: RouteLocationNormalizedLoaded | ElegantConstRoute) {
const { SvgIconVNode } = useSvgIconRender(SvgIcon);
const { SvgIconVNode } = useSvgIcon();
const { name, path } = route;
const { title, i18nKey, icon = import.meta.env.VITE_MENU_ICON, localIcon } = route.meta ?? {};

View File

@ -78,7 +78,7 @@ export function getTabByRoute(route: App.Global.TabRoute) {
}
/**
* The vue router will automatically merge the metas of all matched items, and the icons here may be affected by other
* The vue router will automatically merge the meta of all matched items, and the icons here may be affected by other
* matching items, so they need to be processed separately
*
* @param route