Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ea8af983
authored
Nov 11, 2024
by
Arthur Darkstone
Committed by
GitHub
Nov 11, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
docs: add route config desc (#4857)
1 parent
dc15accd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
11 deletions
apps/web-antd/src/router/routes/index.ts
apps/web-ele/src/router/routes/index.ts
apps/web-naive/src/router/routes/index.ts
docs/src/en/guide/essentials/route.md
docs/src/guide/essentials/route.md
playground/src/router/routes/index.ts
apps/web-antd/src/router/routes/index.ts
View file @
ea8af98
...
...
@@ -17,12 +17,12 @@ const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
/** 不需要权限的菜单列表(会显示在菜单中) */
// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
const
staticRoutes
:
RouteRecordRaw
[]
=
[];
const
externalRoutes
:
RouteRecordRaw
[]
=
[];
/** 路由列表,由基本路由+静态路由组成 */
/** 路由列表,由基本路由、外部路由和404兜底路由组成
* 无需走权限验证(会一直显示在菜单中) */
const
routes
:
RouteRecordRaw
[]
=
[
...
coreRoutes
,
...
externalRoutes
,
...
...
@@ -32,5 +32,6 @@ const routes: RouteRecordRaw[] = [
/** 基本路由列表,这些路由不需要进入权限拦截 */
const
coreRouteNames
=
traverseTreeValues
(
coreRoutes
,
(
route
)
=>
route
.
name
);
/** 有权限校验的路由列表,包含动态路由和静态路由 */
const
accessRoutes
=
[...
dynamicRoutes
,
...
staticRoutes
];
export
{
accessRoutes
,
coreRouteNames
,
routes
};
apps/web-ele/src/router/routes/index.ts
View file @
ea8af98
...
...
@@ -17,12 +17,12 @@ const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
/** 不需要权限的菜单列表(会显示在菜单中) */
// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
const
staticRoutes
:
RouteRecordRaw
[]
=
[];
const
externalRoutes
:
RouteRecordRaw
[]
=
[];
/** 路由列表,由基本路由+静态路由组成 */
/** 路由列表,由基本路由、外部路由和404兜底路由组成
* 无需走权限验证(会一直显示在菜单中) */
const
routes
:
RouteRecordRaw
[]
=
[
...
coreRoutes
,
...
externalRoutes
,
...
...
@@ -32,5 +32,6 @@ const routes: RouteRecordRaw[] = [
/** 基本路由列表,这些路由不需要进入权限拦截 */
const
coreRouteNames
=
traverseTreeValues
(
coreRoutes
,
(
route
)
=>
route
.
name
);
/** 有权限校验的路由列表,包含动态路由和静态路由 */
const
accessRoutes
=
[...
dynamicRoutes
,
...
staticRoutes
];
export
{
accessRoutes
,
coreRouteNames
,
routes
};
apps/web-naive/src/router/routes/index.ts
View file @
ea8af98
...
...
@@ -17,12 +17,12 @@ const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
/** 不需要权限的菜单列表(会显示在菜单中) */
// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
const
staticRoutes
:
RouteRecordRaw
[]
=
[];
const
externalRoutes
:
RouteRecordRaw
[]
=
[];
/** 路由列表,由基本路由+静态路由组成 */
/** 路由列表,由基本路由、外部路由和404兜底路由组成
* 无需走权限验证(会一直显示在菜单中) */
const
routes
:
RouteRecordRaw
[]
=
[
...
coreRoutes
,
...
externalRoutes
,
...
...
@@ -32,5 +32,6 @@ const routes: RouteRecordRaw[] = [
/** 基本路由列表,这些路由不需要进入权限拦截 */
const
coreRouteNames
=
traverseTreeValues
(
coreRoutes
,
(
route
)
=>
route
.
name
);
/** 有权限校验的路由列表,包含动态路由和静态路由 */
const
accessRoutes
=
[...
dynamicRoutes
,
...
staticRoutes
];
export
{
accessRoutes
,
coreRouteNames
,
routes
};
docs/src/en/guide/essentials/route.md
View file @
ea8af98
This diff is collapsed.
Click to expand it.
docs/src/guide/essentials/route.md
View file @
ea8af98
...
...
@@ -8,11 +8,29 @@ outline: deep
## 路由类型
路由分为静态路由和动态路由,静态路由是在项目启动时就已经确定的路由。动态路由一般是在用户登录后,根据用户的权限动态生成的路由。
路由分为核心路由、静态路由和动态路由,核心路由是框架内置的路由,包含了根路由、登录路由、404路由等;静态路由是在项目启动时就已经确定的路由;动态路由一般是在用户登录后,根据用户的权限动态生成的路由。
静态路由和动态路由都会走权限控制,可以通过配置路由的
`meta`
属性中的
`authority`
字段来控制权限,可以参考
[
路由权限控制
](
https://github.com/vbenjs/vue-vben-admin/blob/main/playground/src/router/routes/modules/demos.ts
)
。
### 核心路由
核心路由是框架内置的路由,包含了根路由、登录路由、404路由等,核心路由的配置在应用下
`src/router/routes/core`
目录下
::: tip
核心路由主要用于框架的基础功能,因此不建议将业务相关的路由放在核心路由中,推荐将业务相关的路由放在静态路由或动态路由中。
:::
### 静态路由
如果你的页面项目不需要权限控制,可以直接使用静态路由,静态路由的配置在应用下
`src/router/routes/index`
目录下,打开注释的文件内容:
静态路由的配置在应用下
`src/router/routes/index`
目录下,打开注释的文件内容:
::: tip
权限控制是通过路由的
`meta`
属性中的
`authority`
字段来控制的,如果你的页面项目不需要权限控制,可以不设置
`authority`
字段。
:::
```
ts
// 有需要可以自行打开注释,并创建文件夹
...
...
playground/src/router/routes/index.ts
View file @
ea8af98
...
...
@@ -17,12 +17,12 @@ const dynamicRoutes: RouteRecordRaw[] = mergeRouteModules(dynamicRouteFiles);
/** 外部路由列表,访问这些页面可以不需要Layout,可能用于内嵌在别的系统(不会显示在菜单中) */
// const externalRoutes: RouteRecordRaw[] = mergeRouteModules(externalRouteFiles);
/** 不需要权限的菜单列表(会显示在菜单中) */
// const staticRoutes: RouteRecordRaw[] = mergeRouteModules(staticRouteFiles);
const
staticRoutes
:
RouteRecordRaw
[]
=
[];
const
externalRoutes
:
RouteRecordRaw
[]
=
[];
/** 路由列表,由基本路由+静态路由组成 */
/** 路由列表,由基本路由、外部路由和404兜底路由组成
* 无需走权限验证(会一直显示在菜单中) */
const
routes
:
RouteRecordRaw
[]
=
[
...
coreRoutes
,
...
externalRoutes
,
...
...
@@ -32,6 +32,6 @@ const routes: RouteRecordRaw[] = [
/** 基本路由列表,这些路由不需要进入权限拦截 */
const
coreRouteNames
=
traverseTreeValues
(
coreRoutes
,
(
route
)
=>
route
.
name
);
/** 有权限校验的路由列表,包含动态路由和静态路由 */
const
accessRoutes
=
[...
dynamicRoutes
,
...
staticRoutes
];
export
{
accessRoutes
,
coreRouteNames
,
routes
};
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment