efront 3.6.0 → 3.7.0

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.
@@ -4,3 +4,5 @@
4
4
  share: options ::share-:opt?:path
5
5
  folder: options ::file-:opt:::path?:to
6
6
  cluster: options ::cluster-:opt?:id
7
+ private-list: options ::private
8
+ private-edit: options ::private-:key?:value
@@ -1,4 +1,3 @@
1
-
2
1
  <div>
3
2
  已登录到服务器,您可以进行如下操作
4
3
  </div>
@@ -7,6 +6,11 @@
7
6
  清理服务器缓存 <btn @click="run('clear-cache',this)">清理</btn>
8
7
  </padding>
9
8
  </block>
9
+ <block>
10
+ <padding>
11
+ 重启服务器 <btn @click="run('rehost',this)" type="danger">重启</btn>
12
+ </padding>
13
+ </block>
10
14
  <block>
11
15
  <padding>
12
16
  退出登录 <btn @click="logout()">退出</btn>
@@ -16,6 +16,9 @@ var layer = layer$glance({
16
16
  left: frame$left,
17
17
  top: frame$top
18
18
  });
19
+ on("append")(layer, function () {
20
+ frame$route.open();
21
+ });
19
22
  function main() {
20
23
  return layer;
21
24
  }
@@ -3,4 +3,5 @@
3
3
  短链接: /home/short
4
4
  WEB文件管理: /wow/root
5
5
  长连接管理: /link/list
6
+ 密钥管理: /token/list
6
7
  # 用户列表: /user/list
@@ -0,0 +1,9 @@
1
+ frame$edit.bind(null, "密钥", {
2
+ submit(a) {
3
+ return data.from("private-edit", {
4
+ key: encode62.timeencode(a.key),
5
+ value: encode62.timeencode(JSON.stringify(a)),
6
+ }).loading_promise;
7
+ },
8
+
9
+ });
@@ -0,0 +1,13 @@
1
+ frame$list.bind(null, "密钥管理", {
2
+ load() {
3
+ return data.from("private-list", a => JSAM.parse(encode62.timedecode(a)));
4
+ },
5
+ remove(o) {
6
+ return data.from("private-edit", { key: encode62.timeencode(o.key), value: encode62.timeencode("") }).loading_promise;
7
+ },
8
+ fields: refilm`
9
+ 显示名/name input
10
+ *键名/key
11
+ 密钥/value
12
+ 备注/comment
13
+ `}, "/token/edit");
@@ -521,39 +521,63 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
521
521
  return exec.apply(_this, args);
522
522
  });
523
523
  };
524
- var bindthen = function (callback) {
525
- return function (data) {
526
- if (Promise && data instanceof Promise) {
527
- data.then(callback);
528
- } else {
529
- callback(data);
530
- }
531
- };
532
- };
533
-
534
524
 
535
525
  var init = function (name, then, prebuilds) {
536
- then = bindthen(then);
526
+ // then = bindthen(then);
537
527
  var key = keyprefix + name;
538
528
  if (prebuilds) {
539
529
  if (name in prebuilds) {
540
- return then(prebuilds[name]);
530
+ if (then) then(prebuilds[name]);
531
+ return prebuilds[name];
541
532
  }
542
533
  }
543
534
  if (hasOwnProperty.call(modules, name)) {
544
- then(modules[name]);
545
- return;
535
+ if (then) then(modules[name]);
536
+ return modules[name];
546
537
  }
547
538
  if (window[name] !== null && window[name] !== void 0 && !hasOwnProperty.call(forceRequest, name)) {
548
- then(modules[name] = window[name]);
549
- return;
539
+ modules[name] = window[name]
540
+ if (then) then(modules[name]);
541
+ return modules[name];
550
542
  }
543
+ var oks = [];
544
+ if (then) oks.push(then);
545
+ var ohs = [];
546
+ var res = {
547
+ oks,
548
+ ohs,
549
+ resolved: null,
550
+ errored: null,
551
+ then(ok, oh) {
552
+ if (ok) this.oks.push(ok);
553
+ if (oh) this.ohs.push(oh);
554
+ this.fire();
555
+ },
556
+ fire() {
557
+ if (this.resolved || this.errored) {
558
+ var oks = this.oks.splice(0, this.oks.length);
559
+ var ohs = this.ohs.splice(0, this.ohs.length);
560
+ if (this.resolved) for (var o of oks) o(this.resolved);
561
+ if (this.errored) for (var o of ohs) o(this.errored);
562
+ }
563
+ },
564
+ };
565
+ then = function (created) {
566
+ if (Promise && created instanceof Promise) return created.then(then, crack);
567
+ res.resolved = created;
568
+ res.fire();
569
+ };
570
+ var crack = function (error) {
571
+ res.errored = error;
572
+ res.fire();
573
+ };
551
574
  loadModule(name, function (error) {
552
575
  if (hasOwnProperty.call(modules, name)) {
553
576
  then(modules[name]);
554
577
  return;
555
578
  }
556
- if (error) return;
579
+ if (error) return crack(error);
580
+
557
581
  var module = loadedModules[key];
558
582
  var args = module.args || [];
559
583
 
@@ -593,6 +617,7 @@ var init = function (name, then, prebuilds) {
593
617
 
594
618
  then(created);
595
619
  }, prebuilds);
620
+ return res;
596
621
  };
597
622
  var forceRequest = {};
598
623
  var removeGlobalProperty = function (property) {
@@ -31,7 +31,8 @@ Object.assign(encode62, {
31
31
  var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
32
32
  var time_start = parseInt((new Date() - parseInt(time_rest, 36)) / time_delta) * time_delta;
33
33
  var time_stamp = time_start + parseInt(time_rest, 36);
34
- return this.decode62(string.slice(0, string.length - time_delta.toString(36).length), time_stamp.toString(36));
34
+ string = this.decode62(string.slice(0, string.length - time_delta.toString(36).length), time_stamp.toString(36)).replace(/\.\.?/g, a => a === '.' ? "%" : ".");
35
+ return decodeURIComponent(string);
35
36
  },
36
37
  timeencode(string) {
37
38
  var { time_delta } = this;
@@ -40,6 +41,7 @@ Object.assign(encode62, {
40
41
  var time_rest = time_stamp % time_delta;
41
42
  var time_rest_str = time_rest.toString(36);
42
43
  var time_delta_str = time_delta.toString(36);
44
+ string = encodeURIComponent(string).replace(/\./g, '..').replace(/%/g, '.');
43
45
  return this.encode62(string, time_stamp.toString(36)) + repeat("0", time_delta_str.length - time_rest_str.length) + time_rest_str;
44
46
  },
45
47
  timeupdate(string) {
@@ -0,0 +1,10 @@
1
+ <div head>
2
+ <span v-text="origin?'修改':'添加'"></span><span -text="title"></span>
3
+ </div>
4
+ <div body>
5
+ <field v-if="!f.readonly||!!data[f.key]" -repeat="f in fields" ng-src="[f,data]"></field>
6
+ </div>
7
+ <div foot>
8
+ <btn @click="remove()" class="white">取消</btn>
9
+ <button type="submit">保存</button>
10
+ </div>
@@ -0,0 +1,29 @@
1
+ function main(title, { submit }, { data: origin, fields, }) {
2
+ var page = view();
3
+ var item = Object.assign({}, origin);
4
+ page.innerHTML = edit;
5
+ drag.on(page.firstChild, page);
6
+ resize.on(page);
7
+ page.onback = function () {
8
+ return false;
9
+ };
10
+ renderWithDefaults(page, {
11
+ fields,
12
+ title,
13
+ origin: item,
14
+ data: item,
15
+ remove() {
16
+ remove(page);
17
+ },
18
+ });
19
+ on('submit')(page, async function (e) {
20
+ e.preventDefault();
21
+ await submit(item);
22
+ dispatch(this, 'submited');
23
+ remove(this);
24
+ });
25
+ on("append")(page, lazy(function () {
26
+ page.querySelector("input").focus();
27
+ }));
28
+ return page;
29
+ }
File without changes
@@ -0,0 +1,4 @@
1
+ <div>
2
+ <btn @click="add()">添加</btn>
3
+ </div>
4
+ <table -src="[fields,data]"></table>
@@ -0,0 +1,64 @@
1
+ function main(title, { fields, load, remove }, edit_ref) {
2
+ prepare(edit_ref);
3
+ var page = document.createElement("div");
4
+ var edit = function (o) {
5
+ zimoli.prepare(edit_ref, function () {
6
+ var p = popup(edit_ref, { fields, data: o })
7
+ on("submited")(p, function () {
8
+ console.log("submited")
9
+ page.$scope.load();
10
+ })
11
+ })
12
+ };
13
+ page.innerHTML = template;
14
+ renderWithDefaults(page, {
15
+ title,
16
+ load() {
17
+ this.data = load();
18
+ },
19
+ fields: fields.concat({
20
+ name: "操作",
21
+ options: [
22
+ {
23
+ name: "修改",
24
+ do(o) {
25
+ edit(o);
26
+ },
27
+ },
28
+ {
29
+ type: "danger",
30
+ name(o) {
31
+ return this.confirm === o ? "确认删除" : "删除";
32
+ },
33
+ type(o) {
34
+ return this.confirm === o ? "dark" : "danger";
35
+ },
36
+ confirm: false,
37
+ timer: 0,
38
+ async do(o) {
39
+ if (this.confirm !== o) {
40
+ this.confirm = o;
41
+ clearTimeout(this.timer);
42
+ var that = this;
43
+ this.timer = setTimeout(function () {
44
+ that.confirm = null;
45
+ render.refresh();
46
+ }, 2000);
47
+ return;
48
+ }
49
+ await remove(o);
50
+ page.$scope.load();
51
+ }
52
+ }
53
+ ]
54
+ }),
55
+ data: [],
56
+ add() {
57
+ edit();
58
+ },
59
+ });
60
+ on("append")(page, function () {
61
+ page.$scope.load();
62
+ });
63
+ return page;
64
+ }
@@ -0,0 +1,3 @@
1
+ btn{
2
+ padding: 0 16px;
3
+ }
@@ -8,4 +8,7 @@ class LoadingArray extends Array {
8
8
  is_readonly = null;
9
9
  loading = null;
10
10
  loading_promise = null;
11
+ then(ok, oh) {
12
+ if (this.loading_promise) this.loading_promise.then(ok, oh);
13
+ }
11
14
  }
@@ -434,8 +434,6 @@ var privates = {
434
434
  let url = api.url;
435
435
  var base = api.base;
436
436
  if (base) url = base + api.path;
437
- console.log(url, base);
438
-
439
437
  if (this.validApi(api, params)) {
440
438
  params = this.repare(api, params);
441
439
  return this.loadIgnoreConfig(api.method, url, params, api);
@@ -23,8 +23,8 @@ var encode62 = {
23
23
  var time_rest = string.slice(string.length - time_delta.toString(36).length, string.length);
24
24
  var time_start = parseInt((new Date() - parseInt(time_rest, 36)) / time_delta) * time_delta;
25
25
  var time_stamp = time_start + parseInt(time_rest, 36);
26
-
27
- return this.encode(string.slice(0, string.length - time_delta.toString(36).length), time_stamp.toString(36));
26
+ string = this.encode(string.slice(0, string.length - time_delta.toString(36).length), time_stamp.toString(36)).replace(/\.\.?/g, a => a === '.' ? "%" : ".");
27
+ return decodeURIComponent(string);
28
28
  },
29
29
  timeencode(string) {
30
30
  var { time_delta } = this;
@@ -33,6 +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
37
  return this.encode(string, time_stamp.toString(36)) + repeat("0", time_delta_str.length - time_rest_str.length) + time_rest_str;
37
38
  },
38
39
  timeupdate(string) {
@@ -8,7 +8,8 @@
8
8
  <tr>
9
9
  <td -repeat="f in fields">
10
10
  <span -if="f.key" -text="d[f.key]"></span>
11
- <a on-click="o.do(d)" -if="f.options" _type="o.type" -repeat="o in f.options">
11
+ <a on-click="o.do(d)" -if="f.options" _type="o.type instanceof Function?o.type(d):o.type"
12
+ -repeat="o in f.options">
12
13
  <span -text="o.name instanceof Function?o.name(d):o.name"></span>
13
14
  </a>
14
15
  </td>
@@ -249,11 +249,31 @@ function prepare(pgpath, ok) {
249
249
  return _with_elements;
250
250
  };
251
251
  state.path = function (url) {
252
- if (isString(url) && /^[^\\\/]/.test(url)) {
252
+ if (isString(url) && /^\.+[\\\/]/.test(url)) {
253
+ url = url.replace(/^\.[\\\/]/, '');
253
254
  url = pgpath.replace(/[^\/]*$/, url);
255
+ var ps = url.split(/[\\\/]/);
256
+ var ds = [];
257
+ for (var p of ps) {
258
+ if (p === "..") {
259
+ ds.pop();
260
+ }
261
+ else if (p !== ".") {
262
+ ds.push(p);
263
+ }
264
+ }
265
+ url = ds.join('/');
254
266
  }
255
267
  return url;
256
- }
268
+ };
269
+ state.popup = function (a) {
270
+ a = state.path(a);
271
+ return popup.apply(this, [a].concat([].slice.call(arguments, 1)));
272
+ };
273
+ state.init = function (a) {
274
+ a = state.path(a);
275
+ return init.apply(this, [a].concat([].slice.call(arguments, 1)));
276
+ };
257
277
  state.go = function (url, args, _history_name) {
258
278
  // if (arguments.length === 1 && isFinite(url)) return window_history.go(url | 0);
259
279
  var to = function (_url, args, _history_name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {