|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
(function () { |
|
|
|
|
var moduleInjection = {}, moduleInjectionMap = { |
|
|
|
|
import { isFunction, isNull, isNotNull, isArray, each, isWidget, extend, init, isEmpty, remove } from "./2.base"; |
|
|
|
|
import OB from "./3.ob"; |
|
|
|
|
import Widget from "./4.widget" |
|
|
|
|
|
|
|
|
|
let moduleInjection = {}, moduleInjectionMap = { |
|
|
|
|
components: {}, |
|
|
|
|
constants: {}, |
|
|
|
|
stores: {}, |
|
|
|
@ -7,16 +10,17 @@
|
|
|
|
|
models: {}, |
|
|
|
|
providers: {} |
|
|
|
|
}; |
|
|
|
|
BI.module = BI.module || function (xtype, cls) { |
|
|
|
|
|
|
|
|
|
export function module(xtype, cls) { |
|
|
|
|
if (moduleInjection[xtype] != null) { |
|
|
|
|
_global.console && console.error("module: [" + xtype + "] 已经注册过了"); |
|
|
|
|
} else { |
|
|
|
|
if (BI.isFunction(cls)) { |
|
|
|
|
if (isFunction(cls)) { |
|
|
|
|
cls = cls(); |
|
|
|
|
} |
|
|
|
|
for (var k in moduleInjectionMap) { |
|
|
|
|
for (const k in moduleInjectionMap) { |
|
|
|
|
if (cls[k]) { |
|
|
|
|
for (var key in cls[k]) { |
|
|
|
|
for (const key in cls[k]) { |
|
|
|
|
if (!moduleInjectionMap[k]) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
@ -33,112 +37,103 @@
|
|
|
|
|
moduleInjection[xtype] = cls; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return function () { |
|
|
|
|
return BI.Modules.getModule(xtype); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
return () => Modules.getModule(xtype); |
|
|
|
|
} |
|
|
|
|
BI.module = BI.module || module; |
|
|
|
|
|
|
|
|
|
var constantInjection = {}; |
|
|
|
|
BI.constant = BI.constant || function (xtype, cls) { |
|
|
|
|
let constantInjection = {}; |
|
|
|
|
export function constant(xtype, cls) { |
|
|
|
|
if (constantInjection[xtype] != null) { |
|
|
|
|
_global.console && console.error("constant: [" + xtype + "]已经注册过了"); |
|
|
|
|
} else { |
|
|
|
|
constantInjection[xtype] = cls; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return function () { |
|
|
|
|
return BI.Constants.getConstant(xtype); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
return () => Constants.getConstant(xtype); |
|
|
|
|
} |
|
|
|
|
BI.constant = BI.constant || constant; |
|
|
|
|
|
|
|
|
|
var modelInjection = {}; |
|
|
|
|
BI.model = BI.model || function (xtype, cls) { |
|
|
|
|
let modelInjection = {}; |
|
|
|
|
export function model(xtype, cls) { |
|
|
|
|
if (modelInjection[xtype] != null) { |
|
|
|
|
_global.console && console.error("model: [" + xtype + "] 已经注册过了"); |
|
|
|
|
} else { |
|
|
|
|
modelInjection[xtype] = cls; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return function (config) { |
|
|
|
|
return BI.Models.getModel(xtype, config); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
return (config) => Models.getModel(xtype, config); |
|
|
|
|
} |
|
|
|
|
BI.model = BI.model || model; |
|
|
|
|
|
|
|
|
|
var storeInjection = {}; |
|
|
|
|
BI.store = BI.store || function (xtype, cls) { |
|
|
|
|
let storeInjection = {}; |
|
|
|
|
export function store(xtype, cls) { |
|
|
|
|
if (storeInjection[xtype] != null) { |
|
|
|
|
_global.console && console.error("store: [" + xtype + "] 已经注册过了"); |
|
|
|
|
} else { |
|
|
|
|
storeInjection[xtype] = cls; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return function (config) { |
|
|
|
|
return BI.Stores.getStore(xtype, config); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
return (config) => Stores.getStore(xtype, config); |
|
|
|
|
} |
|
|
|
|
BI.store = BI.store || store; |
|
|
|
|
|
|
|
|
|
var serviceInjection = {}; |
|
|
|
|
BI.service = BI.service || function (xtype, cls) { |
|
|
|
|
let serviceInjection = {}; |
|
|
|
|
export function service(xtype, cls) { |
|
|
|
|
if (serviceInjection[xtype] != null) { |
|
|
|
|
_global.console && console.error("service: [" + xtype + "] 已经注册过了"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
serviceInjection[xtype] = cls; |
|
|
|
|
|
|
|
|
|
return function (config) { |
|
|
|
|
return BI.Services.getService(xtype, config); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
return (config) => Services.getService(xtype, config); |
|
|
|
|
} |
|
|
|
|
BI.service = BI.service || service; |
|
|
|
|
|
|
|
|
|
var providerInjection = {}; |
|
|
|
|
BI.provider = BI.provider || function (xtype, cls) { |
|
|
|
|
let providerInjection = {}; |
|
|
|
|
export function provider(xtype, cls) { |
|
|
|
|
if (providerInjection[xtype] != null) { |
|
|
|
|
_global.console && console.error("provider: [" + xtype + "] 已经注册过了"); |
|
|
|
|
} else { |
|
|
|
|
providerInjection[xtype] = cls; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return function (config) { |
|
|
|
|
return BI.Providers.getProvider(xtype, config); |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
return (config) => Providers.getProvider(xtype, config); |
|
|
|
|
} |
|
|
|
|
BI.provider = BI.provider || provider; |
|
|
|
|
|
|
|
|
|
var configFunctions = BI.OB.configFunctions = {}; |
|
|
|
|
var runConfigFunction = function (type, configFn) { |
|
|
|
|
let configFunctions = OB.configFunctions = {}; |
|
|
|
|
const runConfigFunction = function (type, configFn) { |
|
|
|
|
if (!type || !configFunctions[type]) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var queue = []; |
|
|
|
|
let queue = []; |
|
|
|
|
if (configFn) { |
|
|
|
|
queue = configFunctions[type].filter(function (conf) { |
|
|
|
|
return conf.fn === configFn; |
|
|
|
|
}); |
|
|
|
|
configFunctions[type] = configFunctions[type].filter(function (conf) { |
|
|
|
|
return conf.fn !== configFn; |
|
|
|
|
}); |
|
|
|
|
queue = configFunctions[type].filter((conf) => conf.fn === configFn); |
|
|
|
|
configFunctions[type] = configFunctions[type].filter((conf) => conf.fn !== configFn); |
|
|
|
|
} else { |
|
|
|
|
queue = configFunctions[type]; |
|
|
|
|
delete configFunctions[type]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies(); |
|
|
|
|
var modules = moduleInjectionMap.components[type] |
|
|
|
|
const dependencies = Providers.getProvider("bi.provider.system").getDependencies(); |
|
|
|
|
const modules = moduleInjectionMap.components[type] |
|
|
|
|
|| moduleInjectionMap.constants[type] |
|
|
|
|
|| moduleInjectionMap.services[type] |
|
|
|
|
|| moduleInjectionMap.stores[type] |
|
|
|
|
|| moduleInjectionMap.models[type] |
|
|
|
|
|| moduleInjectionMap.providers[type]; |
|
|
|
|
for (var i = 0; i < queue.length; i++) { |
|
|
|
|
var conf = queue[i]; |
|
|
|
|
var version = conf.opt.version; |
|
|
|
|
var fn = conf.fn; |
|
|
|
|
for (let i = 0; i < queue.length; i++) { |
|
|
|
|
const conf = queue[i]; |
|
|
|
|
const version = conf.opt.version; |
|
|
|
|
const fn = conf.fn; |
|
|
|
|
if (modules && version) { |
|
|
|
|
var findVersion = false; |
|
|
|
|
for (var j = 0; j < modules.length; j++) { |
|
|
|
|
var module = modules[j]; |
|
|
|
|
let findVersion = false; |
|
|
|
|
let module; |
|
|
|
|
for (let j = 0; j < modules.length; j++) { |
|
|
|
|
module = modules[j]; |
|
|
|
|
if (module && dependencies[module.moduleId] && module.version === version) { |
|
|
|
|
var minVersion = dependencies[module.moduleId].minVersion, |
|
|
|
|
const minVersion = dependencies[module.moduleId].minVersion, |
|
|
|
|
maxVersion = dependencies[module.moduleId].maxVersion; |
|
|
|
|
if (minVersion && (moduleInjection[module.moduleId].version || version) < minVersion) { |
|
|
|
|
findVersion = true; |
|
|
|
@ -172,8 +167,9 @@
|
|
|
|
|
BI.Plugin.configWidget(type, fn, conf.opt); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
BI.config = BI.config || function (type, configFn, opt) { |
|
|
|
|
if (BI.isFunction(type)) { |
|
|
|
|
|
|
|
|
|
export function config(type, configFn, opt) { |
|
|
|
|
if (isFunction(type)) { |
|
|
|
|
opt = configFn; |
|
|
|
|
configFn = type; |
|
|
|
|
type = "bi.provider.system"; |
|
|
|
@ -203,39 +199,38 @@
|
|
|
|
|
if (opt.immediately) { |
|
|
|
|
return runConfigFunction(type, configFn); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.config = BI.config || config; |
|
|
|
|
|
|
|
|
|
BI.getReference = BI.getReference || function (type, fn) { |
|
|
|
|
export function getReference(type, fn) { |
|
|
|
|
return BI.Plugin.registerObject(type, fn); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.getReference = BI.getReference || getReference; |
|
|
|
|
|
|
|
|
|
var actions = {}; |
|
|
|
|
var globalAction = []; |
|
|
|
|
BI.action = BI.action || function (type, actionFn) { |
|
|
|
|
if (BI.isFunction(type)) { |
|
|
|
|
let actions = {}; |
|
|
|
|
let globalAction = []; |
|
|
|
|
export function action(type, actionFn) { |
|
|
|
|
if (isFunction(type)) { |
|
|
|
|
globalAction.push(type); |
|
|
|
|
return function () { |
|
|
|
|
BI.remove(globalAction, function (idx) { |
|
|
|
|
return globalAction.indexOf(actionFn) === idx; |
|
|
|
|
}); |
|
|
|
|
return () => { |
|
|
|
|
remove(globalAction, (idx) => globalAction.indexOf(actionFn) === idx); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
if (!actions[type]) { |
|
|
|
|
actions[type] = []; |
|
|
|
|
} |
|
|
|
|
actions[type].push(actionFn); |
|
|
|
|
return function () { |
|
|
|
|
BI.remove(actions[type], function (idx) { |
|
|
|
|
return actions[type].indexOf(actionFn) === idx; |
|
|
|
|
}); |
|
|
|
|
return () => { |
|
|
|
|
remove(actions[type], (idx) => actions[type].indexOf(actionFn) === idx); |
|
|
|
|
if (actions[type].length === 0) { |
|
|
|
|
delete actions[type]; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.action = BI.action || action; |
|
|
|
|
|
|
|
|
|
var points = {}; |
|
|
|
|
BI.point = BI.point || function (type, action, pointFn, after) { |
|
|
|
|
let points = {}; |
|
|
|
|
export function point(type, action, pointFn, after) { |
|
|
|
|
if (!points[type]) { |
|
|
|
|
points[type] = {}; |
|
|
|
|
} |
|
|
|
@ -246,9 +241,10 @@
|
|
|
|
|
points[type][action][after ? "after" : "before"] = []; |
|
|
|
|
} |
|
|
|
|
points[type][action][after ? "after" : "before"].push(pointFn); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.point = BI.point || point; |
|
|
|
|
|
|
|
|
|
BI.Modules = BI.Modules || { |
|
|
|
|
export const Modules = { |
|
|
|
|
getModule: function (type) { |
|
|
|
|
if (!moduleInjection[type]) { |
|
|
|
|
_global.console && console.error("module: [" + type + "] 未定义"); |
|
|
|
@ -258,28 +254,30 @@
|
|
|
|
|
getAllModules: function () { |
|
|
|
|
return moduleInjection; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.Modules = BI.Modules || Modules; |
|
|
|
|
|
|
|
|
|
BI.Constants = BI.Constants || { |
|
|
|
|
export const Constants = { |
|
|
|
|
getConstant: function (type) { |
|
|
|
|
if (BI.isNull(constantInjection[type])) { |
|
|
|
|
if (isNull(constantInjection[type])) { |
|
|
|
|
_global.console && console.error("constant: [" + type + "] 未定义"); |
|
|
|
|
} |
|
|
|
|
runConfigFunction(type); |
|
|
|
|
return BI.isFunction(constantInjection[type]) ? constantInjection[type]() : constantInjection[type]; |
|
|
|
|
return isFunction(constantInjection[type]) ? constantInjection[type]() : constantInjection[type]; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.Constants = BI.Constants || Constants; |
|
|
|
|
|
|
|
|
|
var callPoint = function (inst, types) { |
|
|
|
|
types = BI.isArray(types) ? types : [types]; |
|
|
|
|
BI.each(types, function (idx, type) { |
|
|
|
|
const callPoint = function (inst, types) { |
|
|
|
|
types = isArray(types) ? types : [types]; |
|
|
|
|
each(types, (idx, type) => { |
|
|
|
|
if (points[type]) { |
|
|
|
|
for (var action in points[type]) { |
|
|
|
|
var bfns = points[type][action].before; |
|
|
|
|
for (const action in points[type]) { |
|
|
|
|
let bfns = points[type][action].before; |
|
|
|
|
if (bfns) { |
|
|
|
|
BI.aspect.before(inst, action, function (bfns) { |
|
|
|
|
return function () { |
|
|
|
|
for (var i = 0, len = bfns.length; i < len; i++) { |
|
|
|
|
for (let i = 0, len = bfns.length; i < len; i++) { |
|
|
|
|
try { |
|
|
|
|
bfns[i].apply(inst, arguments); |
|
|
|
|
} catch (e) { |
|
|
|
@ -289,11 +287,11 @@
|
|
|
|
|
}; |
|
|
|
|
}(bfns)); |
|
|
|
|
} |
|
|
|
|
var afns = points[type][action].after; |
|
|
|
|
let afns = points[type][action].after; |
|
|
|
|
if (afns) { |
|
|
|
|
BI.aspect.after(inst, action, function (afns) { |
|
|
|
|
return function () { |
|
|
|
|
for (var i = 0, len = afns.length; i < len; i++) { |
|
|
|
|
for (let i = 0, len = afns.length; i < len; i++) { |
|
|
|
|
try { |
|
|
|
|
afns[i].apply(inst, arguments); |
|
|
|
|
} catch (e) { |
|
|
|
@ -308,7 +306,7 @@
|
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
BI.Models = BI.Models || { |
|
|
|
|
export const Models = { |
|
|
|
|
getModel: function (type, config) { |
|
|
|
|
if (!modelInjection[type]) { |
|
|
|
|
_global.console && console.error("model: [" + type + "] 未定义"); |
|
|
|
@ -320,11 +318,11 @@
|
|
|
|
|
callPoint(inst, type); |
|
|
|
|
return inst; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var stores = {}; |
|
|
|
|
} |
|
|
|
|
BI.Models = BI.Models || Models; |
|
|
|
|
|
|
|
|
|
BI.Stores = BI.Stores || { |
|
|
|
|
let stores = {}; |
|
|
|
|
export const Stores = { |
|
|
|
|
getStore: function (type, config) { |
|
|
|
|
if (!storeInjection[type]) { |
|
|
|
|
_global.console && console.error("store: [" + type + "] 未定义"); |
|
|
|
@ -332,19 +330,19 @@
|
|
|
|
|
if (stores[type]) { |
|
|
|
|
return stores[type]; |
|
|
|
|
} |
|
|
|
|
var inst = stores[type] = new storeInjection[type](config); |
|
|
|
|
const inst = stores[type] = new storeInjection[type](config); |
|
|
|
|
inst._constructor && inst._constructor(config, function () { |
|
|
|
|
delete stores[type]; |
|
|
|
|
}); |
|
|
|
|
callPoint(inst, type); |
|
|
|
|
return inst; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var services = {}; |
|
|
|
|
} |
|
|
|
|
BI.Stores = BI.Stores || Stores; |
|
|
|
|
|
|
|
|
|
BI.Services = BI.Services || { |
|
|
|
|
getService: function (type, config) { |
|
|
|
|
let services = {}; |
|
|
|
|
export const Services = { |
|
|
|
|
getService: (type, config) => { |
|
|
|
|
if (!serviceInjection[type]) { |
|
|
|
|
_global.console && console.error("service: [" + type + "] 未定义"); |
|
|
|
|
} |
|
|
|
@ -355,13 +353,13 @@
|
|
|
|
|
callPoint(services[type], type); |
|
|
|
|
return services[type]; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.Services = BI.Services || Services; |
|
|
|
|
|
|
|
|
|
var providers = {}, |
|
|
|
|
let providers = {}, |
|
|
|
|
providerInstance = {}; |
|
|
|
|
|
|
|
|
|
BI.Providers = BI.Providers || { |
|
|
|
|
getProvider: function (type, config) { |
|
|
|
|
export const Providers = { |
|
|
|
|
getProvider: (type, config) => { |
|
|
|
|
if (!providerInjection[type]) { |
|
|
|
|
_global.console && console.error("provider: [" + type + "] 未定义"); |
|
|
|
|
} |
|
|
|
@ -374,11 +372,12 @@
|
|
|
|
|
} |
|
|
|
|
return providerInstance[type]; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.Providers = BI.Providers || Providers; |
|
|
|
|
|
|
|
|
|
BI.Actions = BI.Actions || { |
|
|
|
|
export const Actions = { |
|
|
|
|
runAction: function (type, event, config) { |
|
|
|
|
BI.each(actions[type], function (i, act) { |
|
|
|
|
each(actions[type], (i, act) => { |
|
|
|
|
try { |
|
|
|
|
act(event, config); |
|
|
|
|
} catch (e) { |
|
|
|
@ -388,7 +387,7 @@
|
|
|
|
|
}, |
|
|
|
|
runGlobalAction: function () { |
|
|
|
|
var args = [].slice.call(arguments); |
|
|
|
|
BI.each(globalAction, function (i, act) { |
|
|
|
|
each(globalAction, (i, act) => { |
|
|
|
|
try { |
|
|
|
|
act.apply(null, args); |
|
|
|
|
} catch (e) { |
|
|
|
@ -396,10 +395,11 @@
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.Actions = BI.Actions || Actions; |
|
|
|
|
|
|
|
|
|
var kv = {}; |
|
|
|
|
BI.shortcut = BI.component = BI.shortcut || function (xtype, cls) { |
|
|
|
|
let kv = {}; |
|
|
|
|
export function shortcut(xtype, cls) { |
|
|
|
|
if (kv[xtype] != null) { |
|
|
|
|
_global.console && console.error("组件: [" + xtype + "] 已经注册过了"); |
|
|
|
|
} |
|
|
|
@ -407,21 +407,22 @@
|
|
|
|
|
cls["xtype"] = xtype; |
|
|
|
|
} |
|
|
|
|
kv[xtype] = cls; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.shortcut = BI.component = BI.shortcut || shortcut; |
|
|
|
|
|
|
|
|
|
// 根据配置属性生成widget
|
|
|
|
|
var createWidget = function (config, context, lazy) { |
|
|
|
|
var cls = BI.isFunction(config.type) ? config.type : kv[config.type]; |
|
|
|
|
const createRealWidget = function (config, context, lazy) { |
|
|
|
|
const cls = isFunction(config.type) ? config.type : kv[config.type]; |
|
|
|
|
|
|
|
|
|
if (!cls) { |
|
|
|
|
throw new Error("组件: [" + config.type + "] 未定义"); |
|
|
|
|
} |
|
|
|
|
var pushed = false; |
|
|
|
|
var widget = new cls(); |
|
|
|
|
widget._context = BI.Widget.context || context; |
|
|
|
|
if (!BI.Widget.context && context) { |
|
|
|
|
let pushed = false; |
|
|
|
|
const widget = new cls(); |
|
|
|
|
widget._context = Widget.context || context; |
|
|
|
|
if (!Widget.context && context) { |
|
|
|
|
pushed = true; |
|
|
|
|
BI.Widget.pushContext(context); |
|
|
|
|
Widget.pushContext(context); |
|
|
|
|
} |
|
|
|
|
callPoint(widget, config.type); |
|
|
|
|
widget._initProps(config); |
|
|
|
@ -430,13 +431,13 @@
|
|
|
|
|
// if (!lazy || config.element || config.root) {
|
|
|
|
|
widget._lazyConstructor(); |
|
|
|
|
// }
|
|
|
|
|
pushed && BI.Widget.popContext(); |
|
|
|
|
pushed && Widget.popContext(); |
|
|
|
|
return widget; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
BI.createWidget = BI.createWidget || function (item, options, context, lazy) { |
|
|
|
|
export function createWidget(item, options, context, lazy) { |
|
|
|
|
item || (item = {}); |
|
|
|
|
if (BI.isWidget(options)) { |
|
|
|
|
if (isWidget(options)) { |
|
|
|
|
context = options; |
|
|
|
|
options = {}; |
|
|
|
|
} else { |
|
|
|
@ -445,9 +446,9 @@
|
|
|
|
|
|
|
|
|
|
var el, w; |
|
|
|
|
if (item.type || options.type) { |
|
|
|
|
el = BI.extend({}, options, item); |
|
|
|
|
el = extend({}, options, item); |
|
|
|
|
} else if (item.el && (item.el.type || options.type)) { |
|
|
|
|
el = BI.extend({}, options, item.el); |
|
|
|
|
el = extend({}, options, item.el); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (el) { |
|
|
|
@ -456,14 +457,14 @@
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 先把准备环境准备好
|
|
|
|
|
BI.init(); |
|
|
|
|
init(); |
|
|
|
|
|
|
|
|
|
if (BI.isEmpty(item) && BI.isEmpty(options)) { |
|
|
|
|
return BI.createWidget({ |
|
|
|
|
if (isEmpty(item) && isEmpty(options)) { |
|
|
|
|
return createWidget({ |
|
|
|
|
type: "bi.layout" |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if (BI.isWidget(item)) { |
|
|
|
|
if (isWidget(item)) { |
|
|
|
|
return item; |
|
|
|
|
} |
|
|
|
|
if (el) { |
|
|
|
@ -471,56 +472,59 @@
|
|
|
|
|
var wType = (w.type && w.type.xtype) || w.type; |
|
|
|
|
if (wType === elType) { |
|
|
|
|
if (BI.Plugin.hasObject(elType)) { |
|
|
|
|
if (!w.listeners || BI.isArray(w.listeners)) { |
|
|
|
|
if (!w.listeners || isArray(w.listeners)) { |
|
|
|
|
w.listeners = (w.listeners || []).concat([{ |
|
|
|
|
eventName: BI.Events.MOUNT, |
|
|
|
|
action: function () { |
|
|
|
|
action: () => { |
|
|
|
|
BI.Plugin.getObject(elType, this); |
|
|
|
|
} |
|
|
|
|
}]); |
|
|
|
|
} else { |
|
|
|
|
w.listeners[BI.Events.MOUNT] = [ |
|
|
|
|
function () { |
|
|
|
|
() => { |
|
|
|
|
BI.Plugin.getObject(elType, this); |
|
|
|
|
} |
|
|
|
|
].concat(w.listeners[BI.Events.MOUNT] || []); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return createWidget(w, context, lazy); |
|
|
|
|
return createRealWidget(w, context, lazy); |
|
|
|
|
} |
|
|
|
|
return BI.createWidget(w, options, context, lazy); |
|
|
|
|
return createWidget(w, options, context, lazy); |
|
|
|
|
} |
|
|
|
|
if (BI.isWidget(item.el)) { |
|
|
|
|
if (isWidget(item.el)) { |
|
|
|
|
return item.el; |
|
|
|
|
} |
|
|
|
|
throw new Error("组件:无法根据item创建组件", item); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.createWidget = BI.createWidget || createWidget; |
|
|
|
|
|
|
|
|
|
BI._lazyCreateWidget = BI._lazyCreateWidget || function (item, options, context) { |
|
|
|
|
return BI.createWidget(item, options, context, true); |
|
|
|
|
}; |
|
|
|
|
export function _lazyCreateWidget (item, options, context) { |
|
|
|
|
return createWidget(item, options, context, true); |
|
|
|
|
} |
|
|
|
|
BI._lazyCreateWidget = BI._lazyCreateWidget || _lazyCreateWidget; |
|
|
|
|
|
|
|
|
|
BI.createElement = BI.createElement || function () { |
|
|
|
|
var widget = BI.createWidget.apply(this, arguments); |
|
|
|
|
export function createElement() { |
|
|
|
|
const widget = createWidget.apply(this, arguments); |
|
|
|
|
return widget.element; |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
BI.createElement = BI.createElement || createElement; |
|
|
|
|
|
|
|
|
|
BI.getResource = BI.getResource || function (type, config) { |
|
|
|
|
if (BI.isNotNull(constantInjection[type])) { |
|
|
|
|
return BI.Constants.getConstant(type); |
|
|
|
|
export function getResource(type, config) { |
|
|
|
|
if (isNotNull(constantInjection[type])) { |
|
|
|
|
return Constants.getConstant(type); |
|
|
|
|
} |
|
|
|
|
if (modelInjection[type]) { |
|
|
|
|
return BI.Models.getModel(type, config); |
|
|
|
|
return Models.getModel(type, config); |
|
|
|
|
} |
|
|
|
|
if (storeInjection[type]) { |
|
|
|
|
return BI.Stores.getStore(type, config); |
|
|
|
|
return Stores.getStore(type, config); |
|
|
|
|
} |
|
|
|
|
if (serviceInjection[type]) { |
|
|
|
|
return BI.Services.getService(type, config); |
|
|
|
|
return Services.getService(type, config); |
|
|
|
|
} |
|
|
|
|
if (providerInjection[type]) { |
|
|
|
|
return BI.Providers.getProvider(type, config); |
|
|
|
|
return Providers.getProvider(type, config); |
|
|
|
|
} |
|
|
|
|
throw new Error("未知类型: [" + type + "] 未定义"); |
|
|
|
|
}; |
|
|
|
|
})(); |
|
|
|
|
} |
|
|
|
|
BI.getResource = BI.getResource || getResource; |
|
|
|
|