Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一臭打代码的 aka 潘先生です
vue-vben-admin
提交
c6b766d8
V
vue-vben-admin
项目概览
一臭打代码的 aka 潘先生です
/
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,体验更适合开发者的 AI 搜索 >>
提交
c6b766d8
编写于
6月 11, 2021
作者:
无
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(route): dynamically introduce components error
修复后台权限模式下,加载IFrame类型的路由时会丢失component的问题
上级
a222ec85
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
6 deletion
+44
-6
mock/sys/menu.ts
mock/sys/menu.ts
+30
-2
src/router/helper/routeHelper.ts
src/router/helper/routeHelper.ts
+14
-4
未找到文件。
mock/sys/menu.ts
浏览文件 @
c6b766d8
...
...
@@ -168,6 +168,34 @@ const sysRoute = {
],
};
const
linkRoute
=
{
path
:
'
/link
'
,
name
:
'
Link
'
,
component
:
'
LAYOUT
'
,
meta
:
{
icon
:
'
ion:tv-outline
'
,
title
:
'
routes.demo.iframe.frame
'
,
},
children
:
[
{
path
:
'
doc
'
,
name
:
'
Doc
'
,
meta
:
{
title
:
'
routes.demo.iframe.doc
'
,
frameSrc
:
'
https://vvbin.cn/doc-next/
'
,
},
},
{
path
:
'
https://vvbin.cn/doc-next/
'
,
name
:
'
DocExternal
'
,
component
:
'
LAYOUT
'
,
meta
:
{
title
:
'
routes.demo.iframe.docExternal
'
,
},
},
],
};
export
default
[
{
url
:
'
/basic-api/getMenuList
'
,
...
...
@@ -184,10 +212,10 @@ export default [
}
const
id
=
checkUser
.
userId
;
if
(
!
id
||
id
===
'
1
'
)
{
return
resultSuccess
([
dashboardRoute
,
authRoute
,
levelRoute
,
sysRoute
]);
return
resultSuccess
([
dashboardRoute
,
authRoute
,
levelRoute
,
sysRoute
,
linkRoute
]);
}
if
(
id
===
'
2
'
)
{
return
resultSuccess
([
dashboardRoute
,
authRoute
,
levelRoute
]);
return
resultSuccess
([
dashboardRoute
,
authRoute
,
levelRoute
,
linkRoute
]);
}
},
},
...
...
src/router/helper/routeHelper.ts
浏览文件 @
c6b766d8
...
...
@@ -7,8 +7,12 @@ import { warn } from '/@/utils/log';
import
{
createRouter
,
createWebHashHistory
}
from
'
vue-router
'
;
export
type
LayoutMapKey
=
'
LAYOUT
'
;
const
IFRAME
=
()
=>
import
(
'
/@/views/sys/iframe/FrameBlank.vue
'
);
const
LayoutMap
=
new
Map
<
LayoutMapKey
,
()
=>
Promise
<
typeof
import
(
'
*.vue
'
)
>>
();
const
LayoutMap
=
new
Map
<
String
,
()
=>
Promise
<
typeof
import
(
'
*.vue
'
)
>>
();
LayoutMap
.
set
(
'
LAYOUT
'
,
LAYOUT
);
LayoutMap
.
set
(
'
IFRAME
'
,
IFRAME
);
let
dynamicViewsModules
:
Record
<
string
,
()
=>
Promise
<
Recordable
>>
;
...
...
@@ -17,10 +21,18 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
dynamicViewsModules
=
dynamicViewsModules
||
import
.
meta
.
glob
(
'
../../views/**/*.{vue,tsx}
'
);
if
(
!
routes
)
return
;
routes
.
forEach
((
item
)
=>
{
if
(
!
item
.
component
&&
item
.
meta
?.
frameSrc
)
{
item
.
component
=
'
IFRAME
'
;
}
const
{
component
,
name
}
=
item
;
const
{
children
}
=
item
;
if
(
component
)
{
item
.
component
=
dynamicImport
(
dynamicViewsModules
,
component
as
string
);
const
layoutFound
=
LayoutMap
.
get
(
component
);
if
(
layoutFound
)
{
item
.
component
=
layoutFound
;
}
else
{
item
.
component
=
dynamicImport
(
dynamicViewsModules
,
component
as
string
);
}
}
else
if
(
name
)
{
item
.
component
=
getParentLayout
();
}
...
...
@@ -53,8 +65,6 @@ function dynamicImport(
// Turn background objects into routing objects
export
function
transformObjToRoute
<
T
=
AppRouteModule
>
(
routeList
:
AppRouteModule
[]):
T
[]
{
LayoutMap
.
set
(
'
LAYOUT
'
,
LAYOUT
);
routeList
.
forEach
((
route
)
=>
{
if
(
route
.
component
)
{
if
((
route
.
component
as
string
).
toUpperCase
()
===
'
LAYOUT
'
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录