智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/f9/f9af767e34bebdc015b33219e91...

49 lines
1.0 KiB

import {
cached,
camelize
} from 'uni-shared'
const MPPage = Page
const MPComponent = Component
const customizeRE = /:/g
const customize = cached((str) => {
return camelize(str.replace(customizeRE, '-'))
})
function initTriggerEvent (mpInstance) {
if (__PLATFORM__ === 'mp-weixin' || __PLATFORM__ === 'app-plus') {
if (!wx.canIUse('nextTick')) {
return
}
}
const oldTriggerEvent = mpInstance.triggerEvent
mpInstance.triggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
}
}
function initHook (name, options) {
const oldHook = options[name]
if (!oldHook) {
options[name] = function () {
initTriggerEvent(this)
}
} else {
options[name] = function (...args) {
initTriggerEvent(this)
return oldHook.apply(this, args)
}
}
}
Page = function (options = {}) {
initHook('onLoad', options)
return MPPage(options)
}
Component = function (options = {}) {
initHook('created', options)
return MPComponent(options)
}