perf: 同步完整版代码

This commit is contained in:
xiaoxian521
2022-04-18 11:15:46 +08:00
parent 736f1c27cd
commit 77049fdbd7
12 changed files with 527 additions and 393 deletions

View File

@@ -9,6 +9,8 @@ import { storageSession } from "/@/utils/storage";
import { useAppStoreHook } from "/@/store/modules/app";
import { useEpThemeStoreHook } from "/@/store/modules/epTheme";
const errorInfo = "当前路由配置不正确,请检查配置";
export function useNav() {
const pureApp = useAppStoreHook();
// 用户名
@@ -24,6 +26,10 @@ export function useNav() {
};
});
const avatarsStyle = computed(() => {
return username ? { marginRight: "10px" } : "";
});
const isCollapse = computed(() => {
return !pureApp.getSidebarStatus;
});
@@ -59,6 +65,7 @@ export function useNav() {
}
function resolvePath(route) {
if (!route.children) return console.error(errorInfo);
const httpReg = /^http(s?):\/\//;
const routeChildPath = route.children[0]?.path;
if (httpReg.test(routeChildPath)) {
@@ -77,6 +84,7 @@ export function useNav() {
}
// 找到当前路由的信息
function findCurrentRoute(indexPath: string, routes) {
if (!routes) return console.error(errorInfo);
return routes.map(item => {
if (item.path === indexPath) {
if (item.redirect) {
@@ -113,6 +121,7 @@ export function useNav() {
isCollapse,
pureApp,
username,
avatarsStyle,
getDropdownItemStyle
};
}