-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
307 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,36 @@ | ||
import { AppRouteRecordRaw } from '#/route'; | ||
import { pathNamekeyCheck, setUpRoutePath } from '../utils'; | ||
|
||
const modules = import.meta.globEager('./**/*.ts'); | ||
function configRouteList() { | ||
// 白名单目录/文件 | ||
const whiteCatalogue = ['root', 'whiteList']; | ||
|
||
const routeModuleList: AppRouteRecordRaw[] = []; | ||
let routeModulesList: AppRouteRecordRaw[] = []; //菜单路由 | ||
const whiteRouteModulesList: AppRouteRecordRaw[] = []; // 不参与菜单处理的路由 | ||
|
||
Object.keys(modules).forEach((key) => { | ||
const mod = modules[key].default || {}; | ||
const modList = Array.isArray(mod) ? [...mod] : [mod]; | ||
routeModuleList.push(...modList); | ||
}); | ||
// 自动查找路由配置文件 | ||
const modules = import.meta.globEager('./**/*.ts'); | ||
Object.keys(modules).forEach((key) => { | ||
const mod = modules[key].default; | ||
if (!mod) return; | ||
const modList = Array.isArray(mod) ? [...mod] : [mod]; | ||
if (pathNamekeyCheck(key, whiteCatalogue)) { | ||
whiteRouteModulesList.push(...modList); | ||
} else { | ||
routeModulesList.push(...modList); | ||
} | ||
}); | ||
|
||
export default routeModuleList; | ||
// 菜单路由 根据父级重新处理子路由的path路径 | ||
routeModulesList = setUpRoutePath(routeModulesList); | ||
|
||
// 先把菜单路由插入根路径 '/' 防止route 初始化警告查找不到路由 | ||
const whIndex = whiteRouteModulesList.findIndex((i) => i.path === '/'); | ||
whiteRouteModulesList[whIndex]['children'] = routeModulesList; | ||
return { whiteRouteModulesList, routeModulesList }; | ||
} | ||
|
||
const { whiteRouteModulesList, routeModulesList } = configRouteList(); | ||
|
||
export default whiteRouteModulesList; | ||
export const sidebarRouteList = routeModulesList; |
Oops, something went wrong.