智能照明系统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/2a/2a3774a13d4291b9bebb186bb41...

41 lines
778 B

3 years ago
const defaultApp = {
globalData: {}
}
function wrapper (def) {
if (def.__$processed) {
return def
}
const methods = def.methods
if (methods) {
Object.keys(methods).forEach(name => {
def[name] = methods[name]
})
delete def.methods
}
// merge defaultApp
Object.keys(defaultApp).forEach(name => {
if (name !== 'globalData') {
def[name] = defaultApp[name]
}
})
if (!def.globalData) {
def.globalData = {}
}
Object.assign(def.globalData, defaultApp.globalData)
def.__$processed = true
return def
}
export function getApp ({
allowDefault = false
} = {}) {
/* eslint-disable no-undef */
if (inst.$def) {
return wrapper(inst.$def)
}
if (allowDefault) { // 返回默认实现
return defaultApp
}
}