Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jxf111348
vue-vben-admin
提交
4c658f48
V
vue-vben-admin
项目概览
jxf111348
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-vben-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4c658f48
编写于
11月 01, 2020
作者:
V
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf: the routeModule can ignore the layou configuration without writing
上级
b36d9486
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
10 deletion
+26
-10
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
src/router/menus/index.ts
src/router/menus/index.ts
+7
-2
src/router/types.d.ts
src/router/types.d.ts
+1
-1
src/utils/helper/menuHelper.ts
src/utils/helper/menuHelper.ts
+6
-2
src/utils/helper/routeHelper.ts
src/utils/helper/routeHelper.ts
+11
-5
未找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
4c658f48
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
-
Layout 界面布局样式调整
-
Layout 界面布局样式调整
-
优化表格渲染性能
-
优化表格渲染性能
-
表单折叠搜索添图标添加动画
-
表单折叠搜索添图标添加动画
-
routeModule 可以忽略 layou 配置不写。方便配置一级菜单
### 🐛 Bug Fixes
### 🐛 Bug Fixes
...
...
src/router/menus/index.ts
浏览文件 @
4c658f48
...
@@ -87,8 +87,13 @@ export async function getFlatChildrenMenus(children: Menu[]) {
...
@@ -87,8 +87,13 @@ export async function getFlatChildrenMenus(children: Menu[]) {
function
basicFilter
(
routes
:
RouteRecordNormalized
[])
{
function
basicFilter
(
routes
:
RouteRecordNormalized
[])
{
return
(
menu
:
Menu
)
=>
{
return
(
menu
:
Menu
)
=>
{
const
matchRoute
=
routes
.
find
((
route
)
=>
{
const
matchRoute
=
routes
.
find
((
route
)
=>
{
if
(
route
.
meta
&&
route
.
meta
.
carryParam
)
{
if
(
route
.
meta
)
{
return
pathToRegexp
(
route
.
path
).
test
(
menu
.
path
);
if
(
route
.
meta
.
carryParam
)
{
return
pathToRegexp
(
route
.
path
).
test
(
menu
.
path
);
}
if
(
route
.
meta
.
ignoreAuth
)
{
return
false
;
}
}
}
return
route
.
path
===
menu
.
path
;
return
route
.
path
===
menu
.
path
;
});
});
...
...
src/router/types.d.ts
浏览文件 @
4c658f48
...
@@ -67,6 +67,6 @@ export interface MenuModule {
...
@@ -67,6 +67,6 @@ export interface MenuModule {
}
}
export
interface
AppRouteModule
{
export
interface
AppRouteModule
{
layout
:
AppRouteRecordRaw
;
layout
?
:
AppRouteRecordRaw
;
routes
:
AppRouteRecordRaw
[];
routes
:
AppRouteRecordRaw
[];
}
}
src/utils/helper/menuHelper.ts
浏览文件 @
4c658f48
...
@@ -49,8 +49,12 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) {
...
@@ -49,8 +49,12 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) {
const routeList: AppRouteRecordRaw[] = [];
const routeList: AppRouteRecordRaw[] = [];
cloneRouteModList.forEach((item) => {
cloneRouteModList.forEach((item) => {
const { layout, routes } = item;
const { layout, routes } = item;
layout.children = routes;
if (layout) {
routeList.push(layout);
layout.children = routes;
routeList.push(layout);
} else {
routeList.push(...routes);
}
});
});
return treeMap(routeList, {
return treeMap(routeList, {
conversion: (node: AppRouteRecordRaw) => {
conversion: (node: AppRouteRecordRaw) => {
...
...
src/utils/helper/routeHelper.ts
浏览文件 @
4c658f48
...
@@ -23,18 +23,24 @@ export function genRouteModule(moduleList: AppRouteModule[]) {
...
@@ -23,18 +23,24 @@ export function genRouteModule(moduleList: AppRouteModule[]) {
for
(
const
routeMod
of
moduleList
)
{
for
(
const
routeMod
of
moduleList
)
{
const
routes
=
routeMod
.
routes
as
any
;
const
routes
=
routeMod
.
routes
as
any
;
const
layout
=
routeMod
.
layout
;
const
layout
=
routeMod
.
layout
;
le
t
router
=
createRouter
({
routes
,
history
:
createWebHashHistory
()
});
cons
t
router
=
createRouter
({
routes
,
history
:
createWebHashHistory
()
});
const
flatList
=
toRaw
(
router
.
getRoutes
()).
filter
((
item
)
=>
item
.
children
.
length
===
0
);
const
flatList
=
(
toRaw
(
router
.
getRoutes
()).
filter
(
(
item
)
=>
item
.
children
.
length
===
0
)
as
unknown
)
as
AppRouteRecordRaw
[];
try
{
try
{
(
router
as
any
)
=
null
;
(
router
as
any
)
=
null
;
}
catch
(
error
)
{}
}
catch
(
error
)
{}
flatList
.
forEach
((
item
)
=>
{
flatList
.
forEach
((
item
)
=>
{
item
.
path
=
`
${
layout
.
path
}${
item
.
path
}
`
;
item
.
path
=
`
${
layout
?
layout
.
path
:
''
}${
item
.
path
}
`
;
});
});
layout
.
children
=
(
flatList
as
unknown
)
as
AppRouteRecordRaw
[];
if
(
layout
)
{
ret
.
push
(
layout
);
layout
.
children
=
flatList
;
ret
.
push
(
layout
);
}
else
{
ret
.
push
(...
flatList
);
}
}
}
return
ret
as
RouteRecordRaw
[];
return
ret
as
RouteRecordRaw
[];
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录