Browse Source

优化一下

es6
guy 3 years ago
parent
commit
a0cb462ae3
  1. 18
      src/core/6.inject.js

18
src/core/6.inject.js

@ -13,8 +13,11 @@
} }
var key; var key;
for (var k in moduleInjectionMap) { for (var k in moduleInjectionMap) {
if(cls[k]){ if (cls[k]) {
for (key in cls[k]) { for (key in cls[k]) {
if (!moduleInjectionMap[k]) {
continue;
}
if (!moduleInjectionMap[k][key]) { if (!moduleInjectionMap[k][key]) {
moduleInjectionMap[k][key] = []; moduleInjectionMap[k][key] = [];
} }
@ -103,24 +106,25 @@
var conf = queue[i]; var conf = queue[i];
var version = conf.opt.version; var version = conf.opt.version;
var fn = conf.fn; var fn = conf.fn;
if(modules && version) { if (modules && version) {
var findVersion = false; var findVersion = false;
for (var j = 0; j < modules.length; j++) { for (var j = 0; j < modules.length; j++) {
var module = modules[i]; var module = modules[i];
if (module && dependencies[module.moduleId] && module.version === version) { if (module && dependencies[module.moduleId] && module.version === version) {
var minVersion = dependencies[module.moduleId].minVersion, maxVersion = dependencies[module.moduleId].maxVersion; var minVersion = dependencies[module.moduleId].minVersion,
if (minVersion && (moduleInjection[module.moduleId].version || version) < minVersion){ maxVersion = dependencies[module.moduleId].maxVersion;
if (minVersion && (moduleInjection[module.moduleId].version || version) < minVersion) {
findVersion = true; findVersion = true;
break; break;
} }
if(maxVersion && (moduleInjection[module.moduleId].version || version) > maxVersion){ if (maxVersion && (moduleInjection[module.moduleId].version || version) > maxVersion) {
findVersion = true; findVersion = true;
break; break;
} }
} }
} }
if(findVersion === true){ if (findVersion === true) {
_global.console && console.error("module: [" + type + "] 版本: [" + module.version + "] 已过期"); _global.console && console.error("moduleId: [" + module.moduleId + "] 服务: [" + type + "] 版本: [" + module.version + "] 已过期", modelInjection[module.moduleId]);
continue; continue;
} }
} }

Loading…
Cancel
Save