perf: 优化示例代码

This commit is contained in:
xiaoxian521
2022-04-11 12:17:47 +08:00
parent c4ebacedfe
commit 160db34fa0
12 changed files with 105 additions and 60 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();
// 用户名
@@ -59,6 +61,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 +80,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) {