Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
4c658f48
Commit
4c658f48
authored
Nov 01, 2020
by
vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: the routeModule can ignore the layou configuration without writing
parent
b36d9486
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
10 deletions
+26
-10
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
index.ts
src/router/menus/index.ts
+7
-2
types.d.ts
src/router/types.d.ts
+1
-1
menuHelper.ts
src/utils/helper/menuHelper.ts
+6
-2
routeHelper.ts
src/utils/helper/routeHelper.ts
+11
-5
No files found.
CHANGELOG.zh_CN.md
View file @
4c658f48
...
...
@@ -5,6 +5,7 @@
-
Layout 界面布局样式调整
-
优化表格渲染性能
-
表单折叠搜索添图标添加动画
-
routeModule 可以忽略 layou 配置不写。方便配置一级菜单
### 🐛 Bug Fixes
...
...
src/router/menus/index.ts
View file @
4c658f48
...
...
@@ -87,8 +87,13 @@ export async function getFlatChildrenMenus(children: Menu[]) {
function
basicFilter
(
routes
:
RouteRecordNormalized
[])
{
return
(
menu
:
Menu
)
=>
{
const
matchRoute
=
routes
.
find
((
route
)
=>
{
if
(
route
.
meta
&&
route
.
meta
.
carryParam
)
{
return
pathToRegexp
(
route
.
path
).
test
(
menu
.
path
);
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
View file @
4c658f48
...
...
@@ -67,6 +67,6 @@ export interface MenuModule {
}
export
interface
AppRouteModule
{
layout
:
AppRouteRecordRaw
;
layout
?
:
AppRouteRecordRaw
;
routes
:
AppRouteRecordRaw
[];
}
src/utils/helper/menuHelper.ts
View file @
4c658f48
...
...
@@ -49,8 +49,12 @@ export function transformRouteToMenu(routeModList: AppRouteModule[]) {
const
routeList
:
AppRouteRecordRaw
[]
=
[];
cloneRouteModList
.
forEach
((
item
)
=>
{
const
{
layout
,
routes
}
=
item
;
layout
.
children
=
routes
;
routeList
.
push
(
layout
);
if
(
layout
)
{
layout
.
children
=
routes
;
routeList
.
push
(
layout
);
}
else
{
routeList
.
push
(...
routes
);
}
});
return
treeMap
(
routeList
,
{
conversion
:
(
node
:
AppRouteRecordRaw
)
=>
{
...
...
src/utils/helper/routeHelper.ts
View file @
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
[];
ret
.
push
(
layout
);
if
(
layout
)
{
layout
.
children
=
flatList
;
ret
.
push
(
layout
);
}
else
{
ret
.
push
(...
flatList
);
}
}
return
ret
as
RouteRecordRaw
[];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment