提交 36bbb136 编写于 作者: fxy060608's avatar fxy060608

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

......@@ -6,19 +6,31 @@ process.env.UNI_CLI_CONTEXT = path.resolve(__dirname, '../../../')
process.env.UNI_HBUILDERX_PLUGINS = process.env.UNI_HBUILDERX_PLUGINS || path.resolve(__dirname, '../../../../')
require('./module-alias')
const {
devtoolModuleFilenameTemplate
} = require('@dcloudio/uni-cli-shared')
} = require('@dcloudio/uni-cli-shared')
module.exports = (api, options) => { // 仅处理 app-plus 相关逻辑
if (process.env.UNI_PLATFORM !== 'app-plus') {
return
}
if (!fs.existsSync(path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'weapp-tools/lib/index.js'))) {
console.error('请使用 HBuilderX 编译运行至 app-plus 平台')
process.exit(0)
if (
(
!process.env.UNI_USING_V3 &&
!process.env.UNI_USING_NATIVE &&
!process.env.UNI_USING_V3_NATIVE
) ||
(
process.env.UNI_USING_NATIVE &&
!process.env.UNI_USING_NVUE_COMPILER
)
) {
if (!fs.existsSync(path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'weapp-tools/lib/index.js'))) {
console.error('请使用 HBuilderX 编译运行至 app-plus 平台')
process.exit(0)
}
}
const plugins = []
......
import {
invoke,
publish,
arrayBufferToBase64,
base64ToArrayBuffer
publish
} from '../../bridge'
/**
......@@ -53,16 +51,6 @@ function bluetoothOn (method, beforeSuccess) {
return true
}
function checkDevices (data) {
data.devices = data.devices.map(device => {
var advertisData = device.advertisData
if (advertisData && typeof advertisData !== 'string') {
device.advertisData = arrayBufferToBase64(advertisData)
}
return device
})
}
var onBluetoothAdapterStateChange
var onBluetoothDeviceFound
var onBLEConnectionStateChange
......@@ -83,7 +71,7 @@ export function getBluetoothAdapterState (data, callbackId) {
}
export function startBluetoothDevicesDiscovery (data, callbackId) {
onBluetoothDeviceFound = onBluetoothDeviceFound || bluetoothOn('onBluetoothDeviceFound', checkDevices)
onBluetoothDeviceFound = onBluetoothDeviceFound || bluetoothOn('onBluetoothDeviceFound')
bluetoothExec('startBluetoothDevicesDiscovery', callbackId, data)
}
......@@ -92,7 +80,7 @@ export function stopBluetoothDevicesDiscovery (data, callbackId) {
}
export function getBluetoothDevices (data, callbackId) {
bluetoothExec('getBluetoothDevices', callbackId, {}, checkDevices)
bluetoothExec('getBluetoothDevices', callbackId, {})
}
export function getConnectedBluetoothDevices (data, callbackId) {
......@@ -118,18 +106,12 @@ export function getBLEDeviceCharacteristics (data, callbackId) {
}
export function notifyBLECharacteristicValueChange (data, callbackId) {
onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange',
data => {
data.value = arrayBufferToBase64(data.value)
})
onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange')
bluetoothExec('notifyBLECharacteristicValueChange', callbackId, data)
}
export function notifyBLECharacteristicValueChanged (data, callbackId) {
onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange',
data => {
data.value = arrayBufferToBase64(data.value)
})
onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange')
bluetoothExec('notifyBLECharacteristicValueChanged', callbackId, data)
}
......@@ -139,8 +121,5 @@ export function readBLECharacteristicValue (data, callbackId) {
}
export function writeBLECharacteristicValue (data, callbackId) {
if (typeof data.value === 'string') {
data.value = base64ToArrayBuffer(data.value)
}
bluetoothExec('writeBLECharacteristicValue', callbackId, data)
}
......@@ -156,7 +156,7 @@ export default {
},
data () {
return {
valueSync: this.value || 0,
valueSync: null,
visible: false,
valueChangeSource: '',
timeArray: [],
......@@ -207,20 +207,17 @@ export default {
}
},
watch: {
value (val) {
if (Array.isArray(val)) {
if (!Array.isArray(this.valueSync)) {
this.valueSync = []
}
this.valueSync.length = val.length
val.forEach((val, index) => {
if (val !== this.valueSync[index]) {
this.$set(this.valueSync, index, val)
}
})
} else if (typeof val !== 'object') {
this.valueSync = val
}
value () {
this._setValueSync()
},
mode () {
this._setValueSync()
},
range () {
this._setValueSync()
},
valueSync () {
this._setValueArray()
},
valueArray (val) {
if (this.mode === mode.TIME || this.mode === mode.DATE) {
......@@ -269,8 +266,7 @@ export default {
})
this._createTime()
this._createDate()
this.$watch('valueSync', this._setValue)
this.$watch('mode', this._setValue)
this._setValueSync()
},
beforeDestroy () {
this.$refs.picker.remove()
......@@ -285,7 +281,6 @@ export default {
return
}
this.valueChangeSource = ''
this._setValue()
var $picker = this.$refs.picker
$picker.remove();
(document.querySelector('uni-app') || document.body).appendChild($picker)
......@@ -346,13 +341,34 @@ export default {
val1[i] = val2[i]
}
},
_setValue () {
_setValueSync () {
let val = this.value
switch (this.mode) {
case mode.MULTISELECTOR:
if (!Array.isArray(val)) {
val = []
}
if (!Array.isArray(this.valueSync)) {
this.valueSync = []
}
const length = this.valueSync.length = Math.max(val.length, this.range.length)
for (let index = 0; index < length; index++) {
this.valueSync.splice(index, 1, Number(val[index]) || Number(this.valueSync[index]) || 0)
}
break
case mode.TIME:
case mode.DATE:
this.valueSync = String(val)
break
default:
this.valueSync = Number(val) || 0
break
}
},
_setValueArray () {
var val = this.valueSync
var valueArray
switch (this.mode) {
case mode.SELECTOR:
valueArray = [val]
break
case mode.MULTISELECTOR:
valueArray = [...val]
break
......@@ -366,6 +382,9 @@ export default {
mode: mode.DATE
}))
break
default:
valueArray = [val]
break
}
this.oldValueArray = [...valueArray]
this.valueArray = [...valueArray]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册