Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
2d30a925
U
uni-app
项目概览
anyefeiyu
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2d30a925
编写于
7月 17, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app-plus-nvue): add route
上级
e8cf7689
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
485 addition
and
124 deletion
+485
-124
.editorconfig
.editorconfig
+1
-1
packages/uni-app-plus-nvue/dist/index.js
packages/uni-app-plus-nvue/dist/index.js
+171
-45
packages/uni-app-plus-nvue/dist/uni.js
packages/uni-app-plus-nvue/dist/uni.js
+56
-7
src/core/helpers/protocol/route.js
src/core/helpers/protocol/route.js
+47
-5
src/core/service/api/route.js
src/core/service/api/route.js
+9
-2
src/platforms/app-plus-nvue/service/uni/router.js
src/platforms/app-plus-nvue/service/uni/router.js
+0
-45
src/platforms/app-plus-nvue/service/uni/router/index.js
src/platforms/app-plus-nvue/service/uni/router/index.js
+44
-0
src/platforms/app-plus-nvue/service/uni/router/navigate-back.js
...atforms/app-plus-nvue/service/uni/router/navigate-back.js
+37
-0
src/platforms/app-plus-nvue/service/uni/router/navigate-to.js
...platforms/app-plus-nvue/service/uni/router/navigate-to.js
+31
-0
src/platforms/app-plus-nvue/service/uni/router/re-launch.js
src/platforms/app-plus-nvue/service/uni/router/re-launch.js
+5
-0
src/platforms/app-plus-nvue/service/uni/router/redirect-to.js
...platforms/app-plus-nvue/service/uni/router/redirect-to.js
+5
-0
src/platforms/app-plus-nvue/service/uni/router/switch-tab.js
src/platforms/app-plus-nvue/service/uni/router/switch-tab.js
+5
-0
src/platforms/app-plus-nvue/service/uni/router/util.js
src/platforms/app-plus-nvue/service/uni/router/util.js
+20
-0
src/platforms/app-plus/service/uni/app.js
src/platforms/app-plus/service/uni/app.js
+15
-3
src/platforms/app-plus/service/uni/config.js
src/platforms/app-plus/service/uni/config.js
+8
-2
src/platforms/app-plus/service/uni/create-instance-context.js
...platforms/app-plus/service/uni/create-instance-context.js
+12
-10
src/platforms/app-plus/service/uni/page.js
src/platforms/app-plus/service/uni/page.js
+19
-4
未找到文件。
.editorconfig
浏览文件 @
2d30a925
...
...
@@ -6,7 +6,7 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_size =
4
indent_size =
2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
...
...
packages/uni-app-plus-nvue/dist/index.js
浏览文件 @
2d30a925
import
{
createUniInstance
}
from
'
./uni
'
;
function
getWebviewStyle
()
{
const
ANI_SHOW
=
'
pop-in
'
;
const
ANI_DURATION
=
300
;
let
id
=
0
;
function
getId
()
{
return
id
++
}
function
parseWebviewStyle
(
path
)
{
return
{
titleNView
:
{
autoBackButton
:
true
,
titleText
:
'
titleText
'
},
uniNView
:
{
path
}
}
}
class
Router
{
constructor
(
routes
,
plus
)
{
this
.
routes
=
routes
;
this
.
plus
=
plus
;
this
.
id
=
0
;
this
.
aniShow
=
plus
.
os
.
name
===
'
Android
'
?
'
slide-in-right
'
:
'
pop-in
'
;
this
.
aniClose
=
'
pop-out
'
;
this
.
aniDuration
=
300
;
}
push
({
type
,
path
}
=
{})
{
this
.
plus
.
webview
.
open
(
}
function
initNavigateTo
({
plus
,
__registerPage
})
{
return
function
navigateTo
(
path
,
{
animationType
,
animationDuration
})
{
const
webview
=
plus
.
webview
.
open
(
''
,
String
(
this
.
id
++
),
getWebviewStyle
(
),
this
.
aniShow
,
this
.
aniDuration
,
String
(
getId
()
),
parseWebviewStyle
(
path
),
animationType
||
ANI_SHOW
,
animationDuration
||
ANI_DURATION
,
()
=>
{
console
.
log
(
'
show.callback
'
);
});
__registerPage
({
path
,
webview
});
}
}
function
initRedirectTo
()
{
return
function
redirectTo
(
path
)
{
replace
({
type
,
path
}
=
{})
{
}
}
let
firstBackTime
=
0
;
function
initNavigateBack
({
plus
,
getCurrentPages
})
{
return
function
navigateBack
(
delta
,
{
animationType
,
animationDuration
})
{
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
-
1
;
const
page
=
pages
[
len
];
if
(
page
.
$meta
.
isQuit
)
{
if
(
!
firstBackTime
)
{
firstBackTime
=
Date
.
now
();
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
);
setTimeout
(()
=>
{
firstBackTime
=
null
;
},
2000
);
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
plus
.
runtime
.
quit
();
}
}
else
{
pages
.
splice
(
len
,
1
);
if
(
animationType
)
{
page
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION
);
}
else
{
page
.
$getAppWebview
().
close
(
'
auto
'
);
}
}
}
}
function
initSwitchTab
(
path
)
{
return
function
switchTab
()
{
}
}
function
initReLaunch
()
{
return
function
reLaunch
(
path
)
{
go
(
delta
)
{
}
}
function
initRouter
(
instanceContext
)
{
return
{
navigateTo
:
initNavigateTo
(
instanceContext
),
redirectTo
:
initRedirectTo
(
instanceContext
),
navigateBack
:
initNavigateBack
(
instanceContext
),
switchTab
:
initSwitchTab
(
instanceContext
),
reLaunch
:
initReLaunch
(
instanceContext
)
}
}
class
Router
{
constructor
(
instanceContext
)
{
this
.
router
=
initRouter
(
instanceContext
);
}
push
({
type
,
path
,
animationType
,
animationDuration
}
=
{})
{
this
.
router
[
type
](
path
,
{
animationType
,
animationDuration
});
}
go
(
delta
,
{
animationType
,
animationDuration
}
=
{})
{
delta
=
Math
.
abs
(
parseInt
(
delta
)
||
1
);
this
.
router
.
navigateBack
(
delta
,
{
animationType
,
animationDuration
});
}
}
...
...
@@ -52,15 +143,27 @@ function getApp () {
return
appCtx
}
function
registerApp
(
appVm
,
routes
,
plus
)
{
function
initListeners
({
plus
})
{
plus
.
key
.
addEventListener
(
'
backbutton
'
,
()
=>
{
appCtx
.
$router
.
go
(
-
1
);
});
}
function
registerApp
(
appVm
,
instanceContext
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerApp`
);
}
appCtx
=
appVm
;
appCtx
.
$router
=
new
Router
(
routes
,
plus
);
appCtx
.
$router
=
new
Router
(
instanceContext
);
initListeners
(
instanceContext
);
}
const
page
Vm
s
=
[];
const
pages
=
[];
function
getCurrentPages
()
{
return
page
Vm
s
return
pages
}
/**
* @param {Object} pageVm
...
...
@@ -80,55 +183,78 @@ function getCurrentPages () {
*
*
*/
function
registerPage
(
pageVm
)
{
pageVms
.
push
(
pageVm
);
function
registerPage
({
vm
,
path
,
webview
},
instanceContext
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerPage`
,
path
,
webview
.
id
);
}
pages
.
push
({
route
:
path
.
slice
(
1
),
$getAppWebview
()
{
return
webview
},
$meta
:
instanceContext
.
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
).
meta
,
$vm
:
vm
});
}
const
uniConfig
=
Object
.
create
(
null
);
const
uniRoutes
=
[];
function
parseRoutes
(
config
)
{
uniRoutes
.
length
=
0
;
uniRoutes
.
length
=
0
;
/* eslint-disable no-mixed-operators */
const
tabBarList
=
(
config
.
tabBar
&&
config
.
tabBar
.
list
||
[]).
map
(
item
=>
item
.
pagePath
);
Object
.
keys
(
config
.
page
).
forEach
(
function
(
pagePath
)
{
const
isTabBar
=
tabBarList
.
indexOf
(
pagePath
)
!==
-
1
;
const
isQuit
=
isTabBar
||
(
config
.
pages
[
0
]
===
pagePath
);
uniRoutes
.
push
({
path
:
'
/
'
+
pagePath
,
meta
:
{
isTabBar
:
tabBarList
.
indexOf
(
pagePath
)
!==
-
1
isQuit
,
isTabBar
}
});
});
}
function
registerConfig
(
config
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerConfig`
);
}
Object
.
assign
(
uniConfig
,
config
);
parseRoutes
(
uniConfig
);
}
function
createInstanceContext
({
weex
,
WeexPlus
})
{
function
createInstanceContext
(
instanceContext
)
{
const
{
weex
,
WeexPlus
}
=
instanceContext
;
const
plus
=
new
WeexPlus
(
weex
);
return
{
__uniConfig
:
uniConfig
,
__uniRoutes
:
uniRoutes
,
__registerConfig
(
config
)
{
registerConfig
(
config
);
registerConfig
(
config
,
instanceContext
);
},
__registerApp
(
appVm
)
{
registerApp
(
appVm
,
uniRoutes
,
plus
);
registerApp
(
appVm
,
instanceContext
);
},
__registerPage
(
page
Vm
)
{
registerPage
(
page
Vm
);
__registerPage
(
page
)
{
registerPage
(
page
,
instanceContext
);
},
plus
,
uni
:
createUniInstance
(
weex
,
plus
,
__
uniConfig
,
__
uniRoutes
,
uniConfig
,
uniRoutes
,
getApp
,
getCurrentPages
),
...
...
packages/uni-app-plus-nvue/dist/uni.js
浏览文件 @
2d30a925
...
...
@@ -1136,24 +1136,54 @@ function createValidator (type) {
}
}
function
createProtocol
(
type
)
{
return
{
function
createProtocol
(
type
,
extras
=
{}
)
{
return
Object
.
assign
(
{
url
:
{
type
:
String
,
required
:
true
,
validator
:
createValidator
(
type
)
}
},
extras
)
}
function
createAnimationProtocol
(
animationTypes
)
{
return
{
animationType
:
{
type
:
String
,
validator
(
type
)
{
if
(
type
&&
animationTypes
.
indexOf
(
type
)
===
-
1
)
{
return
'
`
'
+
type
+
'
` is not supported for `animationType` (supported values are: `
'
+
animationTypes
.
join
(
'
`|`
'
)
+
'
`)
'
}
}
},
animationDuration
:
{
type
:
Number
}
}
}
const
redirectTo
=
createProtocol
(
'
redirectTo
'
);
const
reLaunch
=
createProtocol
(
'
reLaunch
'
);
const
navigateTo
=
createProtocol
(
'
navigateTo
'
);
const
navigateTo
=
createProtocol
(
'
navigateTo
'
,
createAnimationProtocol
(
[
'
slide-in-right
'
,
'
slide-in-left
'
,
'
slide-in-top
'
,
'
slide-in-bottom
'
,
'
fade-in
'
,
'
zoom-out
'
,
'
zoom-fade-out
'
,
'
pop-in
'
,
'
none
'
]
));
const
switchTab
=
createProtocol
(
'
switchTab
'
);
const
navigateBack
=
{
const
navigateBack
=
Object
.
assign
(
{
delta
:
{
type
:
Number
,
validator
(
delta
,
params
)
{
...
...
@@ -1161,7 +1191,19 @@ const navigateBack = {
params
.
delta
=
Math
.
min
(
getCurrentPages
().
length
-
1
,
delta
);
}
}
};
},
createAnimationProtocol
(
[
'
slide-out-right
'
,
'
slide-out-left
'
,
'
slide-out-top
'
,
'
slide-out-bottom
'
,
'
fade-out
'
,
'
zoom-in
'
,
'
zoom-fade-in
'
,
'
pop-out
'
,
'
none
'
]
));
var
require_context_module_0_19
=
/*#__PURE__*/
Object
.
freeze
({
redirectTo
:
redirectTo
,
...
...
@@ -1735,6 +1777,8 @@ function hasLifecycleHook (vueOptions = {}, hook) {
function
onAppRoute
(
type
,
{
url
,
delta
,
animationType
,
animationDuration
,
from
=
'
navigateBack
'
,
detail
}
=
{})
{
...
...
@@ -1749,7 +1793,9 @@ function onAppRoute (type, {
case
'
navigateTo
'
:
router
.
push
({
type
,
path
:
url
path
:
url
,
animationType
,
animationDuration
});
break
case
'
navigateBack
'
:
...
...
@@ -1767,7 +1813,10 @@ function onAppRoute (type, {
if
(
delta
>
1
)
{
router
.
_$delta
=
delta
;
}
router
.
go
(
-
delta
);
router
.
go
(
-
delta
,
{
animationType
,
animationDuration
});
}
break
case
'
reLaunch
'
:
...
...
src/core/helpers/protocol/route.js
浏览文件 @
2d30a925
...
...
@@ -75,24 +75,54 @@ function createValidator (type) {
}
}
function
createProtocol
(
type
)
{
return
{
function
createProtocol
(
type
,
extras
=
{}
)
{
return
Object
.
assign
(
{
url
:
{
type
:
String
,
required
:
true
,
validator
:
createValidator
(
type
)
}
},
extras
)
}
function
createAnimationProtocol
(
animationTypes
)
{
return
{
animationType
:
{
type
:
String
,
validator
(
type
)
{
if
(
type
&&
animationTypes
.
indexOf
(
type
)
===
-
1
)
{
return
'
`
'
+
type
+
'
` is not supported for `animationType` (supported values are: `
'
+
animationTypes
.
join
(
'
`|`
'
)
+
'
`)
'
}
}
},
animationDuration
:
{
type
:
Number
}
}
}
export
const
redirectTo
=
createProtocol
(
'
redirectTo
'
)
export
const
reLaunch
=
createProtocol
(
'
reLaunch
'
)
export
const
navigateTo
=
createProtocol
(
'
navigateTo
'
)
export
const
navigateTo
=
createProtocol
(
'
navigateTo
'
,
createAnimationProtocol
(
[
'
slide-in-right
'
,
'
slide-in-left
'
,
'
slide-in-top
'
,
'
slide-in-bottom
'
,
'
fade-in
'
,
'
zoom-out
'
,
'
zoom-fade-out
'
,
'
pop-in
'
,
'
none
'
]
))
export
const
switchTab
=
createProtocol
(
'
switchTab
'
)
export
const
navigateBack
=
{
export
const
navigateBack
=
Object
.
assign
(
{
delta
:
{
type
:
Number
,
validator
(
delta
,
params
)
{
...
...
@@ -100,4 +130,16 @@ export const navigateBack = {
params
.
delta
=
Math
.
min
(
getCurrentPages
().
length
-
1
,
delta
)
}
}
}
},
createAnimationProtocol
(
[
'
slide-out-right
'
,
'
slide-out-left
'
,
'
slide-out-top
'
,
'
slide-out-bottom
'
,
'
fade-out
'
,
'
zoom-in
'
,
'
zoom-fade-in
'
,
'
pop-out
'
,
'
none
'
]
))
src/core/service/api/route.js
浏览文件 @
2d30a925
...
...
@@ -5,6 +5,8 @@ import {
function
onAppRoute
(
type
,
{
url
,
delta
,
animationType
,
animationDuration
,
from
=
'
navigateBack
'
,
detail
}
=
{})
{
...
...
@@ -19,7 +21,9 @@ function onAppRoute (type, {
case
'
navigateTo
'
:
router
.
push
({
type
,
path
:
url
path
:
url
,
animationType
,
animationDuration
})
break
case
'
navigateBack
'
:
...
...
@@ -37,7 +41,10 @@ function onAppRoute (type, {
if
(
delta
>
1
)
{
router
.
_$delta
=
delta
}
router
.
go
(
-
delta
)
router
.
go
(
-
delta
,
{
animationType
,
animationDuration
})
}
break
case
'
reLaunch
'
:
...
...
src/platforms/app-plus-nvue/service/uni/router.js
已删除
100644 → 0
浏览文件 @
e8cf7689
function
getWebviewStyle
()
{
return
{
titleNView
:
{
autoBackButton
:
true
,
titleText
:
'
titleText
'
}
}
}
export
default
class
Router
{
constructor
(
routes
,
plus
)
{
this
.
routes
=
routes
this
.
plus
=
plus
this
.
id
=
0
this
.
aniShow
=
plus
.
os
.
name
===
'
Android
'
?
'
slide-in-right
'
:
'
pop-in
'
this
.
aniClose
=
'
pop-out
'
this
.
aniDuration
=
300
}
push
({
type
,
path
}
=
{})
{
this
.
plus
.
webview
.
open
(
''
,
String
(
this
.
id
++
),
getWebviewStyle
(),
this
.
aniShow
,
this
.
aniDuration
,
()
=>
{
console
.
log
(
'
show.callback
'
)
})
}
replace
({
type
,
path
}
=
{})
{
}
go
(
delta
)
{
}
}
src/platforms/app-plus-nvue/service/uni/router/index.js
0 → 100644
浏览文件 @
2d30a925
import
initNavigateTo
from
'
./navigate-to
'
import
initRedirectTo
from
'
./redirect-to
'
import
initNavigateBack
from
'
./navigate-back
'
import
initSwitchTab
from
'
./switch-tab
'
import
initReLaunch
from
'
./re-launch
'
function
initRouter
(
instanceContext
)
{
return
{
navigateTo
:
initNavigateTo
(
instanceContext
),
redirectTo
:
initRedirectTo
(
instanceContext
),
navigateBack
:
initNavigateBack
(
instanceContext
),
switchTab
:
initSwitchTab
(
instanceContext
),
reLaunch
:
initReLaunch
(
instanceContext
)
}
}
export
default
class
Router
{
constructor
(
instanceContext
)
{
this
.
router
=
initRouter
(
instanceContext
)
}
push
({
type
,
path
,
animationType
,
animationDuration
}
=
{})
{
this
.
router
[
type
](
path
,
{
animationType
,
animationDuration
})
}
go
(
delta
,
{
animationType
,
animationDuration
}
=
{})
{
delta
=
Math
.
abs
(
parseInt
(
delta
)
||
1
)
this
.
router
.
navigateBack
(
delta
,
{
animationType
,
animationDuration
})
}
}
src/platforms/app-plus-nvue/service/uni/router/navigate-back.js
0 → 100644
浏览文件 @
2d30a925
import
{
ANI_DURATION
}
from
'
./util
'
let
firstBackTime
=
0
export
default
function
initNavigateBack
({
plus
,
getCurrentPages
})
{
return
function
navigateBack
(
delta
,
{
animationType
,
animationDuration
})
{
const
pages
=
getCurrentPages
()
const
len
=
pages
.
length
-
1
const
page
=
pages
[
len
]
if
(
page
.
$meta
.
isQuit
)
{
if
(
!
firstBackTime
)
{
firstBackTime
=
Date
.
now
()
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
)
setTimeout
(()
=>
{
firstBackTime
=
null
},
2000
)
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
plus
.
runtime
.
quit
()
}
}
else
{
pages
.
splice
(
len
,
1
)
if
(
animationType
)
{
page
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION
)
}
else
{
page
.
$getAppWebview
().
close
(
'
auto
'
)
}
}
}
}
src/platforms/app-plus-nvue/service/uni/router/navigate-to.js
0 → 100644
浏览文件 @
2d30a925
import
{
getId
,
ANI_SHOW
,
ANI_DURATION
,
parseWebviewStyle
}
from
'
./util
'
export
default
function
initNavigateTo
({
plus
,
__registerPage
})
{
return
function
navigateTo
(
path
,
{
animationType
,
animationDuration
})
{
const
webview
=
plus
.
webview
.
open
(
''
,
String
(
getId
()),
parseWebviewStyle
(
path
),
animationType
||
ANI_SHOW
,
animationDuration
||
ANI_DURATION
,
()
=>
{
console
.
log
(
'
show.callback
'
)
})
__registerPage
({
path
,
webview
})
}
}
src/platforms/app-plus-nvue/service/uni/router/re-launch.js
0 → 100644
浏览文件 @
2d30a925
export
default
function
initReLaunch
()
{
return
function
reLaunch
(
path
)
{
}
}
src/platforms/app-plus-nvue/service/uni/router/redirect-to.js
0 → 100644
浏览文件 @
2d30a925
export
default
function
initRedirectTo
()
{
return
function
redirectTo
(
path
)
{
}
}
src/platforms/app-plus-nvue/service/uni/router/switch-tab.js
0 → 100644
浏览文件 @
2d30a925
export
default
function
initSwitchTab
(
path
)
{
return
function
switchTab
()
{
}
}
src/platforms/app-plus-nvue/service/uni/router/util.js
0 → 100644
浏览文件 @
2d30a925
export
const
ANI_SHOW
=
'
pop-in
'
export
const
ANI_DURATION
=
300
let
id
=
0
export
function
getId
()
{
return
id
++
}
export
function
parseWebviewStyle
(
path
)
{
return
{
titleNView
:
{
autoBackButton
:
true
,
titleText
:
'
titleText
'
},
uniNView
:
{
path
}
}
}
src/platforms/app-plus/service/uni/app.js
浏览文件 @
2d30a925
import
Router
from
'
uni-platform/service/uni/router
'
import
Router
from
'
uni-platform/service/uni/router
/index
'
let
appCtx
...
...
@@ -6,7 +6,19 @@ export function getApp () {
return
appCtx
}
export
function
registerApp
(
appVm
,
routes
,
plus
)
{
function
initListeners
({
plus
})
{
plus
.
key
.
addEventListener
(
'
backbutton
'
,
()
=>
{
appCtx
.
$router
.
go
(
-
1
)
})
}
export
function
registerApp
(
appVm
,
instanceContext
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerApp`
)
}
appCtx
=
appVm
appCtx
.
$router
=
new
Router
(
routes
,
plus
)
appCtx
.
$router
=
new
Router
(
instanceContext
)
initListeners
(
instanceContext
)
}
src/platforms/app-plus/service/uni/config.js
浏览文件 @
2d30a925
...
...
@@ -2,21 +2,27 @@ export const uniConfig = Object.create(null)
export
const
uniRoutes
=
[]
function
parseRoutes
(
config
)
{
uniRoutes
.
length
=
0
uniRoutes
.
length
=
0
/* eslint-disable no-mixed-operators */
const
tabBarList
=
(
config
.
tabBar
&&
config
.
tabBar
.
list
||
[]).
map
(
item
=>
item
.
pagePath
)
Object
.
keys
(
config
.
page
).
forEach
(
function
(
pagePath
)
{
const
isTabBar
=
tabBarList
.
indexOf
(
pagePath
)
!==
-
1
const
isQuit
=
isTabBar
||
(
config
.
pages
[
0
]
===
pagePath
)
uniRoutes
.
push
({
path
:
'
/
'
+
pagePath
,
meta
:
{
isTabBar
:
tabBarList
.
indexOf
(
pagePath
)
!==
-
1
isQuit
,
isTabBar
}
})
})
}
export
function
registerConfig
(
config
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerConfig`
)
}
Object
.
assign
(
uniConfig
,
config
)
parseRoutes
(
uniConfig
)
}
src/platforms/app-plus/service/uni/create-instance-context.js
浏览文件 @
2d30a925
...
...
@@ -18,28 +18,30 @@ import {
createUniInstance
}
from
'
./uni
'
export
function
createInstanceContext
({
weex
,
WeexPlus
})
{
export
function
createInstanceContext
(
instanceContext
)
{
const
{
weex
,
WeexPlus
}
=
instanceContext
const
plus
=
new
WeexPlus
(
weex
)
return
{
__uniConfig
:
uniConfig
,
__uniRoutes
:
uniRoutes
,
__registerConfig
(
config
)
{
registerConfig
(
config
)
registerConfig
(
config
,
instanceContext
)
},
__registerApp
(
appVm
)
{
registerApp
(
appVm
,
uniRoutes
,
plus
)
registerApp
(
appVm
,
instanceContext
)
},
__registerPage
(
page
Vm
)
{
registerPage
(
page
Vm
)
__registerPage
(
page
)
{
registerPage
(
page
,
instanceContext
)
},
plus
,
uni
:
createUniInstance
(
weex
,
plus
,
__
uniConfig
,
__
uniRoutes
,
uniConfig
,
uniRoutes
,
getApp
,
getCurrentPages
),
...
...
src/platforms/app-plus/service/uni/page.js
浏览文件 @
2d30a925
const
page
Vm
s
=
[]
const
pages
=
[]
export
function
getCurrentPages
()
{
return
page
Vm
s
return
pages
}
/**
* @param {Object} pageVm
...
...
@@ -21,6 +21,21 @@ export function getCurrentPages () {
*
*
*/
export
function
registerPage
(
pageVm
)
{
pageVms
.
push
(
pageVm
)
export
function
registerPage
({
vm
,
path
,
webview
},
instanceContext
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerPage`
,
path
,
webview
.
id
)
}
pages
.
push
({
route
:
path
.
slice
(
1
),
$getAppWebview
()
{
return
webview
},
$meta
:
instanceContext
.
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
).
meta
,
$vm
:
vm
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录