From e87c38a9d2cf5071a69a9add86ee6fc7568b83f4 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Thu, 17 Mar 2022 19:00:01 +0800 Subject: [PATCH] perf: router rank --- src/router/utils.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/router/utils.ts b/src/router/utils.ts index 57e687a..8c418d9 100644 --- a/src/router/utils.ts +++ b/src/router/utils.ts @@ -22,6 +22,13 @@ import { getAsyncRoutes } from "/@/api/routes"; // 按照路由中meta下的rank等级升序来排序路由 function ascending(arr: any[]) { + arr.forEach(v => { + if (v?.meta?.rank === 0) { + if (v.name !== "home" && v.path !== "/") { + console.warn("rank only the home page can be 0"); + } + } + }); return arr.sort( (a: { meta: { rank: number } }, b: { meta: { rank: number } }) => { return a?.meta?.rank - b?.meta?.rank;