index.js
1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
define(["mec/score"], function (score) {
'use strict';
var req = new XMLHttpRequest();
var result;
req.open("GET", "/api/mobilemode/admin/designer/getModelAndViews", false); // 同步请求
req.send(null);
result = JSON.parse(req.responseText).data;
var models = result.models; // 插件
var views = result.views; // 需要特殊处理的插件view
var paths = {}; // 插件路径配置
models.forEach(function (type) {
var modName = "mec/plugin/model/" + type;
var path = "./appdesigner/mec/plugin/model/" + type;
paths[modName] = path;
});
views.forEach(function (type) {
var viewModName = "mec/plugin/view/" + type;
var viewpath = "./appdesigner/mec/plugin/view/" + type;
paths[viewModName] = viewpath;
});
require.config(paths);
// 实例化配置
var ioc = score.init({
controller: "mec/plugin/controller",
model: {
module: function (compType) {
if (!~models.indexOf(compType)) return "mec/plugin/model";
return "mec/plugin/model/" + compType;
},
inherit: "mec/plugin/model"
},
view: {
module: function (compType) {
if (!~views.indexOf(compType)) return "";
return "mec/plugin/view/" + compType;
},
inherit: "mec/plugin/view"
}
});
return ioc;
});