Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
4c658f48
提交
4c658f48
authored
11月 01, 2020
作者:
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf: the routeModule can ignore the layou configuration without writing
上级
b36d9486
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
22 行增加
和
6 行删除
+22
-6
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
index.ts
src/router/menus/index.ts
+6
-1
types.d.ts
src/router/types.d.ts
+1
-1
menuHelper.ts
src/utils/helper/menuHelper.ts
+4
-0
routeHelper.ts
src/utils/helper/routeHelper.ts
+10
-4
没有找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
4c658f48
...
...
@@ -5,6 +5,7 @@
-
Layout 界面布局样式调整
-
优化表格渲染性能
-
表单折叠搜索添图标添加动画
-
routeModule 可以忽略 layou 配置不写。方便配置一级菜单
### 🐛 Bug Fixes
...
...
src/router/menus/index.ts
浏览文件 @
4c658f48
...
...
@@ -87,9 +87,14 @@ export async function getFlatChildrenMenus(children: Menu[]) {
function
basicFilter
(
routes
:
RouteRecordNormalized
[])
{
return
(
menu
:
Menu
)
=>
{
const
matchRoute
=
routes
.
find
((
route
)
=>
{
if
(
route
.
meta
&&
route
.
meta
.
carryParam
)
{
if
(
route
.
meta
)
{
if
(
route
.
meta
.
carryParam
)
{
return
pathToRegexp
(
route
.
path
).
test
(
menu
.
path
);
}
if
(
route
.
meta
.
ignoreAuth
)
{
return
false
;
}
}
return
route
.
path
===
menu
.
path
;
});
...
...
src/router/types.d.ts
浏览文件 @
4c658f48
...
...
@@ -67,6 +67,6 @@ export interface MenuModule {
}
export
interface
AppRouteModule
{
layout
:
AppRouteRecordRaw
;
layout
?
:
AppRouteRecordRaw
;
routes
:
AppRouteRecordRaw
[];
}
src/utils/helper/menuHelper.ts
浏览文件 @
4c658f48
...
...
@@ -49,8 +49,12 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) {
const
routeList
:
AppRouteRecordRaw
[]
=
[];
cloneRouteModList
.
forEach
((
item
)
=>
{
const
{
layout
,
routes
}
=
item
;
if
(
layout
)
{
layout
.
children
=
routes
;
routeList
.
push
(
layout
);
}
else
{
routeList
.
push
(...
routes
);
}
});
return
treeMap
(
routeList
,
{
conversion
:
(
node
:
AppRouteRecordRaw
)
=>
{
...
...
src/utils/helper/routeHelper.ts
浏览文件 @
4c658f48
...
...
@@ -23,18 +23,24 @@ export function genRouteModule(moduleList: AppRouteModule[]) {
for
(
const
routeMod
of
moduleList
)
{
const
routes
=
routeMod
.
routes
as
any
;
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
{
(
router
as
any
)
=
null
;
}
catch
(
error
)
{}
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
)
{
layout
.
children
=
flatList
;
ret
.
push
(
layout
);
}
else
{
ret
.
push
(...
flatList
);
}
}
return
ret
as
RouteRecordRaw
[];
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论