提交 e26586eb 编写于 作者: Q qiang

Merge branch 'nvue-dev' of github.com:dcloudio/uni-app into nvue-dev

...@@ -76,7 +76,8 @@ function parseApiManifestDeps (manifest, protocol) { ...@@ -76,7 +76,8 @@ function parseApiManifestDeps (manifest, protocol) {
if (manifest[dep[1]]) { if (manifest[dep[1]]) {
dep[0] = manifest[dep[1]][0] dep[0] = manifest[dep[1]][0]
} else { } else {
console.error(`依赖模块[${dep[1]}]不存在`) console.error(`依赖模块[${dep[1]}]不存在,删除 ${name} 接口\n`)
delete manifest[name]
} }
}) })
} }
......
...@@ -23,10 +23,12 @@ if (process.env.UNI_SERVICE === 'legacy') { ...@@ -23,10 +23,12 @@ if (process.env.UNI_SERVICE === 'legacy') {
output.format = 'iife' output.format = 'iife'
output.name = 'serviceContext' output.name = 'serviceContext'
output.banner = 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 localStorage = plus.storage
var setTimeout = global.setTimeout var setTimeout = instanceContext.setTimeout
var clearTimeout = global.clearTimeout var clearTimeout = instanceContext.clearTimeout
var setInterval = instanceContext.setInterval
var clearInterval = instanceContext.clearInterval
` `
output.footer = output.footer =
` `
......
...@@ -52,7 +52,6 @@ const media = [ ...@@ -52,7 +52,6 @@ const media = [
'getImageInfo', 'getImageInfo',
'saveImageToPhotosAlbum', 'saveImageToPhotosAlbum',
'compressImage', 'compressImage',
'chooseMessageFile',
'getRecorderManager', 'getRecorderManager',
'getBackgroundAudioManager', 'getBackgroundAudioManager',
'createInnerAudioContext', 'createInnerAudioContext',
......
[{
"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
}
}]
...@@ -429,26 +429,22 @@ function invokeVmMethod (vm, method, args, extras) { ...@@ -429,26 +429,22 @@ function invokeVmMethod (vm, method, args, extras) {
} }
function findElmById (id, vm) { function findElmById (id, vm) {
return findElmByVNode(id, vm._vnode) return findRefByElm(id, vm.$el)
} }
function findElmByVNode (id, vnode) { function findRefByElm (id, elm) {
if (!id || !vnode) { if (!id || !elm) {
return return
} }
if ( if (elm.attr.id === id) {
vnode.data && return elm
vnode.data.attrs &&
vnode.data.attrs.id === id
) {
return vnode.elm
} }
const children = vnode.children; const children = elm.children;
if (!children) { if (!children) {
return return
} }
for (let i = 0, len = children.length; i < len; i++) { for (let i = 0, len = children.length; i < len; i++) {
const elm = findElmByVNode(id, children[i]); const elm = findRefByElm(id, children[i]);
if (elm) { if (elm) {
return elm return elm
} }
......
...@@ -406,6 +406,22 @@ ...@@ -406,6 +406,22 @@
"/platforms/h5/service/api/device/vibrate.js", "/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": [ "hideKeyboard": [
"/platforms/h5/service/api/device/hide-keyboard.js", "/platforms/h5/service/api/device/hide-keyboard.js",
[] []
......
import { import {
onMethod, onMethod,
invokeMethod invokeMethod
} from '../../platform' } from '../../platform'
const callbacks = { const callbacks = {
pause: [], pause: [],
resume: [], resume: [],
start: [], start: [],
stop: [] stop: []
} }
class RecorderManager { class RecorderManager {
constructor () { constructor () {
onMethod('onRecorderStateChange', res => { onMethod('onRecorderStateChange', res => {
const state = res.state const state = res.state
delete res.state delete res.state
delete res.errMsg delete res.errMsg
callbacks[state].forEach(callback => { callbacks[state].forEach(callback => {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(res) callback(res)
} }
}) })
}) })
} }
onError (callback) { onError (callback) {
callbacks.error.push(callback) callbacks.error.push(callback)
} }
onFrameRecorded (callback) { onFrameRecorded (callback) {
} }
onInterruptionBegin (callback) { onInterruptionBegin (callback) {
} }
onInterruptionEnd (callback) { onInterruptionEnd (callback) {
} }
onPause (callback) { onPause (callback) {
callbacks.pause.push(callback) callbacks.pause.push(callback)
} }
onResume (callback) { onResume (callback) {
callbacks.resume.push(callback) callbacks.resume.push(callback)
} }
onStart (callback) { onStart (callback) {
callbacks.start.push(callback) callbacks.start.push(callback)
} }
onStop (callback) { onStop (callback) {
callbacks.stop.push(callback) callbacks.stop.push(callback)
} }
pause () { pause () {
invokeMethod('operateRecorder', { invokeMethod('operateRecorder', {
operationType: 'pause' operationType: 'pause'
}) })
} }
resume () { resume () {
invokeMethod('operateRecorder', { invokeMethod('operateRecorder', {
operationType: 'resume' operationType: 'resume'
}) })
} }
start (options) { start (options) {
invokeMethod('operateRecorder', Object.assign({}, options, { invokeMethod('operateRecorder', Object.assign({}, options, {
operationType: 'start' operationType: 'start'
})) }))
} }
stop () { stop () {
invokeMethod('operateRecorder', { invokeMethod('operateRecorder', {
operationType: 'stop' operationType: 'stop'
}) })
} }
} }
let recorderManager let recorderManager
export function getRecorderManager () { export function getRecorderManager () {
return recorderManager || (recorderManager = new RecorderManager()) return recorderManager || (recorderManager = new RecorderManager())
} }
...@@ -37,8 +37,6 @@ export function switchTab ({ ...@@ -37,8 +37,6 @@ export function switchTab ({
currentPage.$getAppWebview().close('auto') currentPage.$getAppWebview().close('auto')
} }
} else { } else {
// TODO 客户端 Bug
currentPage.$getAppWebview().hide('none')
// 前一个 tabBar 触发 onHide // 前一个 tabBar 触发 onHide
currentPage.$vm.__call_hook('onHide') currentPage.$vm.__call_hook('onHide')
} }
......
...@@ -115,7 +115,9 @@ export function registerApp (appVm) { ...@@ -115,7 +115,9 @@ export function registerApp (appVm) {
console.log(`[uni-app] registerApp`) console.log(`[uni-app] registerApp`)
} }
appCtx = appVm appCtx = appVm
appCtx.globalData = appVm.$options.globalData || {}
initOn(UniServiceJSBridge.on, { initOn(UniServiceJSBridge.on, {
getApp, getApp,
......
...@@ -29,7 +29,7 @@ export function consumePlusMessage (type, args) { ...@@ -29,7 +29,7 @@ export function consumePlusMessage (type, args) {
*/ */
export function registerPlusMessage (type, callback, keepAlive = true) { export function registerPlusMessage (type, callback, keepAlive = true) {
if (callbacks[type]) { if (callbacks[type]) {
throw new Error(`${type} 已注册:` + (callbacks[type].toString())) return console.warn(`${type} 已注册:` + (callbacks[type].toString()))
} }
callback.keepAlive = !!keepAlive callback.keepAlive = !!keepAlive
callbacks[type] = callback callbacks[type] = callback
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册