efront 3.9.0 → 3.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/pivot/api.yml +1 -0
- package/apps/pivot/auth/login.js +3 -6
- package/apps/pivot/home/welcome.html +5 -0
- package/apps/pivot/home/welcome.js +1 -0
- package/apps/pivot/main.js +7 -0
- package/apps/pivot/task/invoke.html +1 -1
- package/apps/pivot/task/invoke.js +15 -7
- package/apps/pivot/task/invoke.less +13 -0
- package/coms/crypt/encode62.js +1 -1
- package/coms/layer/glance.less +2 -0
- package/coms/zimoli/data.js +11 -11
- package/coms/zimoli/encode62.js +1 -1
- package/coms/zimoli/zimoli.js +33 -27
- package/package.json +1 -1
- package/public/efront.js +1 -1
package/apps/pivot/api.yml
CHANGED
package/apps/pivot/auth/login.js
CHANGED
|
@@ -13,7 +13,8 @@ function main() {
|
|
|
13
13
|
});
|
|
14
14
|
renderWithDefaults(page, {
|
|
15
15
|
fields, data: {
|
|
16
|
-
host: location.host,
|
|
16
|
+
host: data.getInstance("base").host || location.host,
|
|
17
|
+
|
|
17
18
|
}, pending: false
|
|
18
19
|
});
|
|
19
20
|
on("submit")(page, async function () {
|
|
@@ -24,14 +25,10 @@ function main() {
|
|
|
24
25
|
try {
|
|
25
26
|
var login = await data.getApi("login");
|
|
26
27
|
login.base = location.protocol + "//" + parseURL(this.$scope.data.host).host + "/";
|
|
27
|
-
|
|
28
|
+
data.setInstance("base", { base: login.base, host: parseURL(login.base).host });
|
|
28
29
|
var info = await data.from(login, {
|
|
29
30
|
a: encode62.timeencode(encode62.geta(password))
|
|
30
31
|
}).loading_promise;
|
|
31
|
-
var apimap = await data.getConfig();
|
|
32
|
-
for (var k in apimap) {
|
|
33
|
-
apimap[k].base = login.base;
|
|
34
|
-
}
|
|
35
32
|
info = encode62.timeupdate(info);
|
|
36
33
|
data.setSource({ authorization: info });
|
|
37
34
|
user.login({})
|
package/apps/pivot/main.js
CHANGED
|
@@ -4,6 +4,13 @@ var token = data.getSource('authorization');
|
|
|
4
4
|
if (token) {
|
|
5
5
|
user.login({});
|
|
6
6
|
}
|
|
7
|
+
data.bindInstance("base", async function (base) {
|
|
8
|
+
cross.addDirect(base.base);
|
|
9
|
+
var apimap = await data.getConfig();
|
|
10
|
+
for (var k in apimap) {
|
|
11
|
+
apimap[k].base = base.base;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
7
14
|
setInterval(function () {
|
|
8
15
|
var auth = data.getSource('authorization');
|
|
9
16
|
if (!auth) return;
|
|
@@ -3,7 +3,7 @@ function main(a) {
|
|
|
3
3
|
page.innerHTML = template;
|
|
4
4
|
drag.on(page.firstChild, page);
|
|
5
5
|
var fields = data.from("params", { key: a.key }, function (a) {
|
|
6
|
-
return JSON.parse(encode62.timedecode(a));
|
|
6
|
+
return a ? JSON.parse(encode62.timedecode(a)) : [];
|
|
7
7
|
});
|
|
8
8
|
var taskid = 0;
|
|
9
9
|
renderWithDefaults(page, {
|
|
@@ -14,16 +14,24 @@ function main(a) {
|
|
|
14
14
|
fields: fields,
|
|
15
15
|
task: a,
|
|
16
16
|
output: '',
|
|
17
|
+
error: false,
|
|
17
18
|
async run() {
|
|
18
19
|
var id = ++taskid;
|
|
20
|
+
this.output = "正在执行..";
|
|
21
|
+
this.error = false;
|
|
19
22
|
var params = JSON.stringify(this.data);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
try {
|
|
24
|
+
var res = await data.from("invoke", { key: a.key, params: encode62.timeencode(params) }, function (a) {
|
|
25
|
+
return a ? encode62.timedecode(a) : '完成!';
|
|
26
|
+
});
|
|
27
|
+
if (id !== taskid) return;
|
|
28
|
+
this.output = res;
|
|
29
|
+
} catch (e) {
|
|
30
|
+
this.output = String(e);
|
|
31
|
+
this.error = true;
|
|
32
|
+
}
|
|
26
33
|
}
|
|
27
34
|
});
|
|
35
|
+
resize.on(page);
|
|
28
36
|
return page;
|
|
29
37
|
}
|
|
@@ -7,4 +7,17 @@
|
|
|
7
7
|
display: inline-block;
|
|
8
8
|
width: 50%;
|
|
9
9
|
vertical-align: top;
|
|
10
|
+
overflow: auto;
|
|
11
|
+
font-size: 12px;
|
|
12
|
+
border-bottom: 50px solid transparent;
|
|
13
|
+
padding: 0 10px;
|
|
14
|
+
|
|
15
|
+
&.right {
|
|
16
|
+
background: #000;
|
|
17
|
+
color: #fff;
|
|
18
|
+
height: 100%;
|
|
19
|
+
}
|
|
20
|
+
&.error{
|
|
21
|
+
color: #c26;
|
|
22
|
+
}
|
|
10
23
|
}
|
package/coms/crypt/encode62.js
CHANGED
|
@@ -43,7 +43,7 @@ Object.assign(encode62, {
|
|
|
43
43
|
var time_rest = time_stamp % time_delta;
|
|
44
44
|
var time_rest_str = time_rest.toString(36);
|
|
45
45
|
var time_delta_str = time_delta.toString(36);
|
|
46
|
-
string = encodeURIComponent(string).replace(/\./g, '..').replace(/%/g, '.');
|
|
46
|
+
string = encodeURIComponent(string).replace(/\./g, '..').replace(/[\!'\(\)~]/g, a => escape(a)).replace(/%/g, '.');
|
|
47
47
|
return this.encode62(string, time_stamp.toString(36)) + repeat("0", time_delta_str.length - time_rest_str.length) + time_rest_str;
|
|
48
48
|
},
|
|
49
49
|
timeupdate(string) {
|
package/coms/layer/glance.less
CHANGED
package/coms/zimoli/data.js
CHANGED
|
@@ -73,7 +73,7 @@ const formulaters = {
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
function getErrorMessage(error) {
|
|
76
|
+
function getErrorMessage(error = this) {
|
|
77
77
|
if (!isObject(error)) return String(error);
|
|
78
78
|
if (error instanceof Error) return String(error);
|
|
79
79
|
var words = "reason,message,desc,descption,msg,err,error,data".split(',');
|
|
@@ -550,7 +550,7 @@ var privates = {
|
|
|
550
550
|
}).error(xhr => {
|
|
551
551
|
try {
|
|
552
552
|
var e = getErrorMessage(parseData(xhr.response || xhr.responseText || xhr.statusText || xhr.status));
|
|
553
|
-
oh({ status: xhr.status, error: e })
|
|
553
|
+
oh({ status: xhr.status, error: e, toString: getErrorMessage })
|
|
554
554
|
} catch (error) {
|
|
555
555
|
oh(error);
|
|
556
556
|
}
|
|
@@ -621,7 +621,7 @@ function responseCrash(e, data) {
|
|
|
621
621
|
}
|
|
622
622
|
error_report(data.error_message, e.status < 500 ? 'warn' : 'error');
|
|
623
623
|
}
|
|
624
|
-
|
|
624
|
+
var getData = function () { return this.data };
|
|
625
625
|
var data = {
|
|
626
626
|
decodeStructure,
|
|
627
627
|
encodeStructure,
|
|
@@ -898,12 +898,11 @@ var data = {
|
|
|
898
898
|
getInstance(instanceId, onlyFromLocalStorage = false) {
|
|
899
899
|
if (!instanceDataMap[instanceId]) {
|
|
900
900
|
var data = getItem(instanceId, onlyFromLocalStorage);
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
instanceDataMap[instanceId] = data;
|
|
901
|
+
var instance = new LoadingArray;
|
|
902
|
+
this.rebuildInstance(instance, data);
|
|
903
|
+
instance.is_loading = false;
|
|
904
|
+
instance.is_loaded = true;
|
|
905
|
+
instanceDataMap[instanceId] = instance;
|
|
907
906
|
}
|
|
908
907
|
return instanceDataMap[instanceId];
|
|
909
908
|
|
|
@@ -947,7 +946,7 @@ var data = {
|
|
|
947
946
|
*/
|
|
948
947
|
setInstance(instanceId, data, rememberWithStorage = 0) {
|
|
949
948
|
const instance = this.getInstance(instanceId);
|
|
950
|
-
if (isObject(
|
|
949
|
+
if (isObject(instance)) {
|
|
951
950
|
this.rebuildInstance(instance, data);
|
|
952
951
|
} else {
|
|
953
952
|
instanceDataMap[instanceId] = data;
|
|
@@ -1005,7 +1004,8 @@ var data = {
|
|
|
1005
1004
|
},
|
|
1006
1005
|
rebuildInstance(instance, data, old = instance) {
|
|
1007
1006
|
if (instance === data) return;
|
|
1008
|
-
if (!isObject(instance)
|
|
1007
|
+
if (!isObject(instance)) throw new Error("只支持object类型的数据!");
|
|
1008
|
+
if (!isObject(data)) data = { data }, data.toString = data.valueOf = getData;
|
|
1009
1009
|
if (instance instanceof Array) instance.splice(0, instance.length);
|
|
1010
1010
|
var sample = new LoadingArray;
|
|
1011
1011
|
Object.keys(old).forEach(function (k) {
|
package/coms/zimoli/encode62.js
CHANGED
|
@@ -33,7 +33,7 @@ var encode62 = {
|
|
|
33
33
|
var time_rest = time_stamp % time_delta;
|
|
34
34
|
var time_rest_str = time_rest.toString(36);
|
|
35
35
|
var time_delta_str = time_delta.toString(36);
|
|
36
|
-
string = encodeURIComponent(string).replace(/\./g, '..').replace(/%/g, '.');
|
|
36
|
+
string = encodeURIComponent(string).replace(/\./g, '..').replace(/[\!'\(\)~]/g, a => escape(a)).replace(/%/g, '.');
|
|
37
37
|
return this.encode(string, time_stamp.toString(36)) + repeat("0", time_delta_str.length - time_rest_str.length) + time_rest_str;
|
|
38
38
|
},
|
|
39
39
|
timeupdate(string) {
|
package/coms/zimoli/zimoli.js
CHANGED
|
@@ -185,32 +185,8 @@ var loading_tree = {};
|
|
|
185
185
|
var getpgpath = function (pagepath) {
|
|
186
186
|
return /^[@#!]/.test(pagepath) ? pagepath.slice(1) : pagepath;
|
|
187
187
|
};
|
|
188
|
-
function
|
|
188
|
+
function createState(pgpath) {
|
|
189
189
|
var pgpath = getpgpath(pgpath);
|
|
190
|
-
if (page_generators[pgpath]) {
|
|
191
|
-
if (isFunction(ok)) {
|
|
192
|
-
var res = page_generators[pgpath];
|
|
193
|
-
if (!res.roles) {
|
|
194
|
-
ok(res);
|
|
195
|
-
} else {
|
|
196
|
-
prepare(user.loginPath, _ => {
|
|
197
|
-
ok(res);
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (loading_tree[pgpath]) {
|
|
204
|
-
if (isFunction(ok)) {
|
|
205
|
-
loading_tree[pgpath].push(ok);
|
|
206
|
-
}
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
loading_tree[pgpath] = [];
|
|
210
|
-
if (isFunction(ok)) {
|
|
211
|
-
loading_tree[pgpath].push(ok);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
190
|
var _zimoli_state_key = _zimoli_state_prefix + pgpath;
|
|
215
191
|
var state = function state(condition, setAsAdditional = condition !== null) {
|
|
216
192
|
var state_string = hostoryStorage.getItem(_zimoli_state_key);
|
|
@@ -242,6 +218,34 @@ function prepare(pgpath, ok) {
|
|
|
242
218
|
}
|
|
243
219
|
return state_object;
|
|
244
220
|
};
|
|
221
|
+
return state;
|
|
222
|
+
}
|
|
223
|
+
function prepare(pgpath, ok) {
|
|
224
|
+
var pgpath = getpgpath(pgpath);
|
|
225
|
+
if (page_generators[pgpath]) {
|
|
226
|
+
if (isFunction(ok)) {
|
|
227
|
+
var res = page_generators[pgpath];
|
|
228
|
+
if (!res.roles) {
|
|
229
|
+
ok(res);
|
|
230
|
+
} else {
|
|
231
|
+
prepare(user.loginPath, _ => {
|
|
232
|
+
ok(res);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (loading_tree[pgpath]) {
|
|
239
|
+
if (isFunction(ok)) {
|
|
240
|
+
loading_tree[pgpath].push(ok);
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
loading_tree[pgpath] = [];
|
|
245
|
+
if (isFunction(ok)) {
|
|
246
|
+
loading_tree[pgpath].push(ok);
|
|
247
|
+
}
|
|
248
|
+
var state = createState(pgpath);
|
|
245
249
|
state.state = state;
|
|
246
250
|
var _with_elements = [];
|
|
247
251
|
state.with = function (element) {
|
|
@@ -299,6 +303,7 @@ function prepare(pgpath, ok) {
|
|
|
299
303
|
return Promise.resolve(res);
|
|
300
304
|
};
|
|
301
305
|
});
|
|
306
|
+
|
|
302
307
|
var prepares = [];
|
|
303
308
|
state.prepare = state.go.prepare = function (urls) {
|
|
304
309
|
prepares.push.apply(prepares, [].concat(urls).map(state.path));
|
|
@@ -352,8 +357,8 @@ function prepare(pgpath, ok) {
|
|
|
352
357
|
delete loading_tree[pgpath];
|
|
353
358
|
};
|
|
354
359
|
return init(pgpath, function (pg) {
|
|
355
|
-
|
|
356
360
|
if (!pg) return;
|
|
361
|
+
extendIfNeeded(pg, state);
|
|
357
362
|
if (roles) return prepare(user.loginPath, () => emit(pg));
|
|
358
363
|
emit(pg);
|
|
359
364
|
}, state);
|
|
@@ -654,4 +659,5 @@ zimoli.clearHistory = function () {
|
|
|
654
659
|
zimoli.getCurrentHistory = function () {
|
|
655
660
|
return history[current_history];
|
|
656
661
|
};
|
|
657
|
-
zimoli.inithash = locationInitHash;
|
|
662
|
+
zimoli.inithash = locationInitHash;
|
|
663
|
+
zimoli.createState = createState;
|