Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
e26586eb
U
uni-app
项目概览
genary
/
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,发现更多精彩内容 >>
提交
e26586eb
编写于
8月 01, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'nvue-dev' of github.com:dcloudio/uni-app into nvue-dev
上级
5c22e914
8323c9a1
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
1653 addition
and
940 deletion
+1653
-940
build/manifest.js
build/manifest.js
+2
-1
build/rollup.config.app.js
build/rollup.config.app.js
+5
-3
lib/apis.js
lib/apis.js
+0
-1
lib/modules.json
lib/modules.json
+208
-0
packages/uni-app-plus-nvue/dist/index.js
packages/uni-app-plus-nvue/dist/index.js
+1335
-844
packages/uni-app-plus-nvue/dist/index.legacy.js
packages/uni-app-plus-nvue/dist/index.legacy.js
+7
-11
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-h5/manifest.json
packages/uni-h5/manifest.json
+16
-0
src/core/service/api/media/recorder.js
src/core/service/api/media/recorder.js
+75
-75
src/platforms/app-plus-nvue/service/api/route/switch-tab.js
src/platforms/app-plus-nvue/service/api/route/switch-tab.js
+0
-2
src/platforms/app-plus/service/framework/app.js
src/platforms/app-plus/service/framework/app.js
+3
-1
src/platforms/app-plus/service/framework/plus-message.js
src/platforms/app-plus/service/framework/plus-message.js
+1
-1
未找到文件。
build/manifest.js
浏览文件 @
e26586eb
...
...
@@ -76,7 +76,8 @@ function parseApiManifestDeps (manifest, protocol) {
if
(
manifest
[
dep
[
1
]])
{
dep
[
0
]
=
manifest
[
dep
[
1
]][
0
]
}
else
{
console
.
error
(
`依赖模块[
${
dep
[
1
]}
]不存在`
)
console
.
error
(
`依赖模块[
${
dep
[
1
]}
]不存在,删除
${
name
}
接口\n`
)
delete
manifest
[
name
]
}
})
}
...
...
build/rollup.config.app.js
浏览文件 @
e26586eb
...
...
@@ -23,10 +23,12 @@ if (process.env.UNI_SERVICE === 'legacy') {
output
.
format
=
'
iife
'
output
.
name
=
'
serviceContext
'
output
.
banner
=
`export function createServiceContext(Vue, weex, plus, __uniConfig, __uniRoutes, UniServiceJSBridge){
`export function createServiceContext(Vue, weex, plus, __uniConfig, __uniRoutes, UniServiceJSBridge
,instanceContext
){
var localStorage = plus.storage
var setTimeout = global.setTimeout
var clearTimeout = global.clearTimeout
var setTimeout = instanceContext.setTimeout
var clearTimeout = instanceContext.clearTimeout
var setInterval = instanceContext.setInterval
var clearInterval = instanceContext.clearInterval
`
output
.
footer
=
`
...
...
lib/apis.js
浏览文件 @
e26586eb
...
...
@@ -52,7 +52,6 @@ const media = [
'
getImageInfo
'
,
'
saveImageToPhotosAlbum
'
,
'
compressImage
'
,
'
chooseMessageFile
'
,
'
getRecorderManager
'
,
'
getBackgroundAudioManager
'
,
'
createInnerAudioContext
'
,
...
...
lib/modules.json
0 → 100644
浏览文件 @
e26586eb
[{
"name"
:
"base"
,
"title"
:
"基础"
,
"apiList"
:
{
"uni.getSystemInfo"
:
true
,
"uni.getSystemInfoSync"
:
true
,
"uni.canIUse"
:
true
,
"uni.upx2px"
:
true
,
"uni.navigateTo"
:
true
,
"uni.redirectTo"
:
true
,
"uni.switchTab"
:
true
,
"uni.reLaunch"
:
true
,
"uni.navigateBack"
:
true
}
},
{
"name"
:
"network"
,
"title"
:
"网络"
,
"apiList"
:
{
"uni.request"
:
true
,
"uni.connectSocket"
:
true
,
"uni.sendSocketMessage"
:
true
,
"uni.closeSocket"
:
true
,
"uni.onSocketOpen"
:
true
,
"uni.onSocketError"
:
true
,
"uni.onSocketMessage"
:
true
,
"uni.onSocketClose"
:
true
,
"uni.downloadFile"
:
true
,
"uni.uploadFile"
:
true
}
},
{
"name"
:
"storage"
,
"title"
:
"数据缓存"
,
"apiList"
:
{
"uni.setStorage"
:
true
,
"uni.setStorageSync"
:
true
,
"uni.getStorage"
:
true
,
"uni.getStorageSync"
:
true
,
"uni.removeStorage"
:
true
,
"uni.removeStorageSync"
:
true
,
"uni.clearStorage"
:
true
,
"uni.clearStorageSync"
:
true
,
"uni.getStorageInfo"
:
true
,
"uni.getStorageInfoSync"
:
true
}
},
{
"name"
:
"location"
,
"title"
:
"位置"
,
"apiList"
:
{
"uni.getLocation"
:
true
,
"uni.openLocation"
:
true
,
"uni.chooseLocation"
:
true
}
},
{
"name"
:
"media"
,
"title"
:
"媒体"
,
"apiList"
:
{
"uni.chooseImage"
:
true
,
"uni.previewImage"
:
true
,
"uni.getImageInfo"
:
true
,
"uni.saveImageToPhotosAlbum"
:
true
,
"uni.compressImage"
:
true
,
"uni.getRecorderManager"
:
true
,
"uni.getBackgroundAudioManager"
:
true
,
"uni.createInnerAudioContext"
:
true
,
"uni.chooseVideo"
:
true
,
"uni.saveVideoToPhotosAlbum"
:
true
,
"uni.createVideoContext"
:
true
,
"uni.createCameraContext"
:
true
,
"uni.createLivePlayerContext"
:
true
}
},
{
"name"
:
"device"
,
"title"
:
"设备"
,
"apiList"
:
{
"uni.onMemoryWarning"
:
true
,
"uni.getNetworkType"
:
true
,
"uni.onNetworkStatusChange"
:
true
,
"uni.onAccelerometerChange"
:
true
,
"uni.startAccelerometer"
:
true
,
"uni.stopAccelerometer"
:
true
,
"uni.onCompassChange"
:
true
,
"uni.startCompass"
:
true
,
"uni.stopCompass"
:
true
,
"uni.onGyroscopeChange"
:
true
,
"uni.startGyroscope"
:
true
,
"uni.stopGyroscope"
:
true
,
"uni.makePhoneCall"
:
true
,
"uni.scanCode"
:
true
,
"uni.setClipboardData"
:
true
,
"uni.getClipboardData"
:
true
,
"uni.setScreenBrightness"
:
true
,
"uni.getScreenBrightness"
:
true
,
"uni.setKeepScreenOn"
:
true
,
"uni.onUserCaptureScreen"
:
true
,
"uni.vibrateLong"
:
true
,
"uni.vibrateShort"
:
true
,
"uni.addPhoneContact"
:
true
,
"uni.openBluetoothAdapter"
:
true
,
"uni.startBluetoothDevicesDiscovery"
:
true
,
"uni.onBluetoothDeviceFound"
:
true
,
"uni.stopBluetoothDevicesDiscovery"
:
true
,
"uni.onBluetoothAdapterStateChange"
:
true
,
"uni.getConnectedBluetoothDevices"
:
true
,
"uni.getBluetoothDevices"
:
true
,
"uni.getBluetoothAdapterState"
:
true
,
"uni.closeBluetoothAdapter"
:
true
,
"uni.writeBLECharacteristicValue"
:
true
,
"uni.readBLECharacteristicValue"
:
true
,
"uni.onBLEConnectionStateChange"
:
true
,
"uni.onBLECharacteristicValueChange"
:
true
,
"uni.notifyBLECharacteristicValueChange"
:
true
,
"uni.getBLEDeviceServices"
:
true
,
"uni.getBLEDeviceCharacteristics"
:
true
,
"uni.createBLEConnection"
:
true
,
"uni.closeBLEConnection"
:
true
,
"uni.onBeaconServiceChange"
:
true
,
"uni.onBeaconUpdate"
:
true
,
"uni.getBeacons"
:
true
,
"uni.startBeaconDiscovery"
:
true
,
"uni.stopBeaconDiscovery"
:
true
}
},
{
"name"
:
"ui"
,
"title"
:
"界面"
,
"apiList"
:
{
"uni.showToast"
:
true
,
"uni.hideToast"
:
true
,
"uni.showLoading"
:
true
,
"uni.hideLoading"
:
true
,
"uni.showModal"
:
true
,
"uni.showActionSheet"
:
true
,
"uni.setNavigationBarTitle"
:
true
,
"uni.setNavigationBarColor"
:
true
,
"uni.showNavigationBarLoading"
:
true
,
"uni.hideNavigationBarLoading"
:
true
,
"uni.setTabBarItem"
:
true
,
"uni.setTabBarStyle"
:
true
,
"uni.hideTabBar"
:
true
,
"uni.showTabBar"
:
true
,
"uni.setTabBarBadge"
:
true
,
"uni.removeTabBarBadge"
:
true
,
"uni.showTabBarRedDot"
:
true
,
"uni.hideTabBarRedDot"
:
true
,
"uni.setBackgroundColor"
:
true
,
"uni.setBackgroundTextStyle"
:
true
,
"uni.createAnimation"
:
true
,
"uni.pageScrollTo"
:
true
,
"uni.onWindowResize"
:
true
,
"uni.offWindowResize"
:
true
,
"uni.loadFontFace"
:
true
,
"uni.startPullDownRefresh"
:
true
,
"uni.stopPullDownRefresh"
:
true
,
"uni.createSelectorQuery"
:
true
,
"uni.createIntersectionObserver"
:
true
,
"uni.hideKeyboard"
:
true
}
},
{
"name"
:
"event"
,
"title"
:
"页面通讯"
,
"apiList"
:
{
"uni.$emit"
:
true
,
"uni.$on"
:
true
,
"uni.$once"
:
true
,
"uni.$off"
:
true
}
},
{
"name"
:
"file"
,
"title"
:
"文件"
,
"apiList"
:
{
"uni.saveFile"
:
true
,
"uni.getSavedFileList"
:
true
,
"uni.getSavedFileInfo"
:
true
,
"uni.removeSavedFile"
:
true
,
"uni.getFileInfo"
:
true
,
"uni.openDocument"
:
true
,
"uni.getFileSystemManager"
:
true
}
},
{
"name"
:
"canvas"
,
"title"
:
"绘画"
,
"apiList"
:
{
"uni.createOffscreenCanvas"
:
true
,
"uni.createCanvasContext"
:
true
,
"uni.canvasToTempFilePath"
:
true
,
"uni.canvasPutImageData"
:
true
,
"uni.canvasGetImageData"
:
true
}
},
{
"name"
:
"third"
,
"title"
:
"第三方服务"
,
"apiList"
:
{
"uni.getProvider"
:
true
,
"uni.login"
:
true
,
"uni.checkSession"
:
true
,
"uni.getUserInfo"
:
true
,
"uni.share"
:
true
,
"uni.showShareMenu"
:
true
,
"uni.hideShareMenu"
:
true
,
"uni.requestPayment"
:
true
,
"uni.subscribePush"
:
true
,
"uni.unsubscribePush"
:
true
,
"uni.onPush"
:
true
,
"uni.offPush"
:
true
,
"uni.requireNativePlugin"
:
true
,
"uni.base64ToArrayBuffer"
:
true
,
"uni.arrayBufferToBase64"
:
true
}
}]
packages/uni-app-plus-nvue/dist/index.js
浏览文件 @
e26586eb
export
function
createServiceContext
(
Vue
,
weex
,
plus
,
__uniConfig
,
__uniRoutes
,
UniServiceJSBridge
){
export
function
createServiceContext
(
Vue
,
weex
,
plus
,
__uniConfig
,
__uniRoutes
,
UniServiceJSBridge
,
instanceContext
){
var
localStorage
=
plus
.
storage
var
setTimeout
=
global
.
setTimeout
var
clearTimeout
=
global
.
clearTimeout
var
setTimeout
=
instanceContext
.
setTimeout
var
clearTimeout
=
instanceContext
.
clearTimeout
var
setInterval
=
instanceContext
.
setInterval
var
clearInterval
=
instanceContext
.
clearInterval
var
serviceContext
=
(
function
()
{
'
use strict
'
;
...
...
@@ -24,25 +26,49 @@ var serviceContext = (function () {
return
callHook
(
vm
,
hook
,
params
)
}
function
callApiSync
(
api
,
args
,
name
,
alias
)
{
const
ret
=
api
(
args
);
if
(
ret
&&
ret
.
errMsg
)
{
ret
.
errMsg
=
ret
.
errMsg
.
replace
(
name
,
alias
);
function
pack
(
args
)
{
return
args
}
return
ret
function
unpack
(
args
)
{
return
args
}
function
getLastWebview
()
{
try
{
function
invoke
(...
args
)
{
return
UniServiceJSBridge
.
invokeCallbackHandler
(...
args
)
}
function
requireNativePlugin
(
name
)
{
return
uni
.
requireNativePlugin
(
name
)
}
/**
* 触发 service 层,与 onMethod 对应
*/
function
publish
(
name
,
res
)
{
return
UniServiceJSBridge
.
emit
(
'
api.
'
+
name
,
res
)
}
let
lastStatusBarStyle
;
function
setStatusBarStyle
(
statusBarStyle
)
{
if
(
!
statusBarStyle
)
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
return
pages
[
pages
.
length
-
1
].
$getAppWebview
()
if
(
!
pages
.
length
)
{
return
}
}
catch
(
e
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
getCurrentPages is not ready
'
);
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
);
}
function
isTabBarPage
(
path
=
''
)
{
...
...
@@ -70,6 +96,27 @@ var serviceContext = (function () {
return
false
}
function
callApiSync
(
api
,
args
,
name
,
alias
)
{
const
ret
=
api
(
args
);
if
(
ret
&&
ret
.
errMsg
)
{
ret
.
errMsg
=
ret
.
errMsg
.
replace
(
name
,
alias
);
}
return
ret
}
function
getLastWebview
()
{
try
{
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
return
pages
[
pages
.
length
-
1
].
$getAppWebview
()
}
}
catch
(
e
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
console
.
log
(
'
getCurrentPages is not ready
'
);
}
}
}
const
getRealRoute
=
(
e
,
t
)
=>
{
if
(
t
.
indexOf
(
'
./
'
)
===
0
)
return
getRealRoute
(
e
,
t
.
substr
(
2
))
let
n
;
...
...
@@ -674,54 +721,13 @@ var serviceContext = (function () {
return
webview
}
function
unpack
(
args
)
{
return
args
}
function
invoke
(...
args
)
{
return
UniServiceJSBridge
.
invokeCallbackHandler
(...
args
)
}
function
requireNativePlugin
(
name
)
{
return
uni
.
requireNativePlugin
(
name
)
}
/**
* 触发 service 层,与 onMethod 对应
*/
function
publish
(
name
,
res
)
{
return
UniServiceJSBridge
.
emit
(
'
api.
'
+
name
,
res
)
}
let
lastStatusBarStyle
;
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
);
}
const
callbacks
=
{};
/**
* 注册 view 层通知 service 层事件处理
*/
function
registerPlusMessage
(
type
,
callback
,
keepAlive
=
true
)
{
if
(
callbacks
[
type
])
{
throw
new
Error
(
`
${
type
}
已注册:`
+
(
callbacks
[
type
].
toString
()))
return
console
.
warn
(
`
${
type
}
已注册:`
+
(
callbacks
[
type
].
toString
()))
}
callback
.
keepAlive
=
!!
keepAlive
;
callbacks
[
type
]
=
callback
;
...
...
@@ -1316,6 +1322,8 @@ var serviceContext = (function () {
appCtx
=
appVm
;
appCtx
.
globalData
=
appVm
.
$options
.
globalData
||
{};
initOn
(
UniServiceJSBridge
.
on
,
{
getApp
,
getCurrentPages
:
getCurrentPages$1
...
...
@@ -1421,7 +1429,6 @@ var serviceContext = (function () {
'
getImageInfo
'
,
'
saveImageToPhotosAlbum
'
,
'
compressImage
'
,
'
chooseMessageFile
'
,
'
getRecorderManager
'
,
'
getBackgroundAudioManager
'
,
'
createInnerAudioContext
'
,
...
...
@@ -3716,28 +3723,6 @@ var serviceContext = (function () {
upx2px
:
upx2px$1
});
const
Emitter
=
new
Vue
();
function
apply
(
ctx
,
method
,
args
)
{
return
ctx
[
method
].
apply
(
ctx
,
args
)
}
function
$on$1
()
{
return
apply
(
Emitter
,
'
$on
'
,
[...
arguments
])
}
function
$off$1
()
{
return
apply
(
Emitter
,
'
$off
'
,
[...
arguments
])
}
function
$once$1
()
{
return
apply
(
Emitter
,
'
$once
'
,
[...
arguments
])
}
function
$emit$1
()
{
return
apply
(
Emitter
,
'
$emit
'
,
[...
arguments
])
}
let
audios
=
{};
const
evts
=
[
'
play
'
,
'
canplay
'
,
'
ended
'
,
'
stop
'
,
'
waiting
'
,
'
seeking
'
,
'
seeked
'
,
'
pause
'
];
...
...
@@ -4324,7 +4309,7 @@ var serviceContext = (function () {
/**
* 执行蓝牙相关方法
*/
function
bluetoothExec
(
method
,
callbackId
,
data
=
{}
,
beforeSuccess
)
{
function
bluetoothExec
(
method
,
callbackId
,
data
=
{})
{
var
deviceId
=
data
.
deviceId
;
if
(
deviceId
)
{
data
.
deviceId
=
deviceId
.
toUpperCase
();
...
...
@@ -4336,10 +4321,7 @@ var serviceContext = (function () {
plus
.
bluetooth
[
method
.
replace
(
'
Changed
'
,
'
Change
'
)](
Object
.
assign
(
data
,
{
success
(
data
)
{
if
(
typeof
beforeSuccess
===
'
function
'
)
{
beforeSuccess
(
data
);
}
invoke
(
callbackId
,
Object
.
assign
({},
data
,
{
invoke
(
callbackId
,
Object
.
assign
({},
pack
(
data
),
{
errMsg
:
`
${
method
}
:ok`
,
code
:
undefined
,
message
:
undefined
...
...
@@ -4356,12 +4338,9 @@ var serviceContext = (function () {
/**
* 监听蓝牙相关事件
*/
function
bluetoothOn
(
method
,
beforeSuccess
)
{
function
bluetoothOn
(
method
)
{
plus
.
bluetooth
[
method
.
replace
(
'
Changed
'
,
'
Change
'
)](
function
(
data
)
{
if
(
typeof
beforeSuccess
===
'
function
'
)
{
beforeSuccess
(
data
);
}
publish
(
method
,
Object
.
assign
({},
data
,
{
publish
(
method
,
Object
.
assign
({},
pack
(
data
),
{
code
:
undefined
,
message
:
undefined
}));
...
...
@@ -4369,16 +4348,6 @@ var serviceContext = (function () {
return
true
}
function
checkDevices
(
data
)
{
data
.
devices
=
data
.
devices
.
map
(
device
=>
{
var
advertisData
=
device
.
advertisData
;
if
(
advertisData
&&
typeof
advertisData
!==
'
string
'
)
{
device
.
advertisData
=
wx
.
arrayBufferToBase64
(
advertisData
);
}
return
device
});
}
var
onBluetoothAdapterStateChange
;
var
onBluetoothDeviceFound
;
var
onBLEConnectionStateChange
;
...
...
@@ -4399,7 +4368,7 @@ var serviceContext = (function () {
}
function
startBluetoothDevicesDiscovery
(
data
,
callbackId
)
{
onBluetoothDeviceFound
=
onBluetoothDeviceFound
||
bluetoothOn
(
'
onBluetoothDeviceFound
'
,
checkDevices
);
onBluetoothDeviceFound
=
onBluetoothDeviceFound
||
bluetoothOn
(
'
onBluetoothDeviceFound
'
);
bluetoothExec
(
'
startBluetoothDevicesDiscovery
'
,
callbackId
,
data
);
}
...
...
@@ -4408,7 +4377,7 @@ var serviceContext = (function () {
}
function
getBluetoothDevices
(
data
,
callbackId
)
{
bluetoothExec
(
'
getBluetoothDevices
'
,
callbackId
,
{}
,
checkDevices
);
bluetoothExec
(
'
getBluetoothDevices
'
,
callbackId
,
{});
}
function
getConnectedBluetoothDevices
(
data
,
callbackId
)
{
...
...
@@ -4434,18 +4403,12 @@ var serviceContext = (function () {
}
function
notifyBLECharacteristicValueChange
(
data
,
callbackId
)
{
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
,
data
=>
{
data
.
value
=
wx
.
arrayBufferToBase64
(
data
.
value
);
});
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
);
bluetoothExec
(
'
notifyBLECharacteristicValueChange
'
,
callbackId
,
data
);
}
function
notifyBLECharacteristicValueChanged
(
data
,
callbackId
)
{
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
,
data
=>
{
data
.
value
=
wx
.
arrayBufferToBase64
(
data
.
value
);
});
onBLECharacteristicValueChange
=
onBLECharacteristicValueChange
||
bluetoothOn
(
'
onBLECharacteristicValueChange
'
);
bluetoothExec
(
'
notifyBLECharacteristicValueChanged
'
,
callbackId
,
data
);
}
...
...
@@ -4454,8 +4417,7 @@ var serviceContext = (function () {
}
function
writeBLECharacteristicValue
(
data
,
callbackId
)
{
data
.
value
=
wx
.
base64ToArrayBuffer
(
data
.
value
);
bluetoothExec
(
'
writeBLECharacteristicValue
'
,
callbackId
,
data
);
bluetoothExec
(
'
writeBLECharacteristicValue
'
,
callbackId
,
unpack
(
data
));
}
function
getScreenBrightness
()
{
...
...
@@ -7021,15 +6983,11 @@ var serviceContext = (function () {
startPullDownRefresh
:
startPullDownRefresh
,
stopPullDownRefresh
:
stopPullDownRefresh
,
chooseImage
:
chooseImage$1
,
$on
:
$on$1
,
$off
:
$off$1
,
$once
:
$once$1
,
$emit
:
$emit$1
,
getMusicPlayerState
:
getMusicPlayerState
,
operateMusicPlayer
:
operateMusicPlayer
,
setBackgroundAudioState
:
setBackgroundAudioState
,
operateBackgroundAudio
:
operateBackgroundAudio
,
getBackgroundAudioState
:
getBackgroundAudioState
,
createAudioInstance
:
createAudioInstance
,
destroyAudioInstance
:
destroyAudioInstance
,
setAudioState
:
setAudioState
,
getAudioState
:
getAudioState
,
operateAudio
:
operateAudio
,
enableAccelerometer
:
enableAccelerometer
,
addPhoneContact
:
addPhoneContact
,
openBluetoothAdapter
:
openBluetoothAdapter
,
...
...
@@ -7081,11 +7039,11 @@ var serviceContext = (function () {
playVoice
:
playVoice
,
pauseVoice
:
pauseVoice
,
stopVoice
:
stopVoice
,
createAudioInstance
:
createAudioInstanc
e
,
destroyAudioInstance
:
destroyAudioInstance
,
set
AudioState
:
set
AudioState
,
getAudioState
:
getAudioState
,
operateAudio
:
operateAudio
,
getMusicPlayerState
:
getMusicPlayerStat
e
,
operateMusicPlayer
:
operateMusicPlayer
,
set
BackgroundAudioState
:
setBackground
AudioState
,
operateBackgroundAudio
:
operateBackgroundAudio
,
getBackgroundAudioState
:
getBackgroundAudioState
,
chooseVideo
:
chooseVideo$1
,
compressImage
:
compressImage
,
getImageInfo
:
getImageInfo$1
,
...
...
@@ -7131,727 +7089,703 @@ var serviceContext = (function () {
showTabBar
:
showTabBar$2
});
const
SUCCESS
=
'
success
'
;
const
FAIL
=
'
fail
'
;
const
COMPLETE
=
'
complete
'
;
const
CALLBACKS
=
[
SUCCESS
,
FAIL
,
COMPLETE
];
const
Emitter
=
new
Vue
();
/**
* 调用无参数,或仅一个参数且为 callback 的 API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function
invokeVmMethodWithoutArgs
(
vm
,
method
,
args
,
extras
)
{
if
(
!
vm
)
{
return
function
apply
(
ctx
,
method
,
args
)
{
return
ctx
[
method
].
apply
(
ctx
,
args
)
}
if
(
typeof
args
===
'
undefined
'
)
{
return
vm
[
method
]()
function
$on$1
()
{
return
apply
(
Emitter
,
'
$on
'
,
[...
arguments
])
}
const
[,
callbacks
]
=
normalizeArgs
(
args
,
extras
);
if
(
!
Object
.
keys
(
callbacks
).
length
)
{
return
vm
[
method
](
)
function
$off$1
(
)
{
return
apply
(
Emitter
,
'
$off
'
,
[...
arguments
]
)
}
return
vm
[
method
](
normalizeCallback
(
method
,
callbacks
))
function
$once$1
()
{
return
apply
(
Emitter
,
'
$once
'
,
[...
arguments
])
}
function
$emit$1
()
{
return
apply
(
Emitter
,
'
$emit
'
,
[...
arguments
])
}
var
eventApis
=
/*#__PURE__*/
Object
.
freeze
({
$on
:
$on$1
,
$off
:
$off$1
,
$once
:
$once$1
,
$emit
:
$emit$1
});
var
api
=
Object
.
assign
(
Object
.
create
(
null
),
appApi
,
eventApis
);
/**
* 调用两个参数(第一个入参为普通参数,第二个入参为 callback) API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
* 执行内部平台方法
*/
function
invokeVmMethod
(
vm
,
method
,
args
,
extras
)
{
if
(
!
vm
)
{
return
}
const
[
pureArgs
,
callbacks
]
=
normalizeArgs
(
args
,
extras
);
if
(
!
Object
.
keys
(
callbacks
).
length
)
{
return
vm
[
method
](
pureArgs
)
function
invokeMethod
(
name
,
...
args
)
{
return
api
[
name
].
apply
(
null
,
args
)
}
return
vm
[
method
](
pureArgs
,
normalizeCallback
(
method
,
callbacks
))
/**
* 监听 service 层内部平台方法回调,与 publish 对应
* @param {Object} name
* @param {Object} callback
*/
function
onMethod
(
name
,
callback
)
{
return
UniServiceJSBridge
.
on
(
'
api.
'
+
name
,
callback
)
}
function
findElmById
(
id
,
vm
)
{
return
findElmByVNode
(
id
,
vm
.
_vnode
)
}
const
callbacks$1
=
[];
function
findElmByVNode
(
id
,
vnode
)
{
if
(
!
id
||
!
vnode
)
{
return
onMethod
(
'
onAccelerometerChange
'
,
function
(
res
)
{
callbacks$1
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
res
);
});
});
let
isEnable
=
false
;
/**
* 监听加速度
* @param {*} callbackId
*/
function
onAccelerometerChange
(
callbackId
)
{
// TODO 当没有 start 时,添加 on 需要主动 start?
callbacks$1
.
push
(
callbackId
);
if
(
!
isEnable
)
{
startAccelerometer
();
}
if
(
vnode
.
data
&&
vnode
.
data
.
attrs
&&
vnode
.
data
.
attrs
.
id
===
id
)
{
return
vnode
.
elm
}
const
children
=
vnode
.
children
;
if
(
!
children
)
{
function
startAccelerometer
({
interval
// TODO
}
=
{})
{
if
(
isEnable
)
{
return
}
for
(
let
i
=
0
,
len
=
children
.
length
;
i
<
len
;
i
++
)
{
const
elm
=
findElmByVNode
(
id
,
children
[
i
]);
if
(
elm
)
{
return
elm
}
}
isEnable
=
true
;
return
invokeMethod
(
'
enableAccelerometer
'
,
{
enable
:
true
})
}
function
normalizeArgs
(
args
=
{},
extras
)
{
const
callbacks
=
Object
.
create
(
null
);
const
iterator
=
function
iterator
(
name
)
{
const
callback
=
args
[
name
];
if
(
isFn
(
callback
))
{
callbacks
[
name
]
=
callback
;
delete
args
[
name
];
function
stopAccelerometer
()
{
isEnable
=
false
;
return
invokeMethod
(
'
enableAccelerometer
'
,
{
enable
:
false
})
}
};
CALLBACKS
.
forEach
(
iterator
);
extras
&&
extras
.
forEach
(
iterator
);
var
require_context_module_1_4
=
/*#__PURE__*/
Object
.
freeze
({
onAccelerometerChange
:
onAccelerometerChange
,
startAccelerometer
:
startAccelerometer
,
stopAccelerometer
:
stopAccelerometer
});
return
[
args
,
callbacks
]
function
on
(
method
)
{
const
callbacks
=
[];
onMethod
(
method
,
data
=>
{
callbacks
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
data
);
});
});
return
function
(
callbackId
)
{
callbacks
.
push
(
callbackId
);
}
}
function
normalizeCallback
(
method
,
callbacks
)
{
return
function
weexCallback
(
ret
)
{
const
type
=
ret
.
type
;
delete
ret
.
type
;
const
callback
=
callbacks
[
type
];
const
onBluetoothDeviceFound$1
=
on
(
'
onBluetoothDeviceFound
'
);
const
onBluetoothAdapterStateChange$1
=
on
(
'
onBluetoothAdapterStateChange
'
);
const
onBLEConnectionStateChange$1
=
on
(
'
onBLEConnectionStateChange
'
);
const
onBLECharacteristicValueChange$1
=
on
(
'
onBLECharacteristicValueChange
'
);
if
(
type
===
SUCCESS
)
{
ret
.
errMsg
=
`
${
method
}
:ok`
;
}
else
if
(
type
===
FAIL
)
{
ret
.
errMsg
=
method
+
'
:fail
'
+
(
ret
.
msg
?
(
'
'
+
ret
.
msg
)
:
''
);
}
var
require_context_module_1_5
=
/*#__PURE__*/
Object
.
freeze
({
onBluetoothDeviceFound
:
onBluetoothDeviceFound$1
,
onBluetoothAdapterStateChange
:
onBluetoothAdapterStateChange$1
,
onBLEConnectionStateChange
:
onBLEConnectionStateChange$1
,
onBLECharacteristicValueChange
:
onBLECharacteristicValueChange$1
});
delete
ret
.
code
;
delete
ret
.
msg
;
const
callbacks$2
=
[];
isFn
(
callback
)
&&
callback
(
ret
);
onMethod
(
'
onCompassChange
'
,
function
(
res
)
{
callbacks$2
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
res
);
});
});
if
(
type
===
SUCCESS
||
type
===
FAIL
)
{
const
complete
=
callbacks
[
'
complete
'
];
isFn
(
complete
)
&&
complete
(
ret
);
}
let
isEnable$1
=
false
;
/**
* 监听加速度
* @param {*} callbackId
*/
function
onCompassChange
(
callbackId
)
{
// TODO 当没有 start 时,添加 on 需要主动 start?
callbacks$2
.
push
(
callbackId
);
if
(
!
isEnable$1
)
{
startCompass
();
}
}
class
LivePusherContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
function
startCompass
({
interval
// TODO
}
=
{})
{
if
(
isEnable$1
)
{
return
}
start
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
start
'
,
cbs
)
isEnable$1
=
true
;
return
invokeMethod
(
'
enableCompass
'
,
{
enable
:
true
})
}
stop
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
,
cbs
)
function
stopCompass
()
{
isEnable$1
=
false
;
return
invokeMethod
(
'
enableCompass
'
,
{
enable
:
false
})
}
pause
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
,
cbs
)
}
var
require_context_module_1_6
=
/*#__PURE__*/
Object
.
freeze
({
onCompassChange
:
onCompassChange
,
startCompass
:
startCompass
,
stopCompass
:
stopCompass
});
resume
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resume
'
,
cbs
)
}
const
callbacks$3
=
{
pause
:
[],
resume
:
[],
start
:
[],
stop
:
[]
};
switchCamera
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
switchCamera
'
,
cbs
)
class
RecorderManager
{
constructor
()
{
onMethod
(
'
onRecorderStateChange
'
,
res
=>
{
const
state
=
res
.
state
;
delete
res
.
state
;
delete
res
.
errMsg
;
callbacks$3
[
state
].
forEach
(
callback
=>
{
if
(
typeof
callback
===
'
function
'
)
{
callback
(
res
);
}
snapshot
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
snapshot
'
,
cbs
)
});
});
}
toggleTorch
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
toggleTorch
'
,
cbs
)
onError
(
callback
)
{
callbacks$3
.
error
.
push
(
callback
);
}
onFrameRecorded
(
callback
)
{
playBGM
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playBGM
'
,
args
)
}
onInterruptionBegin
(
callback
)
{
stopBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopBGM
'
,
cbs
)
}
onInterruptionEnd
(
callback
)
{
pauseBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pauseBGM
'
,
cbs
)
}
resumeBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resumeBGM
'
,
cbs
)
onPause
(
callback
)
{
callbacks$3
.
pause
.
push
(
callback
);
}
setBGMVolume
(
cbs
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
setBGMVolume
'
,
cbs
)
onResume
(
callback
)
{
callbacks$3
.
resume
.
push
(
callback
);
}
startPreview
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
startPreview
'
,
cbs
)
onStart
(
callback
)
{
callbacks$3
.
start
.
push
(
callback
);
}
stopPreview
(
args
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopPreview
'
,
args
)
onStop
(
callback
)
{
callbacks$3
.
stop
.
push
(
callback
);
}
pause
()
{
invokeMethod
(
'
operateRecorder
'
,
{
operationType
:
'
pause
'
});
}
function
createLivePusherContext
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createLivePusherContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
resume
()
{
invokeMethod
(
'
operateRecorder
'
,
{
operationType
:
'
resume
'
});
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
start
(
options
)
{
invokeMethod
(
'
operateRecorder
'
,
Object
.
assign
({},
options
,
{
operationType
:
'
start
'
}));
}
return
new
LivePusherContext
(
id
,
elm
)
stop
()
{
invokeMethod
(
'
operateRecorder
'
,
{
operationType
:
'
stop
'
});
}
class
MapContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
getCenterLocation
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getCenterLocation
'
,
cbs
)
}
let
recorderManager
;
moveToLocation
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
moveToLocation
'
)
function
getRecorderManager
()
{
return
recorderManager
||
(
recorderManager
=
new
RecorderManager
())
}
translateMarker
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
translateMarker
'
,
args
,
[
'
animationEnd
'
])
}
var
require_context_module_1_7
=
/*#__PURE__*/
Object
.
freeze
({
getRecorderManager
:
getRecorderManager
});
includePoints
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
includePoints
'
,
args
)
class
DownloadTask
{
constructor
(
downloadTaskId
,
callbackId
)
{
this
.
id
=
downloadTaskId
;
this
.
_callbackId
=
callbackId
;
this
.
_callbacks
=
[];
}
getRegion
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getRegion
'
,
cbs
)
abort
()
{
invokeMethod
(
'
operateRequestTask
'
,
{
downloadTaskId
:
this
.
id
,
operationType
:
'
abort
'
});
}
getScale
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getScale
'
,
cbs
)
onProgressUpdate
(
callback
)
{
if
(
typeof
callback
!==
'
function
'
)
{
return
}
this
.
_callbacks
.
push
(
callback
);
}
onHeadersReceived
()
{
function
createMapContext$1
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createMapContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
offProgressUpdate
(
callback
)
{
const
index
=
this
.
_callbacks
.
indexOf
(
callback
);
if
(
index
>=
0
)
{
this
.
_callbacks
.
splice
(
index
,
1
);
}
return
new
MapContext
(
id
,
elm
)
}
offHeadersReceived
()
{
class
VideoContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
play
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
play
'
)
}
const
downloadTasks$1
=
Object
.
create
(
null
);
onMethod
(
'
onDownloadTaskStateChange
'
,
({
downloadTaskId
,
state
,
tempFilePath
,
statusCode
,
progress
,
totalBytesWritten
,
totalBytesExpectedToWrite
,
errMsg
})
=>
{
const
downloadTask
=
downloadTasks$1
[
downloadTaskId
];
const
callbackId
=
downloadTask
.
_callbackId
;
pause
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
)
switch
(
state
)
{
case
'
progressUpdate
'
:
downloadTask
.
_callbacks
.
forEach
(
callback
=>
{
callback
({
progress
,
totalBytesWritten
,
totalBytesExpectedToWrite
});
});
break
case
'
success
'
:
invoke
(
callbackId
,
{
tempFilePath
,
statusCode
,
errMsg
:
'
request:ok
'
});
// eslint-disable-next-line no-fallthrough
case
'
fail
'
:
invoke
(
callbackId
,
{
errMsg
:
'
request:fail
'
+
errMsg
});
// eslint-disable-next-line no-fallthrough
default
:
// progressUpdate 可能晚于 success
setTimeout
(()
=>
{
delete
downloadTasks$1
[
downloadTaskId
];
},
100
);
break
}
seek
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
seek
'
,
args
)
});
function
downloadFile$1
(
args
,
callbackId
)
{
const
{
downloadTaskId
}
=
invokeMethod
(
'
createDownloadTask
'
,
args
);
const
task
=
new
DownloadTask
(
downloadTaskId
,
callbackId
);
downloadTasks$1
[
downloadTaskId
]
=
task
;
return
task
}
stop
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
)
}
var
require_context_module_1_8
=
/*#__PURE__*/
Object
.
freeze
({
downloadFile
:
downloadFile$1
});
sendDanmu
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
sendDanmu
'
,
args
)
}
const
requestTasks$1
=
Object
.
create
(
null
);
playbackRate
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playbackRate
'
,
args
)
function
formatResponse
(
res
,
args
)
{
if
(
typeof
res
.
data
===
'
string
'
&&
res
.
data
.
charCodeAt
(
0
)
===
65279
)
{
res
.
data
=
res
.
data
.
substr
(
1
);
}
requestFullScreen
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
requestFullScreen
'
,
args
)
}
res
.
statusCode
=
parseInt
(
res
.
statusCode
,
10
);
exitFullScreen
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
exitFullScreen
'
)
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
;
}
showStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
showStatusBar
'
)
return
ret
},
{});
}
hideStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
hideStatusBar
'
)
}
if
(
args
.
dataType
&&
args
.
dataType
.
toLowerCase
()
===
'
json
'
)
{
try
{
res
.
data
=
JSON
.
parse
(
res
.
data
);
}
catch
(
e
)
{}
}
function
createVideoContext$1
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createVideoContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
new
VideoContext
(
id
,
elm
)
return
res
}
function
requireNativePlugin$1
(
name
)
{
return
weex
.
requireModule
(
name
)
onMethod
(
'
onRequestTaskStateChange
'
,
function
({
requestTaskId
,
state
,
data
,
statusCode
,
header
,
errMsg
})
{
const
{
args
,
callbackId
}
=
requestTasks$1
[
requestTaskId
]
||
{};
if
(
!
callbackId
)
{
return
}
delete
requestTasks$1
[
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
}
});
const
ANI_DURATION$1
=
300
;
const
ANI_SHOW$1
=
'
pop-in
'
;
const
ANI_CLOSE
=
'
pop-out
'
;
class
RequestTask
{
constructor
(
id
)
{
this
.
id
=
id
;
}
function
showWebview
(
webview
,
animationType
,
animationDuration
,
callback
)
{
setTimeout
(()
=>
{
webview
.
show
(
animationType
||
ANI_SHOW$1
,
parseInt
(
animationDuration
)
||
ANI_DURATION$1
,
()
=>
{
callback
&&
callback
();
abort
()
{
invokeMethod
(
'
operateRequestTask
'
,
{
requestTaskId
:
this
.
id
,
operationType
:
'
abort
'
});
}
);
},
50
);
offHeadersReceived
()
{
}
let
firstBackTime
=
0
;
onHeadersReceived
()
{
function
quit
()
{
if
(
!
firstBackTime
)
{
firstBackTime
=
Date
.
now
();
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
);
setTimeout
(()
=>
{
firstBackTime
=
null
;
},
2000
);
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
plus
.
runtime
.
quit
();
}
}
function
backWebview
(
webview
,
callback
)
{
if
(
!
webview
.
__uniapp_webview
)
{
return
callback
()
function
request$1
(
args
,
callbackId
)
{
const
{
requestTaskId
}
=
invokeMethod
(
'
createRequestTask
'
,
args
);
requestTasks$1
[
requestTaskId
]
=
{
args
,
callbackId
};
return
new
RequestTask
(
requestTaskId
)
}
const
children
=
webview
.
children
();
if
(
!
children
||
!
children
.
length
)
{
// 有子 webview
return
callback
()
var
require_context_module_1_9
=
/*#__PURE__*/
Object
.
freeze
({
request
:
request$1
});
class
SocketTask
{
constructor
(
socketTaskId
)
{
this
.
id
=
socketTaskId
;
this
.
_callbacks
=
{
open
:
[],
close
:
[],
error
:
[],
message
:
[]
};
this
.
CLOSED
=
3
;
this
.
CLOSING
=
2
;
this
.
CONNECTING
=
0
;
this
.
OPEN
=
1
;
this
.
readyState
=
this
.
CLOSED
;
}
send
(
args
)
{
if
(
this
.
readyState
!==
this
.
OPEN
)
{
this
.
_callback
(
args
,
'
sendSocketMessage:fail WebSocket is not connected
'
);
}
const
{
errMsg
}
=
invokeMethod
(
'
operateSocketTask
'
,
Object
.
assign
({},
args
,
{
operationType
:
'
send
'
,
socketTaskId
:
this
.
id
}));
this
.
_callback
(
args
,
errMsg
.
replace
(
'
operateSocketTask
'
,
'
sendSocketMessage
'
));
}
close
(
args
)
{
this
.
readyState
=
this
.
CLOSING
;
const
{
errMsg
}
=
invokeMethod
(
'
operateSocketTask
'
,
Object
.
assign
({},
args
,
{
operationType
:
'
close
'
,
socketTaskId
:
this
.
id
}));
this
.
_callback
(
args
,
errMsg
.
replace
(
'
operateSocketTask
'
,
'
closeSocket
'
));
}
onOpen
(
callback
)
{
this
.
_callbacks
.
open
.
push
(
callback
);
}
onClose
(
callback
)
{
this
.
_callbacks
.
close
.
push
(
callback
);
}
onError
(
callback
)
{
this
.
_callbacks
.
error
.
push
(
callback
);
}
onMessage
(
callback
)
{
this
.
_callbacks
.
message
.
push
(
callback
);
}
_callback
({
success
,
fail
,
complete
},
errMsg
)
{
var
data
=
{
errMsg
};
if
(
/:ok$/
.
test
(
errMsg
))
{
if
(
typeof
success
===
'
function
'
)
{
success
(
data
);
}
const
childWebview
=
children
[
0
];
childWebview
.
canBack
(({
canBack
})
=>
{
if
(
canBack
)
{
childWebview
.
back
();
// webview 返回
}
else
{
callback
();
if
(
typeof
fail
===
'
function
'
)
{
fail
(
data
);
}
}
if
(
typeof
complete
===
'
function
'
)
{
complete
(
data
);
}
}
});
}
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
'
);
const
socketTasks$1
=
Object
.
create
(
null
);
const
socketTasksArray
=
[];
const
callbacks$4
=
Object
.
create
(
null
);
onMethod
(
'
onSocketTaskStateChange
'
,
({
socketTaskId
,
state
,
data
,
errMsg
})
=>
{
const
socketTask
=
socketTasks$1
[
socketTaskId
];
if
(
!
socketTask
)
{
return
}
socketTask
.
_callbacks
[
state
].
forEach
(
callback
=>
{
if
(
typeof
callback
===
'
function
'
)
{
callback
(
state
===
'
message
'
?
{
data
}
:
{});
}
});
if
(
state
===
'
open
'
)
{
socketTask
.
readyState
=
socketTask
.
OPEN
;
}
backWebview
(
currentPage
,
()
=>
{
if
(
animationType
)
{
currentPage
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION$1
);
}
else
{
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
// 如果是 redirectTo 跳转的,需要制定 back 动画
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
if
(
socketTask
===
socketTasksArray
[
0
]
&&
callbacks$4
[
state
])
{
invoke
(
callbacks$4
[
state
],
state
===
'
message
'
?
{
data
}
:
{});
}
if
(
state
===
'
error
'
||
state
===
'
close
'
)
{
socketTask
.
readyState
=
socketTask
.
CLOSED
;
delete
socketTasks$1
[
socketTaskId
];
const
index
=
socketTasksArray
.
indexOf
(
socketTask
);
if
(
index
>=
0
)
{
socketTasksArray
.
splice
(
index
,
1
);
}
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
}
pages
.
slice
(
len
-
delta
,
len
).
forEach
(
page
=>
page
.
$remove
());
setStatusBarStyle
();
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateBack
'
});
function
connectSocket$1
(
args
,
callbackId
)
{
const
{
socketTaskId
}
=
invokeMethod
(
'
createSocketTask
'
,
args
);
const
task
=
new
SocketTask
(
socketTaskId
);
socketTasks$1
[
socketTaskId
]
=
task
;
socketTasksArray
.
push
(
task
);
setTimeout
(()
=>
{
invoke
(
callbackId
,
{
errMsg
:
'
connectSocket:ok
'
});
},
0
);
return
task
}
function
navigateBack$1
({
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
);
function
sendSocketMessage$1
(
args
,
callbackId
)
{
const
socketTask
=
socketTasksArray
[
0
];
if
(
!
socketTask
||
socketTask
.
readyState
!==
socketTask
.
OPEN
)
{
invoke
(
callbackId
,
{
errMsg
:
'
sendSocketMessage:fail WebSocket is not connected
'
});
return
}
return
invokeMethod
(
'
operateSocketTask
'
,
Object
.
assign
({},
args
,
{
operationType
:
'
send
'
,
socketTaskId
:
socketTask
.
id
}))
}
function
navigateTo$1
({
url
,
animationType
,
animationDuration
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateTo
'
,
path
function
closeSocket$1
(
args
,
callbackId
)
{
const
socketTask
=
socketTasksArray
[
0
];
if
(
!
socketTask
)
{
invoke
(
callbackId
,
{
errMsg
:
'
closeSocket:fail WebSocket is not connected
'
});
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
navigate
'
}),
animationType
,
animationDuration
);
setStatusBarStyle
();
return
}
socketTask
.
readyState
=
socketTask
.
CLOSING
;
return
invokeMethod
(
'
operateSocketTask
'
,
Object
.
assign
({},
args
,
{
operationType
:
'
close
'
,
socketTaskId
:
socketTask
.
id
}))
}
function
reLaunch$1
({
url
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
const
pages
=
getCurrentPages
(
true
).
slice
(
0
);
function
onSocketOpen
(
callbackId
)
{
callbacks$4
.
open
=
callbackId
;
}
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
);
function
onSocketError
(
callbackId
)
{
callbacks$4
.
error
=
callbackId
;
}
if
(
routeOptions
.
meta
.
isTabBar
)
{
tabBar
.
switchTab
(
url
)
;
function
onSocketMessage
(
callbackId
)
{
callbacks$4
.
message
=
callbackId
;
}
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
reLaunch
'
}),
'
none
'
,
0
);
function
onSocketClose
(
callbackId
)
{
callbacks$4
.
close
=
callbackId
;
}
pages
.
forEach
(
page
=>
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
var
require_context_module_1_10
=
/*#__PURE__*/
Object
.
freeze
({
connectSocket
:
connectSocket$1
,
sendSocketMessage
:
sendSocketMessage$1
,
closeSocket
:
closeSocket$1
,
onSocketOpen
:
onSocketOpen
,
onSocketError
:
onSocketError
,
onSocketMessage
:
onSocketMessage
,
onSocketClose
:
onSocketClose
});
setStatusBarStyle
();
class
UploadTask
{
constructor
(
uploadTaskId
,
callbackId
)
{
this
.
id
=
uploadTaskId
;
this
.
_callbackId
=
callbackId
;
this
.
_callbacks
=
[];
}
abort
()
{
invokeMethod
(
'
operateRequestTask
'
,
{
uploadTaskId
:
this
.
id
,
operationType
:
'
abort
'
});
}
onProgressUpdate
(
callback
)
{
if
(
typeof
callback
!==
'
function
'
)
{
return
}
this
.
_callbacks
.
push
(
callback
);
}
onHeadersReceived
()
{
function
redirectTo$1
({
url
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
}
offProgressUpdate
(
callback
)
{
const
index
=
this
.
_callbacks
.
indexOf
(
callback
);
if
(
index
>=
0
)
{
this
.
_callbacks
.
splice
(
index
,
1
);
}
}
offHeadersReceived
()
{
const
pages
=
getCurrentPages
();
const
lastPage
=
pages
[
pages
.
length
-
1
];
lastPage
&&
lastPage
.
$remove
();
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
redirect
'
}),
'
none
'
,
0
,
()
=>
{
lastPage
&&
lastPage
.
$getAppWebview
().
close
(
'
none
'
);
}
);
setStatusBarStyle
();
}
function
switchTab$1
({
url
,
from
})
{
const
path
=
url
.
split
(
'
?
'
)[
0
];
tabBar
.
switchTab
(
path
.
slice
(
1
));
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
;
if
(
len
>=
1
)
{
// 前一个页面是非 tabBar 页面
const
currentPage
=
pages
[
len
-
1
];
if
(
!
currentPage
.
$page
.
meta
.
isTabBar
)
{
pages
.
reverse
().
forEach
(
page
=>
{
if
(
!
page
.
$page
.
meta
.
isTabBar
&&
page
!==
currentPage
)
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
}
});
currentPage
.
$remove
();
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
}
else
{
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
}
}
else
{
// TODO 客户端 Bug
currentPage
.
$getAppWebview
().
hide
(
'
none
'
);
// 前一个 tabBar 触发 onHide
currentPage
.
$vm
.
__call_hook
(
'
onHide
'
);
}
}
let
tabBarPage
;
// 查找当前 tabBarPage,且设置 visible
getCurrentPages
(
true
).
forEach
(
page
=>
{
if
((
'
/
'
+
page
.
route
)
===
path
)
{
page
.
$page
.
meta
.
visible
=
true
;
tabBarPage
=
page
;
}
else
{
if
(
page
.
$page
.
meta
.
isTabBar
)
{
page
.
$page
.
meta
.
visible
=
false
;
}
}
});
if
(
tabBarPage
)
{
tabBarPage
.
$vm
.
__call_hook
(
'
onShow
'
);
tabBarPage
.
$getAppWebview
().
show
(
'
none
'
);
}
else
{
showWebview
(
__registerPage
({
path
,
query
:
{},
openType
:
'
switchTab
'
})
);
}
setStatusBarStyle
();
}
var
nvueApi
=
/*#__PURE__*/
Object
.
freeze
({
createLivePusherContext
:
createLivePusherContext
,
createMapContext
:
createMapContext$1
,
createVideoContext
:
createVideoContext$1
,
requireNativePlugin
:
requireNativePlugin$1
,
navigateBack
:
navigateBack$1
,
navigateTo
:
navigateTo$1
,
reLaunch
:
reLaunch$1
,
redirectTo
:
redirectTo$1
,
switchTab
:
switchTab$1
});
var
platformApi
=
Object
.
assign
(
Object
.
create
(
null
),
appApi
,
nvueApi
);
/**
* 执行内部平台方法
*/
function
invokeMethod
(
name
,
...
args
)
{
return
platformApi
[
name
].
apply
(
null
,
args
)
}
/**
* 监听 service 层内部平台方法回调,与 publish 对应
* @param {Object} name
* @param {Object} callback
*/
function
onMethod
(
name
,
callback
)
{
return
UniServiceJSBridge
.
on
(
'
api.
'
+
name
,
callback
)
}
const
callbacks$1
=
[];
onMethod
(
'
onAccelerometerChange
'
,
function
(
res
)
{
callbacks$1
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
res
);
});
});
let
isEnable
=
false
;
/**
* 监听加速度
* @param {*} callbackId
*/
function
onAccelerometerChange
(
callbackId
)
{
// TODO 当没有 start 时,添加 on 需要主动 start?
callbacks$1
.
push
(
callbackId
);
if
(
!
isEnable
)
{
startAccelerometer
();
}
}
function
startAccelerometer
({
interval
// TODO
}
=
{})
{
if
(
isEnable
)
{
return
}
isEnable
=
true
;
return
invokeMethod
(
'
enableAccelerometer
'
,
{
enable
:
true
})
}
function
stopAccelerometer
()
{
isEnable
=
false
;
return
invokeMethod
(
'
enableAccelerometer
'
,
{
enable
:
false
})
}
var
require_context_module_1_4
=
/*#__PURE__*/
Object
.
freeze
({
onAccelerometerChange
:
onAccelerometerChange
,
startAccelerometer
:
startAccelerometer
,
stopAccelerometer
:
stopAccelerometer
});
const
requestTasks$1
=
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
,
const
uploadTasks$1
=
Object
.
create
(
null
);
onMethod
(
'
onUploadTaskStateChange
'
,
({
uploadTaskId
,
state
,
data
,
statusCode
,
header
,
progress
,
totalBytesSent
,
totalBytesExpectedToSend
,
errMsg
})
{
const
{
args
,
callbackId
}
=
requestTasks$1
[
requestTaskId
];
})
=>
{
const
uploadTask
=
uploadTasks$1
[
uploadTaskId
];
const
callbackId
=
uploadTask
.
_callbackId
;
if
(
!
callbackId
)
{
return
}
delete
requestTasks$1
[
requestTaskId
];
switch
(
state
)
{
case
'
progressUpdate
'
:
uploadTask
.
_callbacks
.
forEach
(
callback
=>
{
callback
({
progress
,
totalBytesSent
,
totalBytesExpectedToSend
});
});
break
case
'
success
'
:
invoke
(
callbackId
,
formatResponse
(
{
invoke
(
callbackId
,
{
data
,
statusCode
,
header
,
errMsg
:
'
request:ok
'
}
,
args
)
);
break
});
// eslint-disable-next-line no-fallthrough
case
'
fail
'
:
invoke
(
callbackId
,
{
errMsg
:
'
request:fail
'
+
errMsg
});
// eslint-disable-next-line no-fallthrough
default
:
// progressUpdate 可能晚于 success
setTimeout
(()
=>
{
delete
uploadTasks$1
[
uploadTaskId
];
},
100
);
break
}
});
class
RequestTask
{
constructor
(
id
)
{
this
.
id
=
id
;
}
abort
()
{
invokeMethod
(
'
operateRequestTask
'
,
{
requestTaskId
:
this
.
id
,
operationType
:
'
abort
'
});
}
offHeadersReceived
()
{
}
onHeadersReceived
()
{
}
}
function
request$1
(
args
,
callbackId
)
{
function
uploadFile$1
(
args
,
callbackId
)
{
const
{
requestTaskId
}
=
invokeMethod
(
'
createRequestTask
'
,
args
);
requestTasks$1
[
requestTaskId
]
=
{
args
,
callbackId
};
return
new
RequestTask
(
requestTaskId
)
uploadTaskId
}
=
invokeMethod
(
'
createUploadTask
'
,
args
);
const
task
=
new
UploadTask
(
uploadTaskId
,
callbackId
);
uploadTasks$1
[
uploadTaskId
]
=
task
;
return
task
}
var
require_context_module_1_
5
=
/*#__PURE__*/
Object
.
freeze
({
request
:
request
$1
var
require_context_module_1_
11
=
/*#__PURE__*/
Object
.
freeze
({
uploadFile
:
uploadFile
$1
});
function
setStorage$1
({
...
...
@@ -7959,7 +7893,7 @@ var serviceContext = (function () {
return
res
}
var
require_context_module_1_
6
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_1_
12
=
/*#__PURE__*/
Object
.
freeze
({
setStorage
:
setStorage$1
,
setStorageSync
:
setStorageSync$1
,
getStorage
:
getStorage$1
,
...
...
@@ -7980,11 +7914,11 @@ var serviceContext = (function () {
return
{}
}
var
require_context_module_1_
7
=
/*#__PURE__*/
Object
.
freeze
({
var
require_context_module_1_
13
=
/*#__PURE__*/
Object
.
freeze
({
pageScrollTo
:
pageScrollTo$1
});
const
api
=
Object
.
create
(
null
);
const
api
$1
=
Object
.
create
(
null
);
const
modules$1
=
(
function
()
{
...
...
@@ -7994,9 +7928,15 @@ var serviceContext = (function () {
'
./base/interceptor.js
'
:
require_context_module_1_2
,
'
./base/upx2px.js
'
:
require_context_module_1_3
,
'
./device/accelerometer.js
'
:
require_context_module_1_4
,
'
./network/request.js
'
:
require_context_module_1_5
,
'
./storage/storage.js
'
:
require_context_module_1_6
,
'
./ui/page-scroll-to.js
'
:
require_context_module_1_7
,
'
./device/bluetooth.js
'
:
require_context_module_1_5
,
'
./device/compass.js
'
:
require_context_module_1_6
,
'
./media/recorder.js
'
:
require_context_module_1_7
,
'
./network/download-file.js
'
:
require_context_module_1_8
,
'
./network/request.js
'
:
require_context_module_1_9
,
'
./network/socket.js
'
:
require_context_module_1_10
,
'
./network/upload-file.js
'
:
require_context_module_1_11
,
'
./storage/storage.js
'
:
require_context_module_1_12
,
'
./ui/page-scroll-to.js
'
:
require_context_module_1_13
,
};
var
req
=
function
req
(
key
)
{
...
...
@@ -8010,16 +7950,567 @@ var serviceContext = (function () {
modules$1
.
keys
().
forEach
(
function
(
key
)
{
Object
.
assign
(
api
,
modules$1
(
key
));
Object
.
assign
(
api
$1
,
modules$1
(
key
));
});
var
api$1
=
Object
.
assign
(
Object
.
create
(
null
),
api
,
platformApi
);
const
SUCCESS
=
'
success
'
;
const
FAIL
=
'
fail
'
;
const
COMPLETE
=
'
complete
'
;
const
CALLBACKS
=
[
SUCCESS
,
FAIL
,
COMPLETE
];
/**
* 调用无参数,或仅一个参数且为 callback 的 API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function
invokeVmMethodWithoutArgs
(
vm
,
method
,
args
,
extras
)
{
if
(
!
vm
)
{
return
}
if
(
typeof
args
===
'
undefined
'
)
{
return
vm
[
method
]()
}
const
[,
callbacks
]
=
normalizeArgs
(
args
,
extras
);
if
(
!
Object
.
keys
(
callbacks
).
length
)
{
return
vm
[
method
]()
}
return
vm
[
method
](
normalizeCallback
(
method
,
callbacks
))
}
/**
* 调用两个参数(第一个入参为普通参数,第二个入参为 callback) API
* @param {Object} vm
* @param {Object} method
* @param {Object} args
* @param {Object} extras
*/
function
invokeVmMethod
(
vm
,
method
,
args
,
extras
)
{
if
(
!
vm
)
{
return
}
const
[
pureArgs
,
callbacks
]
=
normalizeArgs
(
args
,
extras
);
if
(
!
Object
.
keys
(
callbacks
).
length
)
{
return
vm
[
method
](
pureArgs
)
}
return
vm
[
method
](
pureArgs
,
normalizeCallback
(
method
,
callbacks
))
}
function
findElmById
(
id
,
vm
)
{
return
findRefByElm
(
id
,
vm
.
$el
)
}
function
findRefByElm
(
id
,
elm
)
{
if
(
!
id
||
!
elm
)
{
return
}
if
(
elm
.
attr
.
id
===
id
)
{
return
elm
}
const
children
=
elm
.
children
;
if
(
!
children
)
{
return
}
for
(
let
i
=
0
,
len
=
children
.
length
;
i
<
len
;
i
++
)
{
const
elm
=
findRefByElm
(
id
,
children
[
i
]);
if
(
elm
)
{
return
elm
}
}
}
function
normalizeArgs
(
args
=
{},
extras
)
{
const
callbacks
=
Object
.
create
(
null
);
const
iterator
=
function
iterator
(
name
)
{
const
callback
=
args
[
name
];
if
(
isFn
(
callback
))
{
callbacks
[
name
]
=
callback
;
delete
args
[
name
];
}
};
CALLBACKS
.
forEach
(
iterator
);
extras
&&
extras
.
forEach
(
iterator
);
return
[
args
,
callbacks
]
}
function
normalizeCallback
(
method
,
callbacks
)
{
return
function
weexCallback
(
ret
)
{
const
type
=
ret
.
type
;
delete
ret
.
type
;
const
callback
=
callbacks
[
type
];
if
(
type
===
SUCCESS
)
{
ret
.
errMsg
=
`
${
method
}
:ok`
;
}
else
if
(
type
===
FAIL
)
{
ret
.
errMsg
=
method
+
'
:fail
'
+
(
ret
.
msg
?
(
'
'
+
ret
.
msg
)
:
''
);
}
delete
ret
.
code
;
delete
ret
.
msg
;
isFn
(
callback
)
&&
callback
(
ret
);
if
(
type
===
SUCCESS
||
type
===
FAIL
)
{
const
complete
=
callbacks
[
'
complete
'
];
isFn
(
complete
)
&&
complete
(
ret
);
}
}
}
class
LivePusherContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
start
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
start
'
,
cbs
)
}
stop
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
,
cbs
)
}
pause
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
,
cbs
)
}
resume
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resume
'
,
cbs
)
}
switchCamera
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
switchCamera
'
,
cbs
)
}
snapshot
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
snapshot
'
,
cbs
)
}
toggleTorch
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
toggleTorch
'
,
cbs
)
}
playBGM
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playBGM
'
,
args
)
}
stopBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopBGM
'
,
cbs
)
}
pauseBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pauseBGM
'
,
cbs
)
}
resumeBGM
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
resumeBGM
'
,
cbs
)
}
setBGMVolume
(
cbs
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
setBGMVolume
'
,
cbs
)
}
startPreview
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
startPreview
'
,
cbs
)
}
stopPreview
(
args
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stopPreview
'
,
args
)
}
}
function
createLivePusherContext
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createLivePusherContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
new
LivePusherContext
(
id
,
elm
)
}
class
MapContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
getCenterLocation
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getCenterLocation
'
,
cbs
)
}
moveToLocation
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
moveToLocation
'
)
}
translateMarker
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
translateMarker
'
,
args
,
[
'
animationEnd
'
])
}
includePoints
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
includePoints
'
,
args
)
}
getRegion
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getRegion
'
,
cbs
)
}
getScale
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getScale
'
,
cbs
)
}
}
function
createMapContext$1
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createMapContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
new
MapContext
(
id
,
elm
)
}
class
VideoContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
;
this
.
ctx
=
ctx
;
}
play
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
play
'
)
}
pause
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
)
}
seek
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
seek
'
,
args
)
}
stop
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
)
}
sendDanmu
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
sendDanmu
'
,
args
)
}
playbackRate
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playbackRate
'
,
args
)
}
requestFullScreen
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
requestFullScreen
'
,
args
)
}
exitFullScreen
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
exitFullScreen
'
)
}
showStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
showStatusBar
'
)
}
hideStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
hideStatusBar
'
)
}
}
function
createVideoContext$1
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createVideoContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
const
elm
=
findElmById
(
id
,
vm
);
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
new
VideoContext
(
id
,
elm
)
}
function
requireNativePlugin$1
(
name
)
{
return
weex
.
requireModule
(
name
)
}
const
ANI_DURATION$1
=
300
;
const
ANI_SHOW$1
=
'
pop-in
'
;
const
ANI_CLOSE
=
'
pop-out
'
;
function
showWebview
(
webview
,
animationType
,
animationDuration
,
callback
)
{
setTimeout
(()
=>
{
webview
.
show
(
animationType
||
ANI_SHOW$1
,
parseInt
(
animationDuration
)
||
ANI_DURATION$1
,
()
=>
{
callback
&&
callback
();
}
);
},
50
);
}
let
firstBackTime
=
0
;
function
quit
()
{
if
(
!
firstBackTime
)
{
firstBackTime
=
Date
.
now
();
plus
.
nativeUI
.
toast
(
'
再按一次退出应用
'
);
setTimeout
(()
=>
{
firstBackTime
=
null
;
},
2000
);
}
else
if
(
Date
.
now
()
-
firstBackTime
<
2000
)
{
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
{
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
)
{
currentPage
.
$getAppWebview
().
close
(
animationType
,
animationDuration
||
ANI_DURATION$1
);
}
else
{
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
// 如果是 redirectTo 跳转的,需要制定 back 动画
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
}
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
}
pages
.
slice
(
len
-
delta
,
len
).
forEach
(
page
=>
page
.
$remove
());
setStatusBarStyle
();
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateBack
'
});
});
}
function
navigateBack$1
({
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
);
}
function
navigateTo$1
({
url
,
animationType
,
animationDuration
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
UniServiceJSBridge
.
emit
(
'
onAppRoute
'
,
{
type
:
'
navigateTo
'
,
path
});
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
navigate
'
}),
animationType
,
animationDuration
);
setStatusBarStyle
();
}
function
reLaunch$1
({
url
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
const
pages
=
getCurrentPages
(
true
).
slice
(
0
);
const
routeOptions
=
__uniRoutes
.
find
(
route
=>
route
.
path
===
path
);
if
(
routeOptions
.
meta
.
isTabBar
)
{
tabBar
.
switchTab
(
url
);
}
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
reLaunch
'
}),
'
none
'
,
0
);
pages
.
forEach
(
page
=>
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
});
setStatusBarStyle
();
}
function
redirectTo$1
({
url
})
{
const
urls
=
url
.
split
(
'
?
'
);
const
path
=
urls
[
0
];
const
query
=
parseQuery
(
urls
[
1
]
||
''
);
const
pages
=
getCurrentPages
();
const
lastPage
=
pages
[
pages
.
length
-
1
];
lastPage
&&
lastPage
.
$remove
();
showWebview
(
__registerPage
({
path
,
query
,
openType
:
'
redirect
'
}),
'
none
'
,
0
,
()
=>
{
lastPage
&&
lastPage
.
$getAppWebview
().
close
(
'
none
'
);
}
);
setStatusBarStyle
();
}
function
switchTab$1
({
url
,
from
})
{
const
path
=
url
.
split
(
'
?
'
)[
0
];
tabBar
.
switchTab
(
path
.
slice
(
1
));
const
pages
=
getCurrentPages
();
const
len
=
pages
.
length
;
if
(
len
>=
1
)
{
// 前一个页面是非 tabBar 页面
const
currentPage
=
pages
[
len
-
1
];
if
(
!
currentPage
.
$page
.
meta
.
isTabBar
)
{
pages
.
reverse
().
forEach
(
page
=>
{
if
(
!
page
.
$page
.
meta
.
isTabBar
&&
page
!==
currentPage
)
{
page
.
$remove
();
page
.
$getAppWebview
().
close
(
'
none
'
);
}
});
currentPage
.
$remove
();
if
(
currentPage
.
$page
.
openType
===
'
redirect
'
)
{
currentPage
.
$getAppWebview
().
close
(
ANI_CLOSE
,
ANI_DURATION$1
);
}
else
{
currentPage
.
$getAppWebview
().
close
(
'
auto
'
);
}
}
else
{
// 前一个 tabBar 触发 onHide
currentPage
.
$vm
.
__call_hook
(
'
onHide
'
);
}
}
let
tabBarPage
;
// 查找当前 tabBarPage,且设置 visible
getCurrentPages
(
true
).
forEach
(
page
=>
{
if
((
'
/
'
+
page
.
route
)
===
path
)
{
page
.
$page
.
meta
.
visible
=
true
;
tabBarPage
=
page
;
}
else
{
if
(
page
.
$page
.
meta
.
isTabBar
)
{
page
.
$page
.
meta
.
visible
=
false
;
}
}
});
if
(
tabBarPage
)
{
tabBarPage
.
$vm
.
__call_hook
(
'
onShow
'
);
tabBarPage
.
$getAppWebview
().
show
(
'
none
'
);
}
else
{
showWebview
(
__registerPage
({
path
,
query
:
{},
openType
:
'
switchTab
'
})
);
}
setStatusBarStyle
();
}
var
nvueApi
=
/*#__PURE__*/
Object
.
freeze
({
createLivePusherContext
:
createLivePusherContext
,
createMapContext
:
createMapContext$1
,
createVideoContext
:
createVideoContext$1
,
requireNativePlugin
:
requireNativePlugin$1
,
navigateBack
:
navigateBack$1
,
navigateTo
:
navigateTo$1
,
reLaunch
:
reLaunch$1
,
redirectTo
:
redirectTo$1
,
switchTab
:
switchTab$1
});
var
platformApi
=
Object
.
assign
(
Object
.
create
(
null
),
appApi
,
nvueApi
);
var
api$2
=
Object
.
assign
(
Object
.
create
(
null
),
api$1
,
platformApi
);
const
uni$1
=
Object
.
create
(
null
);
apis_1
.
forEach
(
name
=>
{
if
(
api$
1
[
name
])
{
uni$1
[
name
]
=
promisify
(
name
,
wrapper
(
name
,
api$
1
[
name
]));
if
(
api$
2
[
name
])
{
uni$1
[
name
]
=
promisify
(
name
,
wrapper
(
name
,
api$
2
[
name
]));
}
else
{
uni$1
[
name
]
=
wrapperUnimplemented
(
name
);
}
...
...
packages/uni-app-plus-nvue/dist/index.legacy.js
浏览文件 @
e26586eb
...
...
@@ -429,26 +429,22 @@ function invokeVmMethod (vm, method, args, extras) {
}
function
findElmById
(
id
,
vm
)
{
return
find
ElmByVNode
(
id
,
vm
.
_vnode
)
return
find
RefByElm
(
id
,
vm
.
$el
)
}
function
find
ElmByVNode
(
id
,
vnode
)
{
if
(
!
id
||
!
vnode
)
{
function
find
RefByElm
(
id
,
elm
)
{
if
(
!
id
||
!
elm
)
{
return
}
if
(
vnode
.
data
&&
vnode
.
data
.
attrs
&&
vnode
.
data
.
attrs
.
id
===
id
)
{
return
vnode
.
elm
if
(
elm
.
attr
.
id
===
id
)
{
return
elm
}
const
children
=
vnode
.
children
;
const
children
=
elm
.
children
;
if
(
!
children
)
{
return
}
for
(
let
i
=
0
,
len
=
children
.
length
;
i
<
len
;
i
++
)
{
const
elm
=
find
ElmByVNode
(
id
,
children
[
i
]);
const
elm
=
find
RefByElm
(
id
,
children
[
i
]);
if
(
elm
)
{
return
elm
}
...
...
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
e26586eb
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
packages/uni-h5/manifest.json
浏览文件 @
e26586eb
...
...
@@ -406,6 +406,22 @@
"/platforms/h5/service/api/device/vibrate.js"
,
[]
],
"onBluetoothDeviceFound"
:
[
"/core/service/api/device/bluetooth.js"
,
[]
],
"onBluetoothAdapterStateChange"
:
[
"/core/service/api/device/bluetooth.js"
,
[]
],
"onBLEConnectionStateChange"
:
[
"/core/service/api/device/bluetooth.js"
,
[]
],
"onBLECharacteristicValueChange"
:
[
"/core/service/api/device/bluetooth.js"
,
[]
],
"hideKeyboard"
:
[
"/platforms/h5/service/api/device/hide-keyboard.js"
,
[]
...
...
src/core/service/api/media/recorder.js
浏览文件 @
e26586eb
src/platforms/app-plus-nvue/service/api/route/switch-tab.js
浏览文件 @
e26586eb
...
...
@@ -37,8 +37,6 @@ export function switchTab ({
currentPage
.
$getAppWebview
().
close
(
'
auto
'
)
}
}
else
{
// TODO 客户端 Bug
currentPage
.
$getAppWebview
().
hide
(
'
none
'
)
// 前一个 tabBar 触发 onHide
currentPage
.
$vm
.
__call_hook
(
'
onHide
'
)
}
...
...
src/platforms/app-plus/service/framework/app.js
浏览文件 @
e26586eb
...
...
@@ -117,6 +117,8 @@ export function registerApp (appVm) {
appCtx
=
appVm
appCtx
.
globalData
=
appVm
.
$options
.
globalData
||
{}
initOn
(
UniServiceJSBridge
.
on
,
{
getApp
,
getCurrentPages
...
...
src/platforms/app-plus/service/framework/plus-message.js
浏览文件 @
e26586eb
...
...
@@ -29,7 +29,7 @@ export function consumePlusMessage (type, args) {
*/
export
function
registerPlusMessage
(
type
,
callback
,
keepAlive
=
true
)
{
if
(
callbacks
[
type
])
{
throw
new
Error
(
`
${
type
}
已注册:`
+
(
callbacks
[
type
].
toString
()))
return
console
.
warn
(
`
${
type
}
已注册:`
+
(
callbacks
[
type
].
toString
()))
}
callback
.
keepAlive
=
!!
keepAlive
callbacks
[
type
]
=
callback
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录