Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
9d119821
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
718
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9d119821
编写于
7月 26, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor navigateBack
上级
7bb0cb54
变更
37
展开全部
显示空白变更内容
内联
并排
Showing
37 changed file
with
8337 addition
and
3798 deletion
+8337
-3798
build/rollup.config.app.js
build/rollup.config.app.js
+19
-8
package.json
package.json
+1
-2
packages/uni-app-plus-nvue/dist/index.js
packages/uni-app-plus-nvue/dist/index.js
+7649
-481
packages/uni-app-plus-nvue/dist/index.legacy.js
packages/uni-app-plus-nvue/dist/index.legacy.js
+12
-0
packages/uni-app-plus-nvue/dist/uni.js
packages/uni-app-plus-nvue/dist/uni.js
+0
-2786
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
src/core/helpers/protocol/network/request.js
src/core/helpers/protocol/network/request.js
+95
-54
src/core/service/api/network/request.js
src/core/service/api/network/request.js
+113
-0
src/core/service/bridge.js
src/core/service/bridge.js
+0
-18
src/core/service/platform.js
src/core/service/platform.js
+16
-0
src/core/service/uni.js
src/core/service/uni.js
+0
-0
src/platforms/app-plus-nvue/service/api.js
src/platforms/app-plus-nvue/service/api.js
+3
-2
src/platforms/app-plus-nvue/service/api/route/navigate-back.js
...latforms/app-plus-nvue/service/api/route/navigate-back.js
+71
-22
src/platforms/app-plus-nvue/service/api/route/navigate-to.js
src/platforms/app-plus-nvue/service/api/route/navigate-to.js
+16
-2
src/platforms/app-plus/service/api/device/system.js
src/platforms/app-plus/service/api/device/system.js
+2
-2
src/platforms/app-plus/service/api/index.js
src/platforms/app-plus/service/api/index.js
+2
-1
src/platforms/app-plus/service/api/plugin/event-bus.js
src/platforms/app-plus/service/api/plugin/event-bus.js
+21
-0
src/platforms/app-plus/service/api/ui/tab-bar.js
src/platforms/app-plus/service/api/ui/tab-bar.js
+6
-6
src/platforms/app-plus/service/bridge.js
src/platforms/app-plus/service/bridge.js
+22
-0
src/platforms/app-plus/service/framework/app.js
src/platforms/app-plus/service/framework/app.js
+63
-11
src/platforms/app-plus/service/framework/bridge.js
src/platforms/app-plus/service/framework/bridge.js
+0
-22
src/platforms/app-plus/service/framework/config.js
src/platforms/app-plus/service/framework/config.js
+11
-16
src/platforms/app-plus/service/framework/create-instance-context.js
...rms/app-plus/service/framework/create-instance-context.js
+0
-74
src/platforms/app-plus/service/framework/holder.js
src/platforms/app-plus/service/framework/holder.js
+0
-32
src/platforms/app-plus/service/framework/page.js
src/platforms/app-plus/service/framework/page.js
+10
-8
src/platforms/app-plus/service/framework/tab-bar.js
src/platforms/app-plus/service/framework/tab-bar.js
+0
-6
src/platforms/app-plus/service/framework/webview/index.js
src/platforms/app-plus/service/framework/webview/index.js
+6
-16
src/platforms/app-plus/service/framework/webview/parser/pull-to-refresh-parser.js
...ervice/framework/webview/parser/pull-to-refresh-parser.js
+2
-4
src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js
...us/service/framework/webview/parser/title-nview-parser.js
+2
-0
src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js
.../service/framework/webview/parser/webview-style-parser.js
+5
-9
src/platforms/app-plus/service/index.js
src/platforms/app-plus/service/index.js
+33
-0
src/platforms/app-plus/service/polyfill.js
src/platforms/app-plus/service/polyfill.js
+0
-6
src/platforms/app-plus/service/uni.js
src/platforms/app-plus/service/uni.js
+0
-27
src/platforms/h5/service/api/network/request.js
src/platforms/h5/service/api/network/request.js
+154
-181
src/platforms/h5/service/api/plugin/event-bus.js
src/platforms/h5/service/api/plugin/event-bus.js
+0
-0
src/platforms/h5/service/index.js
src/platforms/h5/service/index.js
+1
-1
src/shared/index.js
src/shared/index.js
+1
-0
未找到文件。
build/rollup.config.app.js
浏览文件 @
9d119821
...
@@ -17,16 +17,27 @@ const external = []
...
@@ -17,16 +17,27 @@ const external = []
if
(
process
.
env
.
UNI_SERVICE
===
'
legacy
'
)
{
if
(
process
.
env
.
UNI_SERVICE
===
'
legacy
'
)
{
input
=
'
src/platforms/app-plus-nvue/services/index.legacy.js
'
input
=
'
src/platforms/app-plus-nvue/services/index.legacy.js
'
output
.
file
=
'
packages/uni-app-plus-nvue/dist/index.legacy.js
'
output
.
file
=
'
packages/uni-app-plus-nvue/dist/index.legacy.js
'
}
else
if
(
process
.
env
.
UNI_SERVICE
===
'
uni
'
)
{
}
else
{
input
=
'
src/platforms/app-plus/service/uni.js
'
input
=
'
src/platforms/app-plus/service/index.js
'
output
.
file
=
'
packages/uni-app-plus-nvue/dist/uni.js
'
output
.
file
=
'
packages/uni-app-plus-nvue/dist/index.js
'
output
.
format
=
'
iife
'
output
.
name
=
'
serviceContext
'
output
.
banner
=
output
.
banner
=
`export function create
UniInstance(weex, plus, __uniConfig, __uniRoutes, __registerPage, UniServiceJSBridge, getApp, getCurrentPages
){
`export function create
ServiceContext(Vue, weex, plus, __uniConfig, __uniRoutes, UniServiceJSBridge
){
var localStorage = plus.storage
var localStorage = plus.storage
var setTimeout = global.setTimeout
var clearTimeout = global.clearTimeout
`
output
.
footer
=
`
var uni = serviceContext.uni
var getApp = serviceContext.getApp
var getCurrentPages = serviceContext.getCurrentPages
var __registerPage = serviceContext.__registerPage
return serviceContext \n}
`
`
output
.
footer
=
'
\n
return uni$1
\n
}
'
}
else
{
external
.
push
(
'
./uni
'
)
}
}
module
.
exports
=
{
module
.
exports
=
{
...
@@ -40,7 +51,7 @@ module.exports = {
...
@@ -40,7 +51,7 @@ module.exports = {
'
uni-core
'
:
path
.
resolve
(
__dirname
,
'
../src/core
'
),
'
uni-core
'
:
path
.
resolve
(
__dirname
,
'
../src/core
'
),
'
uni-platform
'
:
path
.
resolve
(
__dirname
,
'
../src/platforms/
'
+
process
.
env
.
UNI_PLATFORM
),
'
uni-platform
'
:
path
.
resolve
(
__dirname
,
'
../src/platforms/
'
+
process
.
env
.
UNI_PLATFORM
),
'
uni-platforms
'
:
path
.
resolve
(
__dirname
,
'
../src/platforms
'
),
'
uni-platforms
'
:
path
.
resolve
(
__dirname
,
'
../src/platforms
'
),
'
uni-shared
'
:
path
.
resolve
(
__dirname
,
'
../src/shared/
util
.js
'
),
'
uni-shared
'
:
path
.
resolve
(
__dirname
,
'
../src/shared/
index
.js
'
),
'
uni-helpers
'
:
path
.
resolve
(
__dirname
,
'
../src/core/helpers
'
)
'
uni-helpers
'
:
path
.
resolve
(
__dirname
,
'
../src/core/helpers
'
)
}),
}),
replace
({
replace
({
...
...
package.json
浏览文件 @
9d119821
...
@@ -6,8 +6,7 @@
...
@@ -6,8 +6,7 @@
"dev:h5"
:
"npm run lint && cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.js"
,
"dev:h5"
:
"npm run lint && cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.js"
,
"build:h5"
:
"npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.js"
,
"build:h5"
:
"npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.js"
,
"build:app-plus"
:
"cross-env UNI_PLATFORM=app-plus rollup -c build/rollup.config.mp.js"
,
"build:app-plus"
:
"cross-env UNI_PLATFORM=app-plus rollup -c build/rollup.config.mp.js"
,
"build:app:all"
:
"npm run lint && npm run build:app:uni && npm run build:app:nvue && npm run build:app:legacy"
,
"build:app:all"
:
"npm run lint && npm run build:app:nvue && npm run build:app:legacy"
,
"build:app:uni"
:
"UNI_PLATFORM=app-plus-nvue UNI_SERVICE=uni rollup -c build/rollup.config.app.js"
,
"build:app:nvue"
:
"cross-env UNI_PLATFORM=app-plus-nvue rollup -c build/rollup.config.app.js"
,
"build:app:nvue"
:
"cross-env UNI_PLATFORM=app-plus-nvue rollup -c build/rollup.config.app.js"
,
"build:app:legacy"
:
"cross-env UNI_PLATFORM=app-plus-nvue UNI_SERVICE=legacy rollup -c build/rollup.config.app.js"
,
"build:app:legacy"
:
"cross-env UNI_PLATFORM=app-plus-nvue UNI_SERVICE=legacy rollup -c build/rollup.config.app.js"
,
"build:mp-qq"
:
"cross-env UNI_PLATFORM=mp-qq rollup -c build/rollup.config.mp.js"
,
"build:mp-qq"
:
"cross-env UNI_PLATFORM=mp-qq rollup -c build/rollup.config.mp.js"
,
...
...
packages/uni-app-plus-nvue/dist/index.js
浏览文件 @
9d119821
此差异已折叠。
点击以展开。
packages/uni-app-plus-nvue/dist/index.legacy.js
浏览文件 @
9d119821
let
supportsPassive
=
false
;
try
{
const
opts
=
{};
Object
.
defineProperty
(
opts
,
'
passive
'
,
({
get
()
{
/* istanbul ignore next */
supportsPassive
=
true
;
}
}));
// https://github.com/facebook/flow/issues/285
window
.
addEventListener
(
'
test-passive
'
,
null
,
opts
);
}
catch
(
e
)
{}
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
const
hasOwnProperty
=
Object
.
prototype
.
hasOwnProperty
;
function
isFn
(
fn
)
{
function
isFn
(
fn
)
{
...
...
packages/uni-app-plus-nvue/dist/uni.js
已删除
100644 → 0
浏览文件 @
7bb0cb54
此差异已折叠。
点击以展开。
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
9d119821
此差异已折叠。
点击以展开。
src/core/helpers/protocol/network/request.js
浏览文件 @
9d119821
import
{
isPlainObject
}
from
'
uni-shared
'
const
method
=
{
const
method
=
{
OPTIONS
:
'
OPTIONS
'
,
OPTIONS
:
'
OPTIONS
'
,
GET
:
'
GET
'
,
GET
:
'
GET
'
,
...
@@ -15,10 +19,41 @@ const responseType = {
...
@@ -15,10 +19,41 @@ const responseType = {
TEXT
:
'
TEXT
'
,
TEXT
:
'
TEXT
'
,
ARRAYBUFFER
:
'
ARRAYBUFFER
'
ARRAYBUFFER
:
'
ARRAYBUFFER
'
}
}
const
encode
=
encodeURIComponent
function
stringifyQuery
(
url
,
data
)
{
let
str
=
url
.
split
(
'
#
'
)
const
hash
=
str
[
1
]
||
''
str
=
str
[
0
].
split
(
'
?
'
)
let
query
=
str
[
1
]
||
''
url
=
str
[
0
]
const
search
=
query
.
split
(
'
&
'
).
filter
(
item
=>
item
)
query
=
{}
search
.
forEach
(
item
=>
{
item
=
item
.
split
(
'
=
'
)
query
[
item
[
0
]]
=
item
[
1
]
})
for
(
let
key
in
data
)
{
if
(
data
.
hasOwnProperty
(
key
))
{
if
(
isPlainObject
(
data
[
key
]))
{
query
[
encode
(
key
)]
=
encode
(
JSON
.
stringify
(
data
[
key
]))
}
else
{
query
[
encode
(
key
)]
=
encode
(
data
[
key
])
}
}
}
query
=
Object
.
keys
(
query
).
map
(
item
=>
`
${
item
}
=
${
query
[
item
]}
`
).
join
(
'
&
'
)
return
url
+
(
query
?
'
?
'
+
query
:
''
)
+
(
hash
?
'
#
'
+
hash
:
''
)
}
export
const
request
=
{
export
const
request
=
{
url
:
{
method
:
{
type
:
String
,
type
:
String
,
required
:
true
validator
(
value
,
params
)
{
value
=
(
value
||
''
).
toUpperCase
()
params
.
method
=
Object
.
values
(
method
).
indexOf
(
value
)
<
0
?
method
.
GET
:
value
}
},
},
data
:
{
data
:
{
type
:
[
Object
,
String
,
ArrayBuffer
],
type
:
[
Object
,
String
,
ArrayBuffer
],
...
@@ -26,17 +61,23 @@ export const request = {
...
@@ -26,17 +61,23 @@ export const request = {
params
.
data
=
value
||
''
params
.
data
=
value
||
''
}
}
},
},
header
:
{
url
:
{
type
:
Object
,
type
:
String
,
required
:
true
,
validator
(
value
,
params
)
{
validator
(
value
,
params
)
{
params
.
header
=
value
||
{}
if
(
params
.
method
===
method
.
GET
&&
isPlainObject
(
params
.
data
)
&&
Object
.
keys
(
params
.
data
).
length
)
{
// 将 method,data 校验提前,保证 url 校验时,method,data 已被格式化
params
.
url
=
stringifyQuery
(
value
,
params
.
data
)
}
}
}
},
},
method
:
{
header
:
{
type
:
String
,
type
:
Object
,
validator
(
value
,
params
)
{
validator
(
value
,
params
)
{
value
=
(
value
||
''
).
toUpperCase
()
params
.
header
=
value
||
{}
params
.
method
=
Object
.
values
(
method
).
indexOf
(
value
)
<
0
?
method
.
GET
:
value
}
}
},
},
dataType
:
{
dataType
:
{
...
...
src/core/service/api/network/request.js
0 → 100644
浏览文件 @
9d119821
import
{
isPlainObject
}
from
'
uni-shared
'
import
{
invoke
}
from
'
uni-core/service/bridge
'
import
{
onMethod
,
invokeMethod
}
from
'
../../platform
'
const
requestTasks
=
Object
.
create
(
null
)
function
formatResponse
(
res
,
args
)
{
if
(
typeof
res
.
data
===
'
string
'
&&
res
.
data
.
charCodeAt
(
0
)
===
65279
)
{
res
.
data
=
res
.
data
.
substr
(
1
)
}
res
.
statusCode
=
parseInt
(
res
.
statusCode
,
10
)
if
(
isPlainObject
(
res
.
header
))
{
res
.
header
=
Object
.
keys
(
res
.
header
).
reduce
(
function
(
ret
,
key
)
{
const
value
=
res
.
header
[
key
]
if
(
Array
.
isArray
(
value
))
{
ret
[
key
]
=
value
.
join
(
'
,
'
)
}
else
if
(
typeof
value
===
'
string
'
)
{
ret
[
key
]
=
value
}
return
ret
},
{})
}
if
(
args
.
dataType
&&
args
.
dataType
.
toLowerCase
()
===
'
json
'
)
{
try
{
res
.
data
=
JSON
.
parse
(
res
.
data
)
}
catch
(
e
)
{}
}
return
res
}
onMethod
(
'
onRequestTaskStateChange
'
,
function
({
requestTaskId
,
state
,
data
,
statusCode
,
header
,
errMsg
})
{
const
{
args
,
callbackId
}
=
requestTasks
[
requestTaskId
]
if
(
!
callbackId
)
{
return
}
delete
requestTasks
[
requestTaskId
]
switch
(
state
)
{
case
'
success
'
:
invoke
(
callbackId
,
formatResponse
({
data
,
statusCode
,
header
,
errMsg
:
'
request:ok
'
},
args
))
break
case
'
fail
'
:
invoke
(
callbackId
,
{
errMsg
:
'
request:fail
'
+
errMsg
})
break
}
})
class
RequestTask
{
constructor
(
id
)
{
this
.
id
=
id
}
abort
()
{
invokeMethod
(
'
operateRequestTask
'
,
{
requestTaskId
:
this
.
id
,
operationType
:
'
abort
'
})
}
offHeadersReceived
()
{
}
onHeadersReceived
()
{
}
}
export
function
request
(
args
,
callbackId
)
{
const
{
requestTaskId
}
=
invokeMethod
(
'
createRequestTask
'
,
args
)
requestTasks
[
requestTaskId
]
=
{
args
,
callbackId
}
return
new
RequestTask
(
requestTaskId
)
}
src/core/service/bridge.js
浏览文件 @
9d119821
import
api
from
'
uni-platform/service/api
'
export
function
unpack
(
args
)
{
export
function
unpack
(
args
)
{
return
args
return
args
}
}
...
@@ -7,19 +5,3 @@ export function unpack (args) {
...
@@ -7,19 +5,3 @@ export function unpack (args) {
export
function
invoke
(...
args
)
{
export
function
invoke
(...
args
)
{
return
UniServiceJSBridge
.
invokeCallbackHandler
(...
args
)
return
UniServiceJSBridge
.
invokeCallbackHandler
(...
args
)
}
}
/**
* 执行内部平台方法
*/
export
function
invokeMethod
(
name
,
...
args
)
{
return
api
[
name
].
apply
(
null
,
args
)
}
/**
* 监听 service 层内部平台方法回调,与 publish 对应
* @param {Object} name
* @param {Object} callback
*/
export
function
onMethod
(
name
,
callback
)
{
return
UniServiceJSBridge
.
on
(
'
api.
'
+
name
,
callback
)
}
src/core/service/platform.js
0 → 100644
浏览文件 @
9d119821
import
api
from
'
uni-platform/service/api
'
/**
* 执行内部平台方法
*/
export
function
invokeMethod
(
name
,
...
args
)
{
return
api
[
name
].
apply
(
null
,
args
)
}
/**
* 监听 service 层内部平台方法回调,与 publish 对应
* @param {Object} name
* @param {Object} callback
*/
export
function
onMethod
(
name
,
callback
)
{
return
UniServiceJSBridge
.
on
(
'
api.
'
+
name
,
callback
)
}
src/
platforms/h5
/service/uni.js
→
src/
core
/service/uni.js
浏览文件 @
9d119821
文件已移动
src/platforms/app-plus-nvue/service/api.js
浏览文件 @
9d119821
import
*
as
api
from
'
./api/index
'
import
*
as
appApi
from
'
../../app-plus/service/api/index
'
import
*
as
nvueApi
from
'
./api/index
'
export
default
api
export
default
Object
.
assign
(
Object
.
create
(
null
),
appApi
,
nvueApi
)
src/platforms/app-plus-nvue/service/api/route/navigate-back.js
浏览文件 @
9d119821
...
@@ -2,17 +2,13 @@ import {
...
@@ -2,17 +2,13 @@ import {
ANI_DURATION
ANI_DURATION
}
from
'
./util
'
}
from
'
./util
'
import
{
setStatusBarStyle
}
from
'
../../bridge
'
let
firstBackTime
=
0
let
firstBackTime
=
0
export
function
navigateBack
({
function
quit
()
{
delta
,
animationType
,
animationDuration
})
{
const
pages
=
getCurrentPages
()
const
len
=
pages
.
length
-
1
const
page
=
pages
[
len
]
if
(
page
.
$page
.
meta
.
isQuit
)
{
if
(
!
firstBackTime
)
{
if
(
!
firstBackTime
)
{
firstBackTime
=
Date
.
now
()
firstBackTime
=
Date
.
now
()
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
)
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
)
...
@@ -22,15 +18,68 @@ export function navigateBack ({
...
@@ -22,15 +18,68 @@ export function navigateBack ({
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
plus
.
runtime
.
quit
()
plus
.
runtime
.
quit
()
}
}
}
function
backWebview
(
webview
,
callback
)
{
if
(
!
webview
.
__uniapp_webview
)
{
return
callback
()
}
const
children
=
webview
.
children
()
if
(
!
children
||
!
children
.
length
)
{
// 有子 webview
return
callback
()
}
const
childWebview
=
children
[
0
]
childWebview
.
canBack
(({
canBack
})
=>
{
if
(
canBack
)
{
childWebview
.
back
()
// webview 返回
}
else
{
}
else
{
pages
.
splice
(
len
,
1
)
callback
()
}
})
}
function
back
(
delta
,
animationType
,
animationDuration
)
{
const
pages
=
getCurrentPages
()
const
len
=
pages
.
length
const
currentPage
=
pages
[
len
-
1
]
if
(
delta
>
1
)
{
// 中间页隐藏
pages
.
slice
(
len
-
delta
,
len
-
1
).
reverse
().
forEach
(
deltaPage
=>
{
deltaPage
.
$getAppWebview
().
close
(
'
none
'
)
})
}
backWebview
(
currentPage
,
()
=>
{
if
(
animationType
)
{
if
(
animationType
)
{
p
age
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION
)
currentP
age
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION
)
}
else
{
}
else
{
p
age
.
$getAppWebview
().
close
(
'
auto
'
)
currentP
age
.
$getAppWebview
().
close
(
'
auto
'
)
}
}
// 移除所有 page
pages
.
splice
(
len
-
delta
,
len
)
setStatusBarStyle
()
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateBack
'
type
:
'
navigateBack
'
})
})
}
})
}
export
function
navigateBack
({
delta
,
animationType
,
animationDuration
})
{
const
pages
=
getCurrentPages
()
const
len
=
pages
.
length
uni
.
hideToast
()
// 后退时,关闭 toast,loading
pages
[
len
-
1
].
$page
.
meta
.
isQuit
?
quit
()
:
back
(
delta
,
animationType
,
animationDuration
)
}
}
src/platforms/app-plus-nvue/service/api/route/navigate-to.js
浏览文件 @
9d119821
import
{
parseQuery
}
from
'
uni-shared
'
import
{
import
{
showWebview
showWebview
}
from
'
./util
'
}
from
'
./util
'
import
{
setStatusBarStyle
}
from
'
../../bridge
'
export
function
navigateTo
({
export
function
navigateTo
({
url
,
url
,
animationType
,
animationType
,
animationDuration
animationDuration
})
{
})
{
const
path
=
url
.
split
(
'
?
'
)[
0
]
const
urls
=
url
.
split
(
'
?
'
)
const
path
=
urls
[
0
]
const
query
=
parseQuery
(
urls
[
1
]
||
''
)
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateTo
'
,
type
:
'
navigateTo
'
,
...
@@ -16,9 +27,12 @@ export function navigateTo ({
...
@@ -16,9 +27,12 @@ export function navigateTo ({
showWebview
(
showWebview
(
__registerPage
({
__registerPage
({
path
path
,
query
}),
}),
animationType
,
animationType
,
animationDuration
animationDuration
)
)
setStatusBarStyle
()
}
}
src/platforms/app-plus/service/api/device/system.js
浏览文件 @
9d119821
...
@@ -9,7 +9,7 @@ import {
...
@@ -9,7 +9,7 @@ import {
TITLEBAR_HEIGHT
TITLEBAR_HEIGHT
}
from
'
../../constants
'
}
from
'
../../constants
'
import
tab
bar
from
'
../../framework/tab
bar
'
import
tab
Bar
from
'
../../framework/tab-
bar
'
export
function
getSystemInfoSync
()
{
export
function
getSystemInfoSync
()
{
return
callApiSync
(
getSystemInfo
,
Object
.
create
(
null
),
'
getSystemInfo
'
,
'
getSystemInfoSync
'
)
return
callApiSync
(
getSystemInfo
,
Object
.
create
(
null
),
'
getSystemInfo
'
,
'
getSystemInfoSync
'
)
...
@@ -48,7 +48,7 @@ export function getSystemInfo () {
...
@@ -48,7 +48,7 @@ export function getSystemInfo () {
// TODO screenWidth,screenHeight
// TODO screenWidth,screenHeight
windowWidth
:
screenWidth
,
windowWidth
:
screenWidth
,
windowHeight
:
Math
.
min
(
screenHeight
-
(
titleNView
?
(
statusBarHeight
+
TITLEBAR_HEIGHT
)
windowHeight
:
Math
.
min
(
screenHeight
-
(
titleNView
?
(
statusBarHeight
+
TITLEBAR_HEIGHT
)
:
0
)
-
(
isTabBarPage
()
&&
tab
b
ar
.
visible
?
TABBAR_HEIGHT
:
0
),
screenHeight
),
:
0
)
-
(
isTabBarPage
()
&&
tab
B
ar
.
visible
?
TABBAR_HEIGHT
:
0
),
screenHeight
),
statusBarHeight
,
statusBarHeight
,
language
:
plus
.
os
.
language
,
language
:
plus
.
os
.
language
,
system
:
plus
.
os
.
version
,
system
:
plus
.
os
.
version
,
...
...
src/platforms/app-plus/service/api/index.js
浏览文件 @
9d119821
...
@@ -41,6 +41,7 @@ export * from './plugin/oauth'
...
@@ -41,6 +41,7 @@ export * from './plugin/oauth'
export
*
from
'
./plugin/payment
'
export
*
from
'
./plugin/payment
'
export
*
from
'
./plugin/push
'
export
*
from
'
./plugin/push
'
export
*
from
'
./plugin/share
'
export
*
from
'
./plugin/share
'
export
*
from
'
./plugin/event-bus
'
export
*
from
'
./ui/keyboard
'
export
*
from
'
./ui/keyboard
'
export
*
from
'
./ui/navigation-bar
'
export
*
from
'
./ui/navigation-bar
'
...
...
src/platforms/app-plus/service/api/plugin/event-bus.js
0 → 100644
浏览文件 @
9d119821
const
Emitter
=
new
Vue
()
function
apply
(
ctx
,
method
,
args
)
{
return
ctx
[
method
].
apply
(
ctx
,
args
)
}
export
function
$on
()
{
return
apply
(
Emitter
,
'
$on
'
,
[...
arguments
])
}
export
function
$off
()
{
return
apply
(
Emitter
,
'
$off
'
,
[...
arguments
])
}
export
function
$once
()
{
return
apply
(
Emitter
,
'
$once
'
,
[...
arguments
])
}
export
function
$emit
()
{
return
apply
(
Emitter
,
'
$emit
'
,
[...
arguments
])
}
src/platforms/app-plus/service/api/ui/tab-bar.js
浏览文件 @
9d119821
...
@@ -2,14 +2,14 @@ import {
...
@@ -2,14 +2,14 @@ import {
isTabBarPage
isTabBarPage
}
from
'
../util
'
}
from
'
../util
'
import
tab
bar
from
'
../../framework/tab
bar
'
import
tab
Bar
from
'
../../framework/tab-
bar
'
export
function
setTabBarBadge
({
export
function
setTabBarBadge
({
index
,
index
,
text
,
text
,
type
type
})
{
})
{
tab
b
ar
.
setTabBarBadge
(
type
,
index
,
text
)
tab
B
ar
.
setTabBarBadge
(
type
,
index
,
text
)
return
{
return
{
errMsg
:
'
setTabBarBadge:ok
'
errMsg
:
'
setTabBarBadge:ok
'
}
}
...
@@ -26,7 +26,7 @@ export function setTabBarItem ({
...
@@ -26,7 +26,7 @@ export function setTabBarItem ({
errMsg
:
'
setTabBarItem:fail not TabBar page
'
errMsg
:
'
setTabBarItem:fail not TabBar page
'
}
}
}
}
tab
b
ar
.
setTabBarItem
(
index
,
text
,
iconPath
,
selectedIconPath
)
tab
B
ar
.
setTabBarItem
(
index
,
text
,
iconPath
,
selectedIconPath
)
return
{
return
{
errMsg
:
'
setTabBarItem:ok
'
errMsg
:
'
setTabBarItem:ok
'
}
}
...
@@ -43,7 +43,7 @@ export function setTabBarStyle ({
...
@@ -43,7 +43,7 @@ export function setTabBarStyle ({
errMsg
:
'
setTabBarStyle:fail not TabBar page
'
errMsg
:
'
setTabBarStyle:fail not TabBar page
'
}
}
}
}
tab
b
ar
.
setTabBarStyle
({
tab
B
ar
.
setTabBarStyle
({
color
,
color
,
selectedColor
,
selectedColor
,
backgroundColor
,
backgroundColor
,
...
@@ -62,7 +62,7 @@ export function hideTabBar ({
...
@@ -62,7 +62,7 @@ export function hideTabBar ({
errMsg
:
'
hideTabBar:fail not TabBar page
'
errMsg
:
'
hideTabBar:fail not TabBar page
'
}
}
}
}
tab
b
ar
.
hideTabBar
(
animation
)
tab
B
ar
.
hideTabBar
(
animation
)
return
{
return
{
errMsg
:
'
hideTabBar:ok
'
errMsg
:
'
hideTabBar:ok
'
}
}
...
@@ -76,7 +76,7 @@ export function showTabBar ({
...
@@ -76,7 +76,7 @@ export function showTabBar ({
errMsg
:
'
showTabBar:fail not TabBar page
'
errMsg
:
'
showTabBar:fail not TabBar page
'
}
}
}
}
tab
b
ar
.
showTabBar
(
animation
)
tab
B
ar
.
showTabBar
(
animation
)
return
{
return
{
errMsg
:
'
showTabBar:ok
'
errMsg
:
'
showTabBar:ok
'
}
}
...
...
src/platforms/app-plus/service/bridge.js
浏览文件 @
9d119821
...
@@ -14,3 +14,25 @@ export function requireNativePlugin (name) {
...
@@ -14,3 +14,25 @@ export function requireNativePlugin (name) {
export
function
publish
(
name
,
res
)
{
export
function
publish
(
name
,
res
)
{
return
UniServiceJSBridge
.
emit
(
'
api.
'
+
name
,
res
)
return
UniServiceJSBridge
.
emit
(
'
api.
'
+
name
,
res
)
}
}
let
lastStatusBarStyle
export
function
setStatusBarStyle
(
statusBarStyle
)
{
if
(
!
statusBarStyle
)
{
const
pages
=
getCurrentPages
()
if
(
!
pages
.
length
)
{
return
}
statusBarStyle
=
pages
[
pages
.
length
-
1
].
$page
.
meta
.
statusBarStyle
if
(
!
statusBarStyle
||
statusBarStyle
===
lastStatusBarStyle
)
{
return
}
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] setStatusBarStyle`
,
statusBarStyle
)
}
lastStatusBarStyle
=
statusBarStyle
plus
.
navigator
.
setStatusBarStyle
(
statusBarStyle
)
}
src/platforms/app-plus/service/framework/app.js
浏览文件 @
9d119821
...
@@ -2,6 +2,22 @@ import {
...
@@ -2,6 +2,22 @@ import {
callAppHook
callAppHook
}
from
'
uni-core/service/plugins/util
'
}
from
'
uni-core/service/plugins/util
'
import
initOn
from
'
uni-core/service/bridge/on
'
import
{
getCurrentPages
}
from
'
./page
'
import
{
registerPlusMessage
}
from
'
./plus-message
'
import
{
isTabBarPage
}
from
'
../api/util
'
import
tabBar
from
'
./tab-bar
'
let
appCtx
let
appCtx
const
NETWORK_TYPES
=
[
const
NETWORK_TYPES
=
[
...
@@ -18,14 +34,11 @@ export function getApp () {
...
@@ -18,14 +34,11 @@ export function getApp () {
return
appCtx
return
appCtx
}
}
function
initGlobalListeners
({
function
initGlobalListeners
()
{
uni
,
plus
,
UniServiceJSBridge
})
{
const
emit
=
UniServiceJSBridge
.
emit
const
emit
=
UniServiceJSBridge
.
emit
plus
.
key
.
addEventListener
(
'
backbutton
'
,
()
=>
{
plus
.
key
.
addEventListener
(
'
backbutton
'
,
()
=>
{
// TODO uni?
uni
.
navigateBack
({
uni
.
navigateBack
({
from
:
'
backbutton
'
from
:
'
backbutton
'
})
})
...
@@ -48,9 +61,7 @@ function initGlobalListeners ({
...
@@ -48,9 +61,7 @@ function initGlobalListeners ({
})
})
}
}
function
initAppLaunch
(
appVm
,
{
function
initAppLaunch
(
appVm
)
{
__uniConfig
})
{
const
args
=
{
const
args
=
{
path
:
__uniConfig
.
entryPagePath
,
path
:
__uniConfig
.
entryPagePath
,
query
:
{},
query
:
{},
...
@@ -61,14 +72,55 @@ function initAppLaunch (appVm, {
...
@@ -61,14 +72,55 @@ function initAppLaunch (appVm, {
callAppHook
(
appVm
,
'
onShow
'
,
args
)
callAppHook
(
appVm
,
'
onShow
'
,
args
)
}
}
export
function
registerApp
(
appVm
,
instanceContext
)
{
function
initTabBar
()
{
if
(
!
__uniConfig
.
tabBar
||
!
__uniConfig
.
tabBar
.
list
.
length
)
{
return
}
const
currentTab
=
isTabBarPage
(
__uniConfig
.
entryPagePath
)
if
(
currentTab
)
{
// 取当前 tab 索引值
__uniConfig
.
tabBar
.
selected
=
__uniConfig
.
tabBar
.
list
.
indexOf
(
currentTab
)
// 如果真实的首页与 condition 都是 tabbar,无需启用 realEntryPagePath 机制
if
(
__uniConfig
.
realEntryPagePath
&&
isTabBarPage
(
__uniConfig
.
realEntryPagePath
))
{
delete
__uniConfig
.
realEntryPagePath
}
}
__uniConfig
.
__ready__
=
true
const
onLaunchWebviewReady
=
function
onLaunchWebviewReady
()
{
const
tabBarView
=
tabBar
.
init
(
__uniConfig
.
tabBar
,
(
item
)
=>
{
uni
.
switchTab
({
url
:
'
/
'
+
item
.
pagePath
,
openType
:
'
switchTab
'
,
from
:
'
tabbar
'
})
})
tabBarView
&&
plus
.
webview
.
getLaunchWebview
().
append
(
tabBarView
)
}
if
(
plus
.
webview
.
getLaunchWebview
())
{
onLaunchWebviewReady
()
}
else
{
registerPlusMessage
(
'
UniWebviewReady-
'
+
plus
.
runtime
.
appid
,
onLaunchWebviewReady
,
false
)
}
}
export
function
registerApp
(
appVm
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerApp`
)
console
.
log
(
`[uni-app] registerApp`
)
}
}
appCtx
=
appVm
appCtx
=
appVm
initAppLaunch
(
appVm
,
instanceContext
)
initOn
(
UniServiceJSBridge
.
on
,
{
getApp
,
getCurrentPages
})
initAppLaunch
(
appVm
)
initGlobalListeners
()
init
GlobalListeners
(
instanceContext
)
init
TabBar
(
)
}
}
src/platforms/app-plus/service/framework/bridge.js
已删除
100644 → 0
浏览文件 @
7bb0cb54
import
initOn
from
'
uni-core/service/bridge/on
'
let
bridge
export
function
initServiceJSBridge
(
Vue
,
instanceContext
)
{
if
(
bridge
)
{
return
bridge
}
const
Emitter
=
new
Vue
()
bridge
=
{
on
:
Emitter
.
$on
.
bind
(
Emitter
),
off
:
Emitter
.
$off
.
bind
(
Emitter
),
once
:
Emitter
.
$once
.
bind
(
Emitter
),
emit
:
Emitter
.
$emit
.
bind
(
Emitter
)
}
initOn
(
bridge
.
on
,
instanceContext
)
return
bridge
}
src/platforms/app-plus/service/framework/config.js
浏览文件 @
9d119821
export
const
uniConfig
=
Object
.
create
(
null
)
export
const
uniRoutes
=
[]
function
parseRoutes
(
config
)
{
function
parseRoutes
(
config
)
{
uniRoutes
.
length
=
0
__
uniRoutes
.
length
=
0
/* eslint-disable no-mixed-operators */
/* eslint-disable no-mixed-operators */
const
tabBarList
=
(
config
.
tabBar
&&
config
.
tabBar
.
list
||
[]).
map
(
item
=>
item
.
pagePath
)
const
tabBarList
=
(
config
.
tabBar
&&
config
.
tabBar
.
list
||
[]).
map
(
item
=>
item
.
pagePath
)
...
@@ -10,7 +7,7 @@ function parseRoutes (config) {
...
@@ -10,7 +7,7 @@ function parseRoutes (config) {
const
isTabBar
=
tabBarList
.
indexOf
(
pagePath
)
!==
-
1
const
isTabBar
=
tabBarList
.
indexOf
(
pagePath
)
!==
-
1
const
isQuit
=
isTabBar
||
(
config
.
pages
[
0
]
===
pagePath
)
const
isQuit
=
isTabBar
||
(
config
.
pages
[
0
]
===
pagePath
)
const
isNVue
=
!!
config
.
page
[
pagePath
].
nvue
const
isNVue
=
!!
config
.
page
[
pagePath
].
nvue
uniRoutes
.
push
({
__
uniRoutes
.
push
({
path
:
'
/
'
+
pagePath
,
path
:
'
/
'
+
pagePath
,
meta
:
{
meta
:
{
isQuit
,
isQuit
,
...
@@ -22,22 +19,20 @@ function parseRoutes (config) {
...
@@ -22,22 +19,20 @@ function parseRoutes (config) {
})
})
}
}
export
function
registerConfig
(
config
,
{
export
function
registerConfig
(
config
)
{
plus
Object
.
assign
(
__uniConfig
,
config
)
})
{
Object
.
assign
(
uniConfig
,
config
)
uniConfig
.
viewport
=
''
__
uniConfig
.
viewport
=
''
uniConfig
.
defaultFontSize
=
''
__
uniConfig
.
defaultFontSize
=
''
if
(
uniConfig
.
nvueCompiler
===
'
uni-app
'
)
{
if
(
__
uniConfig
.
nvueCompiler
===
'
uni-app
'
)
{
uniConfig
.
viewport
=
plus
.
screen
.
resolutionWidth
__
uniConfig
.
viewport
=
plus
.
screen
.
resolutionWidth
uniConfig
.
defaultFontSize
=
uniConfig
.
viewport
/
20
__uniConfig
.
defaultFontSize
=
__
uniConfig
.
viewport
/
20
}
}
parseRoutes
(
uniConfig
)
parseRoutes
(
__
uniConfig
)
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerConfig`
,
uniConfig
)
console
.
log
(
`[uni-app] registerConfig`
,
__
uniConfig
)
}
}
}
}
src/platforms/app-plus/service/framework/create-instance-context.js
已删除
100644 → 0
浏览文件 @
7bb0cb54
import
{
getApp
,
registerApp
}
from
'
./app
'
import
{
registerPage
,
getCurrentPages
}
from
'
./page
'
import
{
uniConfig
,
uniRoutes
,
registerConfig
}
from
'
./config
'
import
{
createUniInstance
}
from
'
./uni
'
import
{
initServiceJSBridge
}
from
'
./bridge
'
let
uni
export
function
createInstanceContext
(
instanceContext
)
{
const
{
weex
,
Vue
,
WeexPlus
}
=
instanceContext
const
plus
=
new
WeexPlus
(
weex
)
const
UniServiceJSBridge
=
initServiceJSBridge
(
Vue
,
{
plus
,
getApp
,
getCurrentPages
})
function
__registerPage
(
page
)
{
return
registerPage
(
page
,
instanceContext
)
}
if
(
!
uni
)
{
uni
=
createUniInstance
(
weex
,
plus
,
uniConfig
,
uniRoutes
,
__registerPage
,
UniServiceJSBridge
,
getApp
,
getCurrentPages
)
}
return
{
__uniConfig
:
uniConfig
,
__uniRoutes
:
uniRoutes
,
__registerConfig
(
config
)
{
return
registerConfig
(
config
,
instanceContext
)
},
__registerApp
(
appVm
)
{
return
registerApp
(
appVm
,
instanceContext
)
},
__registerPage
,
plus
,
uni
,
getApp
,
getCurrentPages
,
UniServiceJSBridge
}
}
src/platforms/app-plus/service/framework/holder.js
已删除
100644 → 0
浏览文件 @
7bb0cb54
export
function
createHolder
(
webview
,
{
navigationBar
},
{
Vue
})
{
const
navigationBarState
=
Vue
.
observable
(
navigationBar
)
/* eslint-disable no-new */
new
Vue
({
created
()
{
this
.
$watch
(()
=>
navigationBarState
.
titleText
,
(
val
,
oldVal
)
=>
{
webview
.
setStyle
({
titleNView
:
{
titleText
:
val
||
''
}
})
})
this
.
$watch
(()
=>
[
navigationBarState
.
textColor
,
navigationBarState
.
backgroundColor
],
(
val
)
=>
{
webview
.
setStyle
({
titleNView
:
{
titleColor
:
val
[
0
],
backgroundColor
:
val
[
1
]
}
})
})
}
})
return
{
navigationBar
:
navigationBarState
}
}
src/platforms/app-plus/service/framework/page.js
浏览文件 @
9d119821
...
@@ -32,19 +32,20 @@ export function getCurrentPages () {
...
@@ -32,19 +32,20 @@ export function getCurrentPages () {
*/
*/
export
function
registerPage
({
export
function
registerPage
({
path
,
path
,
query
,
webview
webview
}
,
instanceContext
)
{
})
{
const
routeOptions
=
JSON
.
parse
(
JSON
.
stringify
(
instanceContext
.
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
)))
const
routeOptions
=
JSON
.
parse
(
JSON
.
stringify
(
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
)))
if
(
!
webview
)
{
if
(
!
webview
)
{
webview
=
createWebview
(
path
,
instanceContext
,
routeOptions
)
webview
=
createWebview
(
path
,
routeOptions
)
}
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] registerPage`
,
path
,
webview
.
id
)
console
.
log
(
`[uni-app] registerPage`
,
path
,
webview
.
id
)
}
}
initWebview
(
webview
,
instanceContext
,
webview
.
id
===
'
1
'
&&
routeOptions
)
initWebview
(
webview
,
webview
.
id
===
'
1
'
&&
routeOptions
)
const
route
=
path
.
slice
(
1
)
const
route
=
path
.
slice
(
1
)
...
@@ -52,6 +53,7 @@ export function registerPage ({
...
@@ -52,6 +53,7 @@ export function registerPage ({
pages
.
push
({
pages
.
push
({
route
,
route
,
options
:
Object
.
assign
({},
query
||
{}),
$getAppWebview
()
{
$getAppWebview
()
{
return
webview
return
webview
},
},
...
...
src/platforms/app-plus/service/framework/tabbar.js
→
src/platforms/app-plus/service/framework/tab
-
bar.js
浏览文件 @
9d119821
...
@@ -59,18 +59,12 @@ let initView = function () {
...
@@ -59,18 +59,12 @@ let initView = function () {
viewStyles
.
bottom
=
0
viewStyles
.
bottom
=
0
viewStyles
.
height
+=
safeArea
.
bottom
viewStyles
.
height
+=
safeArea
.
bottom
}
}
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`UNIAPP[tabbar]:
${
JSON
.
stringify
(
viewStyles
)}
`
)
}
view
=
new
plus
.
nativeObj
.
View
(
TABBAR_VIEW_ID
,
viewStyles
,
getDraws
())
view
=
new
plus
.
nativeObj
.
View
(
TABBAR_VIEW_ID
,
viewStyles
,
getDraws
())
view
.
interceptTouchEvent
(
true
)
view
.
interceptTouchEvent
(
true
)
view
.
addEventListener
(
'
click
'
,
(
e
)
=>
{
view
.
addEventListener
(
'
click
'
,
(
e
)
=>
{
if
(
!
__uniConfig
.
__ready__
)
{
// 未 ready,不允许点击
if
(
!
__uniConfig
.
__ready__
)
{
// 未 ready,不允许点击
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`UNIAPP[tabbar].prevent`
)
}
return
return
}
}
const
x
=
e
.
clientX
const
x
=
e
.
clientX
...
...
src/platforms/app-plus/service/framework/webview/index.js
浏览文件 @
9d119821
...
@@ -7,10 +7,6 @@ import {
...
@@ -7,10 +7,6 @@ import {
parseWebviewStyle
parseWebviewStyle
}
from
'
./parser/webview-style-parser
'
}
from
'
./parser/webview-style-parser
'
import
{
parseNavigationBar
}
from
'
./parser/navigation-bar-parser
'
let
id
=
2
let
id
=
2
const
WEBVIEW_LISTENERS
=
{
const
WEBVIEW_LISTENERS
=
{
...
@@ -20,45 +16,39 @@ const WEBVIEW_LISTENERS = {
...
@@ -20,45 +16,39 @@ const WEBVIEW_LISTENERS = {
'
titleNViewSearchInputClicked
'
:
'
onNavigationBarSearchInputClicked
'
'
titleNViewSearchInputClicked
'
:
'
onNavigationBarSearchInputClicked
'
}
}
export
function
createWebview
(
path
,
instanceContext
,
routeOptions
)
{
export
function
createWebview
(
path
,
routeOptions
)
{
const
webviewId
=
id
++
const
webviewId
=
id
++
const
webviewStyle
=
parseWebviewStyle
(
const
webviewStyle
=
parseWebviewStyle
(
webviewId
,
webviewId
,
path
,
path
,
routeOptions
,
routeOptions
instanceContext
)
)
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] createWebview`
,
webviewId
,
path
,
webviewStyle
)
console
.
log
(
`[uni-app] createWebview`
,
webviewId
,
path
,
webviewStyle
)
}
}
const
webview
=
instanceContext
.
plus
.
webview
.
create
(
''
,
String
(
webviewId
),
webviewStyle
)
const
webview
=
plus
.
webview
.
create
(
''
,
String
(
webviewId
),
webviewStyle
)
webview
.
$navigationBar
=
parseNavigationBar
(
webviewStyle
)
return
webview
return
webview
}
}
export
function
initWebview
(
webview
,
instanceContext
,
routeOptions
)
{
export
function
initWebview
(
webview
,
routeOptions
)
{
if
(
isPlainObject
(
routeOptions
))
{
if
(
isPlainObject
(
routeOptions
))
{
const
webviewStyle
=
parseWebviewStyle
(
const
webviewStyle
=
parseWebviewStyle
(
parseInt
(
webview
.
id
),
parseInt
(
webview
.
id
),
''
,
''
,
routeOptions
,
routeOptions
instanceContext
)
)
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
`[uni-app] updateWebview`
,
webviewStyle
)
console
.
log
(
`[uni-app] updateWebview`
,
webviewStyle
)
}
}
webview
.
$navigationBar
=
parseNavigationBar
(
webviewStyle
)
webview
.
setStyle
(
webviewStyle
)
webview
.
setStyle
(
webviewStyle
)
}
}
const
{
const
{
on
,
on
,
emit
emit
}
=
instanceContext
.
UniServiceJSBridge
}
=
UniServiceJSBridge
// TODO subNVues
// TODO subNVues
Object
.
keys
(
WEBVIEW_LISTENERS
).
forEach
(
name
=>
{
Object
.
keys
(
WEBVIEW_LISTENERS
).
forEach
(
name
=>
{
...
...
src/platforms/app-plus/service/framework/webview/parser/pull-to-refresh-parser.js
浏览文件 @
9d119821
export
function
parsePullToRefresh
(
routeOptions
,
{
export
function
parsePullToRefresh
(
routeOptions
)
{
plus
})
{
const
windowOptions
=
routeOptions
.
window
const
windowOptions
=
routeOptions
.
window
if
(
windowOptions
.
enablePullDownRefresh
)
{
if
(
windowOptions
.
enablePullDownRefresh
)
{
...
...
src/platforms/app-plus/service/framework/webview/parser/title-nview-parser.js
浏览文件 @
9d119821
...
@@ -24,6 +24,8 @@ export function parseTitleNView (routeOptions) {
...
@@ -24,6 +24,8 @@ export function parseTitleNView (routeOptions) {
titleColor
:
windowOptions
.
navigationBarTextStyle
===
'
black
'
?
'
#000000
'
:
'
#ffffff
'
titleColor
:
windowOptions
.
navigationBarTextStyle
===
'
black
'
?
'
#000000
'
:
'
#ffffff
'
}
}
routeOptions
.
meta
.
statusBarStyle
=
windowOptions
.
navigationBarTextStyle
===
'
black
'
?
'
dark
'
:
'
light
'
if
(
isPlainObject
(
titleNView
))
{
if
(
isPlainObject
(
titleNView
))
{
return
Object
.
assign
(
ret
,
titleNView
)
return
Object
.
assign
(
ret
,
titleNView
)
}
}
...
...
src/platforms/app-plus/service/framework/webview/parser/webview-style-parser.js
浏览文件 @
9d119821
...
@@ -23,22 +23,18 @@ const WEBVIEW_STYLE_BLACKLIST = [
...
@@ -23,22 +23,18 @@ const WEBVIEW_STYLE_BLACKLIST = [
'
pullToRefresh
'
'
pullToRefresh
'
]
]
export
function
parseWebviewStyle
(
id
,
path
,
routeOptions
=
{},
instanceContext
)
{
export
function
parseWebviewStyle
(
id
,
path
,
routeOptions
=
{})
{
const
{
__uniConfig
}
=
instanceContext
const
webviewStyle
=
Object
.
create
(
null
)
const
webviewStyle
=
Object
.
create
(
null
)
// 合并
// 合并
const
windowOptions
=
Object
.
assign
(
routeOptions
.
window
=
Object
.
assign
(
JSON
.
parse
(
JSON
.
stringify
(
__uniConfig
.
window
||
{})),
JSON
.
parse
(
JSON
.
stringify
(
__uniConfig
.
window
||
{})),
routeOptions
.
window
||
{}
routeOptions
.
window
||
{}
)
)
Object
.
keys
(
windowOptions
).
forEach
(
name
=>
{
Object
.
keys
(
routeOptions
.
window
).
forEach
(
name
=>
{
if
(
WEBVIEW_STYLE_BLACKLIST
.
indexOf
(
name
)
===
-
1
)
{
if
(
WEBVIEW_STYLE_BLACKLIST
.
indexOf
(
name
)
===
-
1
)
{
webviewStyle
[
name
]
=
windowOptions
[
name
]
webviewStyle
[
name
]
=
routeOptions
.
window
[
name
]
}
}
})
})
...
@@ -50,7 +46,7 @@ export function parseWebviewStyle (id, path, routeOptions = {}, instanceContext)
...
@@ -50,7 +46,7 @@ export function parseWebviewStyle (id, path, routeOptions = {}, instanceContext)
webviewStyle
.
titleNView
=
titleNView
webviewStyle
.
titleNView
=
titleNView
}
}
const
pullToRefresh
=
parsePullToRefresh
(
routeOptions
,
instanceContext
)
const
pullToRefresh
=
parsePullToRefresh
(
routeOptions
)
if
(
pullToRefresh
)
{
if
(
pullToRefresh
)
{
if
(
pullToRefresh
.
style
===
'
circle
'
)
{
if
(
pullToRefresh
.
style
===
'
circle
'
)
{
webviewStyle
.
bounce
=
'
none
'
webviewStyle
.
bounce
=
'
none
'
...
...
src/platforms/app-plus/service/index.js
0 → 100644
浏览文件 @
9d119821
import
{
getApp
,
registerApp
}
from
'
./framework/app
'
import
{
registerPage
,
getCurrentPages
}
from
'
./framework/page
'
import
{
registerConfig
}
from
'
./framework/config
'
import
{
uni
}
from
'
uni-core/service/uni
'
import
{
invokeCallbackHandler
}
from
'
uni-helpers/api
'
UniServiceJSBridge
.
publishHandler
=
UniServiceJSBridge
.
emit
// TODO
UniServiceJSBridge
.
invokeCallbackHandler
=
invokeCallbackHandler
export
default
{
__registerConfig
:
registerConfig
,
__registerApp
:
registerApp
,
__registerPage
:
registerPage
,
uni
,
getApp
,
getCurrentPages
}
src/platforms/app-plus/service/polyfill.js
已删除
100644 → 0
浏览文件 @
7bb0cb54
import
{
invokeCallbackHandler
}
from
'
uni-helpers/api
'
UniServiceJSBridge
.
publishHandler
=
UniServiceJSBridge
.
emit
UniServiceJSBridge
.
invokeCallbackHandler
=
invokeCallbackHandler
src/platforms/app-plus/service/uni.js
已删除
100644 → 0
浏览文件 @
7bb0cb54
import
'
./polyfill
'
import
apis
from
'
uni-helpers/apis
'
import
{
wrapper
,
wrapperUnimplemented
}
from
'
uni-helpers/api
'
import
{
promisify
}
from
'
uni-helpers/promise
'
import
baseApi
from
'
uni-core/service/api
'
import
platformApi
from
'
uni-platform/service/api
'
const
api
=
Object
.
assign
(
Object
.
create
(
null
),
baseApi
,
platformApi
)
const
uni
=
Object
.
create
(
null
)
apis
.
forEach
(
name
=>
{
if
(
api
[
name
])
{
uni
[
name
]
=
promisify
(
name
,
wrapper
(
name
,
api
[
name
]))
}
else
{
uni
[
name
]
=
wrapperUnimplemented
(
name
)
}
})
src/platforms/h5/service/api/network/request.js
浏览文件 @
9d119821
...
@@ -13,32 +13,7 @@ class RequestTask {
...
@@ -13,32 +13,7 @@ class RequestTask {
}
}
}
}
}
}
/**
* 拼接网址和参数
* @param {string} url 网址
* @param {any} data 参数
* @return {string}
*/
function
setUrl
(
url
,
data
)
{
var
str
=
url
.
split
(
'
#
'
)
var
hash
=
str
[
1
]
||
''
str
=
str
[
0
].
split
(
'
?
'
)
var
query
=
str
[
1
]
||
''
url
=
str
[
0
]
var
search
=
query
.
split
(
'
&
'
).
filter
(
item
=>
item
)
query
=
{}
search
.
forEach
(
item
=>
{
item
=
item
.
split
(
'
=
'
)
query
[
item
[
0
]]
=
item
[
1
]
})
for
(
var
key
in
data
)
{
if
(
data
.
hasOwnProperty
(
key
))
{
query
[
encodeURIComponent
(
key
)]
=
encodeURIComponent
(
data
[
key
])
}
}
query
=
Object
.
keys
(
query
).
map
(
item
=>
`
${
item
}
=
${
query
[
item
]}
`
).
join
(
'
&
'
)
return
url
+
(
query
?
'
?
'
+
query
:
''
)
+
(
hash
?
'
#
'
+
hash
:
''
)
}
/**
/**
* 解析响应头
* 解析响应头
* @param {string} headers
* @param {string} headers
...
@@ -94,9 +69,7 @@ export function request ({
...
@@ -94,9 +69,7 @@ export function request ({
}
}
}
}
}
}
if
(
method
===
'
GET
'
)
{
if
(
method
!==
'
GET
'
)
{
url
=
setUrl
(
url
,
data
)
}
else
{
if
(
!
contentType
)
{
if
(
!
contentType
)
{
/**
/**
* 跨域时部分服务器OPTION响应头Access-Control-Allow-Headers未包含Content-Type会请求失败
* 跨域时部分服务器OPTION响应头Access-Control-Allow-Headers未包含Content-Type会请求失败
...
...
src/platforms/h5/service/api/event-bus.js
→
src/platforms/h5/service/api/
plugin/
event-bus.js
浏览文件 @
9d119821
文件已移动
src/platforms/h5/service/index.js
浏览文件 @
9d119821
...
@@ -3,7 +3,7 @@ import initSubscribe from 'uni-core/service/bridge/subscribe'
...
@@ -3,7 +3,7 @@ import initSubscribe from 'uni-core/service/bridge/subscribe'
import
{
import
{
uni
uni
}
from
'
.
/uni
'
}
from
'
uni-core/service
/uni
'
import
{
import
{
getApp
,
getApp
,
...
...
src/shared/index.js
浏览文件 @
9d119821
export
*
from
'
./env
'
export
*
from
'
./env
'
export
*
from
'
./util
'
export
*
from
'
./util
'
export
*
from
'
./color
'
export
*
from
'
./color
'
export
*
from
'
./query
'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录