mirror of
https://github.com/un-pany/v3-admin-vite.git
synced 2025-04-20 19:09:21 +08:00
style: rename the variable "whether to enable dynamic routing" from "async" to "dynamic"
This commit is contained in:
parent
01249a4f5a
commit
9963b590fd
@ -5,7 +5,7 @@ interface RouteSettings {
|
||||
* 1. 开启后需要后端配合,在查询用户详情接口返回当前用户可以用来判断并加载动态路由的字段(该项目用的是角色 roles 字段)
|
||||
* 2. 假如项目不需要根据不同的用户来显示不同的页面,则应该将 async: false
|
||||
*/
|
||||
async: boolean
|
||||
dynamic: boolean
|
||||
/** 当动态路由功能关闭时:
|
||||
* 1. 应该将所有路由都写到常驻路由里面(表明所有登录的用户能访问的页面都是一样的)
|
||||
* 2. 系统自动给当前登录用户赋值一个没有任何作用的默认角色
|
||||
@ -20,7 +20,7 @@ interface RouteSettings {
|
||||
}
|
||||
|
||||
const routeSettings: RouteSettings = {
|
||||
async: true,
|
||||
dynamic: true,
|
||||
defaultRoles: ["DEFAULT_ROLE"],
|
||||
thirdLevelRouteCache: false
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ router.beforeEach(async (to, _from, next) => {
|
||||
// 注意:角色必须是一个数组! 例如: ["admin"] 或 ["developer", "editor"]
|
||||
const roles = userStore.roles
|
||||
// 生成可访问的 Routes
|
||||
routeSettings.async ? permissionStore.setRoutes(roles) : permissionStore.setAllRoutes()
|
||||
routeSettings.dynamic ? permissionStore.setRoutes(roles) : permissionStore.setAllRoutes()
|
||||
// 将 "有访问权限的动态路由" 添加到 Router 中
|
||||
permissionStore.dynamicRoutes.forEach((route) => router.addRoute(route))
|
||||
// 确保添加路由已完成
|
||||
|
Loading…
x
Reference in New Issue
Block a user