Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
app-manage-console
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
ReactNative
app-manage-console
Commits
719770f4
提交
719770f4
authored
6月 26, 2018
作者:
vipcxj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加模块页面跳转的钩子
上级
0b64c728
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
52 行增加
和
5 行删除
+52
-5
router.js
src/router.js
+52
-5
没有找到文件。
src/router.js
浏览文件 @
719770f4
...
...
@@ -75,6 +75,33 @@ const createRoute = async (app, group, basePath) => {
};
};
const
moduleHook
=
(
app
,
uid
,
lastModule
,
currentModule
)
=>
{
// noinspection JSUnresolvedVariable
const
store
=
app
.
_store
;
if
(
store
)
{
if
(
lastModule
&&
lastModule
.
model
&&
(
lastModule
.
model
.
reducerExitHook
||
lastModule
.
model
.
effectExitHook
))
{
store
.
dispatch
({
type
:
`
${
lastModule
.
model
.
namespace
}
/@@exit`
,
data
:
{
from
:
lastModule
,
to
:
currentModule
,
},
});
}
if
(
currentModule
&&
currentModule
.
model
&&
(
currentModule
.
model
.
reducerEnterHook
||
currentModule
.
model
.
effectEnterHook
))
{
store
.
dispatch
({
type
:
`
${
currentModule
.
model
.
namespace
}
/@@enter`
,
data
:
{
from
:
lastModule
,
to
:
currentModule
,
},
});
}
}
if
(
currentModule
)
{
histories
.
pushHistory
(
'module'
,
uid
,
currentModule
);
}
};
const
createRoutes
=
async
(
app
,
modules
,
groups
,
basePath
)
=>
{
const
routes
=
[];
...
...
@@ -95,8 +122,9 @@ const createRoutes = async (app, modules, groups, basePath) => {
fullPath
:
combinePath
(
basePath
,
name
),
name
:
showName
,
};
let
modelBundle
;
if
(
layout
.
route
)
{
const
modelBundle
=
await
import
(
`./models/main/modules/
${
layout
.
route
}
`
);
modelBundle
=
await
import
(
`./models/main/modules/
${
layout
.
route
}
`
);
registerModel
(
app
,
modelBundle
.
default
);
let
routeBundle
=
await
import
(
`./routes/main/modules/
${
layout
.
route
}
`
);
routeBundle
=
routeBundle
.
default
||
routeBundle
;
...
...
@@ -113,19 +141,33 @@ const createRoutes = async (app, modules, groups, basePath) => {
}
else
{
route
.
component
=
Monk
;
}
let
model
;
if
(
modelBundle
)
{
model
=
{};
model
.
namespace
=
modelBundle
.
namespace
;
model
.
reducerEnterHook
=
!!
model
.
reducers
[
'@@enter'
];
model
.
effectEnterHook
=
!!
model
.
effects
[
'@@enter'
];
model
.
reducerExitHook
=
!!
model
.
reducers
[
'@@exit'
];
model
.
effectExitHook
=
!!
model
.
effects
[
'@@exit'
];
}
if
(
route
.
onEnter
)
{
const
onEnter
=
route
.
onEnter
;
route
.
onEnter
=
(
nextState
,
replace
,
cb
)
=>
{
if
(
get
(
nextState
,
'location.pathname'
)
===
route
.
fullPath
)
{
getUser
()
.
then
(
u
=>
u
&&
u
.
id
)
.
then
(
uid
=>
histories
.
pushHistory
(
'module'
,
uid
,
{
.
then
((
uid
)
=>
{
const
lastModule
=
histories
.
getLatest
(
'module'
,
uid
);
const
currentModule
=
{
name
,
showName
,
icon
,
description
,
path
:
route
.
fullPath
,
}))
model
,
};
moduleHook
(
app
,
uid
,
lastModule
,
currentModule
);
})
.
then
(()
=>
new
Promise
((
resolve
,
reject
)
=>
{
onEnter
(
nextState
,
replace
,
(
err
,
res
)
=>
{
if
(
err
)
{
...
...
@@ -146,13 +188,18 @@ const createRoutes = async (app, modules, groups, basePath) => {
if
(
get
(
nextState
,
'location.pathname'
)
===
route
.
fullPath
)
{
getUser
()
.
then
(
u
=>
u
&&
u
.
id
)
.
then
(
uid
=>
histories
.
pushHistory
(
'module'
,
uid
,
{
.
then
((
uid
)
=>
{
const
lastModule
=
histories
.
getLatest
(
'module'
,
uid
);
const
currentModule
=
{
name
,
showName
,
icon
,
description
,
path
:
route
.
fullPath
,
}))
model
,
};
moduleHook
(
app
,
uid
,
lastModule
,
currentModule
);
})
.
then
(()
=>
cb
())
.
catch
(
err
=>
cb
(
err
));
}
else
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论