|
|
@ -1,9 +1,30 @@ |
|
|
|
(function () { |
|
|
|
(function () { |
|
|
|
var moduleInjection = {}; |
|
|
|
var moduleInjection = {}, moduleInjectionMap = { |
|
|
|
|
|
|
|
components: {}, |
|
|
|
|
|
|
|
constants: {}, |
|
|
|
|
|
|
|
stores: {}, |
|
|
|
|
|
|
|
services: {}, |
|
|
|
|
|
|
|
models: {}, |
|
|
|
|
|
|
|
providers: {} |
|
|
|
|
|
|
|
}; |
|
|
|
BI.module = BI.module || function (xtype, cls) { |
|
|
|
BI.module = BI.module || function (xtype, cls) { |
|
|
|
if (moduleInjection[xtype] != null) { |
|
|
|
if (moduleInjection[xtype] != null) { |
|
|
|
_global.console && console.error("module: [" + xtype + "] 已经注册过了"); |
|
|
|
_global.console && console.error("module: [" + xtype + "] 已经注册过了"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var key; |
|
|
|
|
|
|
|
for (var k in moduleInjectionMap) { |
|
|
|
|
|
|
|
if(cls[k]){ |
|
|
|
|
|
|
|
for (key in cls[k]) { |
|
|
|
|
|
|
|
if (!moduleInjectionMap[k][key]) { |
|
|
|
|
|
|
|
moduleInjectionMap[k][key] = []; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
moduleInjectionMap[k][key].push({ |
|
|
|
|
|
|
|
version: cls[k][key], |
|
|
|
|
|
|
|
moduleId: xtype |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
moduleInjection[xtype] = cls; |
|
|
|
moduleInjection[xtype] = cls; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -49,7 +70,9 @@ |
|
|
|
|
|
|
|
|
|
|
|
var configFunctions = {}; |
|
|
|
var configFunctions = {}; |
|
|
|
BI.config = BI.config || function (type, configFn, opt) { |
|
|
|
BI.config = BI.config || function (type, configFn, opt) { |
|
|
|
if (BI.initialized) { |
|
|
|
opt = opt || {}; |
|
|
|
|
|
|
|
// 初始化过或者系统配置需要立刻执行
|
|
|
|
|
|
|
|
if (BI.initialized || "bi.provider.system" === type) { |
|
|
|
if (constantInjection[type]) { |
|
|
|
if (constantInjection[type]) { |
|
|
|
return (constantInjection[type] = configFn(constantInjection[type])); |
|
|
|
return (constantInjection[type] = configFn(constantInjection[type])); |
|
|
|
} |
|
|
|
} |
|
|
@ -69,9 +92,40 @@ |
|
|
|
configFunctions[type] = []; |
|
|
|
configFunctions[type] = []; |
|
|
|
BI.prepares.push(function () { |
|
|
|
BI.prepares.push(function () { |
|
|
|
var queue = configFunctions[type]; |
|
|
|
var queue = configFunctions[type]; |
|
|
|
|
|
|
|
var dependencies = BI.Providers.getProvider("bi.provider.system").getDependencies(); |
|
|
|
|
|
|
|
var 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++) { |
|
|
|
for (var i = 0; i < queue.length; i++) { |
|
|
|
|
|
|
|
var conf = queue[i]; |
|
|
|
|
|
|
|
var version = conf.opt.version; |
|
|
|
|
|
|
|
var fn = conf.fn; |
|
|
|
|
|
|
|
if(modules && version) { |
|
|
|
|
|
|
|
var findVersion = false; |
|
|
|
|
|
|
|
for (var j = 0; j < modules.length; j++) { |
|
|
|
|
|
|
|
var module = modules[i]; |
|
|
|
|
|
|
|
if (module && dependencies[module.moduleId] && module.version === version) { |
|
|
|
|
|
|
|
var min = dependencies[module.moduleId].min, max = dependencies[module.moduleId].max; |
|
|
|
|
|
|
|
if (min && module.version < min){ |
|
|
|
|
|
|
|
findVersion = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(max && module.version > max){ |
|
|
|
|
|
|
|
findVersion = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(findVersion === true){ |
|
|
|
|
|
|
|
_global.console && console.error("module: [" + type + "] 版本: [" + module.version + "] 已过期"); |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (constantInjection[type]) { |
|
|
|
if (constantInjection[type]) { |
|
|
|
constantInjection[type] = queue[i](constantInjection[type]); |
|
|
|
constantInjection[type] = fn(constantInjection[type]); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if (providerInjection[type]) { |
|
|
|
if (providerInjection[type]) { |
|
|
@ -81,15 +135,18 @@ |
|
|
|
if (providerInstance[type]) { |
|
|
|
if (providerInstance[type]) { |
|
|
|
delete providerInstance[type]; |
|
|
|
delete providerInstance[type]; |
|
|
|
} |
|
|
|
} |
|
|
|
queue[i](providers[type]); |
|
|
|
fn(providers[type]); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
BI.Plugin.configWidget(type, queue[i]); |
|
|
|
BI.Plugin.configWidget(type, fn); |
|
|
|
} |
|
|
|
} |
|
|
|
configFunctions[type] = null; |
|
|
|
configFunctions[type] = null; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
configFunctions[type].push(configFn); |
|
|
|
configFunctions[type].push({ |
|
|
|
|
|
|
|
fn: configFn, |
|
|
|
|
|
|
|
opt: opt |
|
|
|
|
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
BI.getReference = BI.getReference || function (type, fn) { |
|
|
|
BI.getReference = BI.getReference || function (type, fn) { |
|
|
|