efront 3.5.9 → 3.5.13

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.
@@ -1,5 +1,6 @@
1
1
  ./aapi/ authorization:
2
2
  login: options /::login-:a
3
3
  run: options /:::run
4
- share: options /::share-:opt
4
+ share: options /::share-:opt?:path
5
5
  folder: options /::file-:opt:::path?:to
6
+ cluster: options /::cluster-:opt?:id
@@ -0,0 +1,12 @@
1
+ <div class="clusters">
2
+ <a -repeat="(c,i) in clusters" @click="active(i)">
3
+ <span -text="c"></span>
4
+ </a>
5
+ </div>
6
+ <lattice -src="c in clients">
7
+ <padding>
8
+ <span -text=c.id></span>
9
+ <span class="time" -text=filterTime(c.optime)></span>
10
+
11
+ </padding>
12
+ </lattice>
@@ -0,0 +1,25 @@
1
+ function main() {
2
+ var page = div();
3
+ page.innerHTML = template;
4
+ renderWithDefaults(page, {
5
+ async load() {
6
+ var cs = this.clusters = data.from("cluster", { opt: "list" });
7
+ await cs.loading_promise;
8
+ this.active();
9
+ },
10
+ index: 0,
11
+ clusters: [],
12
+ filterTime(d) {
13
+ return ((new Date - d) / 1000 | 0) + "秒";
14
+ },
15
+ clients: [],
16
+ async active() {
17
+ var index = this.index;
18
+ var clusters = this.clusters;
19
+ if (index >= clusters.length) index = clusters.length - 1;
20
+ this.clients = data.lazyInstance("cluster", { opt: "list", id: clusters[index] });
21
+ },
22
+ });
23
+ page.$scope.load();
24
+ return page;
25
+ }
@@ -0,0 +1,9 @@
1
+ .clusters a {
2
+ display: inline-block;
3
+ margin-right: 20px;
4
+ padding: 0 6px;
5
+ }
6
+
7
+ .time {
8
+ color: #bbb;
9
+ }
@@ -13,8 +13,8 @@ setInterval(function () {
13
13
  }, 2000);
14
14
  login();
15
15
  var layer = layer$glance({
16
- left: "frame$left",
17
- top: 'frame$top'
16
+ left: frame$left,
17
+ top: frame$top
18
18
  });
19
19
  function main() {
20
20
  return layer;
@@ -1,3 +1,4 @@
1
1
  >:not([layer]) {
2
2
  padding: 50px 10px 0;
3
+ min-height: 100%;
3
4
  }
@@ -2,5 +2,5 @@
2
2
  共享目录管理: /share/list
3
3
  短链接: /home/short
4
4
  WEB文件管理: /wow/root
5
- # 用户: /home/short
5
+ 长连接管理: /link/list
6
6
  # 用户列表: /user/list
@@ -5,6 +5,6 @@
5
5
  </form>
6
6
  </div>
7
7
  <div foot>
8
- <button white @click="close()">取消</button>
8
+ <btn white @click="close()">取消</btn>
9
9
  <button @click="save()"> 保存 </button>
10
10
  </div>
@@ -6,8 +6,10 @@ function main({ fields, item }) {
6
6
  close() {
7
7
  return remove(page);
8
8
  },
9
- save() {
10
- return data.from("share", { opt: item ? 'update' : 'create', data: this.data }).loading_promise;
9
+ async save() {
10
+ await data.from("share", { opt: 'create', path: this.data.path }).loading_promise;
11
+ dispatch(page, 'submited');
12
+ remove(page);
11
13
  },
12
14
  data: Object.assign({}, item)
13
15
  });
@@ -1,36 +1,56 @@
1
1
  var fields = refilm`
2
2
  路径/path
3
- 挂载点/name
4
3
  `;
5
- var options = [
6
- {
7
- name: "删除",
8
- do(e) {
9
- data.from('share', { opt: 'delete', item: e });
10
- }
11
- },
12
- {
13
- name: "修改",
14
- do(e) {
15
- popup('/share/edit', { fields, item: e });
16
- }
17
- }
18
- ];
19
- console.log(fields)
20
4
  function main() {
5
+ var options = [
6
+ {
7
+ name(e) {
8
+ return this.confirm === e ? "确认取消" : "取消"
9
+ },
10
+ type: 'danger',
11
+ confirm: false,
12
+ timer: 0,
13
+ async do(e) {
14
+ if (this.confirm !== e) {
15
+ this.confirm = e;
16
+ clearTimeout(this.timer);
17
+ this.timer = setTimeout(() => render.refresh(this.confirm = null), 2000);
18
+ return;
19
+ }
20
+ await data.from('share', { opt: 'delete', path: e.path }).loading_promise;
21
+ page.$scope.load();
22
+ }
23
+ }
24
+ ];
21
25
  var page = div();
22
26
  page.innerHTML = list;
23
- var a = data.from("share", { opt: 'list' }, a => {
24
- if (a) return a.map(b => ({ path: b }));
25
- });
26
27
  renderWithDefaults(page, {
27
- data: a,
28
+ data: [],
29
+ load() {
30
+ this.data = data.from("share", { opt: 'list' }, a => {
31
+ if (a) return a.map(b => ({ path: b }));
32
+ });
33
+ },
28
34
  fields: fields.concat({
29
35
  name: "操作",
36
+ width: 200,
30
37
  type: 'button',
31
38
  options,
32
39
  }),
33
40
  });
34
- console.log(a)
41
+ page.$scope.load();
42
+ contextmenu(page, [
43
+ {
44
+ name: "添加",
45
+ do(e) {
46
+ zimoli.prepare("/share/edit", function () {
47
+ var p = popup("/share/edit", { fields });
48
+ on('submited')(p, function () {
49
+ page.$scope.load();
50
+ })
51
+ })
52
+ }
53
+ },
54
+ ])
35
55
  return page;
36
56
  }
@@ -0,0 +1,7 @@
1
+ >table {
2
+ width: 100%;
3
+ }
4
+
5
+ & {
6
+ height: 100%;
7
+ }
@@ -24,7 +24,7 @@ function main() {
24
24
  if (p) p = String(p.name || '').replace(/\/$/, '');
25
25
  if (p) this.pathlist.push(p);
26
26
  this.data = data.from("folder", { opt: 'list', path: "/" + this.pathlist.join('/') }, files => {
27
- if (files) return files.map(f => {
27
+ if (files) return sortname(files).map(f => {
28
28
  return {
29
29
  name: f,
30
30
  type: /\/$/.test(f) ? 'folder' : 'file'
@@ -40,6 +40,10 @@ function stringify(memery) {
40
40
  if (memery instanceof Date) return date(memery);
41
41
  if (memery instanceof RegExp) return regexp(memery);
42
42
  if (!convertReg.test(typeof memery)) return string(memery);
43
+ m: if (typeof memery === 'function') {
44
+ for (var k in memery) break m;
45
+ return '';
46
+ }
43
47
  var dist = [memery];
44
48
  var rest = [memery];
45
49
  var trimed = [memery instanceof Array ? [] : {}];
@@ -51,7 +55,11 @@ function stringify(memery) {
51
55
  o[""] = arr;
52
56
  for (var k in memery) {
53
57
  var m = memery[k];
54
- if (inc === +k) {
58
+ f: if (typeof m === 'function') {
59
+ for (var k in m) break f;
60
+ continue;
61
+ }
62
+ if (inc === +k && k !== '') {
55
63
  var kindex = "";
56
64
  inc++;
57
65
  } else {
@@ -0,0 +1,119 @@
1
+ var minus = function (d1, d2) {
2
+ d1 = d1.split(".");
3
+ d2 = d2.split(".");
4
+ for (var cx = 0, dx = Math.max(d1.length, d2.length); cx < dx; cx++) {
5
+ var a = +d1[cx] || 0;
6
+ var b = +d2[cx] || 0;
7
+ if (a !== b) {
8
+ return a - b;
9
+ }
10
+ }
11
+ return 0;
12
+ };
13
+
14
+ var createMap = function (str) {
15
+ str = str.split('');
16
+ var map = {};
17
+ for (var cx = 0, dx = str.length; cx < dx; cx++) {
18
+ map[str[cx]] = cx;
19
+ }
20
+ return map;
21
+ };
22
+ var 甲乙丙丁戊己庚辛壬癸 = "甲乙丙丁戊己庚辛壬癸";
23
+
24
+ var map一二三 = extend(createMap("零一二三四五六七八九"), createMap("〇壹贰叁肆伍陆柒捌玖"));
25
+ var power = {
26
+ 拾: 10,
27
+ 十: 10,
28
+ 佰: 100,
29
+ 百: 100,
30
+ 仟: 1000,
31
+ 千: 1000,
32
+ 万: 10000,
33
+ 萬: 10000,
34
+ 亿: 100000000,
35
+ };
36
+ var parse一二三 = function (a) {
37
+ if (!/[十百千万亿拾佰仟萬]/.test(a)) return parseInt(a.split("").map(a => map一二三[a]).join(''));
38
+ var base = 0;
39
+ a.replace(/([^十百千万亿拾佰仟萬零〇]*)([十百千万亿拾佰仟萬]*)/g, function (_, a, b) {
40
+ if (!_) return;
41
+ if (!a) a = 1;
42
+ else a = map一二三[a];
43
+ var r = 1;
44
+ b.split('').forEach(b => r *= power[b]);
45
+ base += a * r;
46
+ })
47
+ return base;
48
+ };
49
+ var map甲乙丙 = createMap("甲乙丙丁戊己庚辛壬癸");
50
+ var map子丑寅 = createMap("子丑寅卯辰巳午未申酉戌亥");
51
+
52
+ var reg123 = /^(\d+|\d+[\.\d]+\d+)[\s\S]*$/;
53
+ var reg一二三 = /^([一二三四五六七八九十百千万亿壹贰叁肆伍陆柒捌玖拾佰仟萬零〇]+)[\s\S]*$/;
54
+ var reg甲乙丙 = /^([甲乙丙丁戊己庚辛壬癸])[\s\S]*$/;
55
+ var reg子丑寅 = /^([子丑寅卯辰巳午未申酉戌亥])[\s\S]*$/;
56
+ var reg天干地支 = /^([甲乙丙丁戊己庚辛壬癸][子丑寅卯辰巳午未申酉戌亥])[\s\S]*$/;
57
+
58
+ var getDelta = function (a, b, reg, parse) {
59
+ var match1 = reg.exec(a);
60
+ var match2 = reg.exec(b);
61
+ if (match1 && match2) {
62
+ var [, d1] = match1;
63
+ var [, d2] = match2;
64
+ if (parse) {
65
+ d1 = parse(d1);
66
+ d2 = parse(d2);
67
+ var delta = d1 - d2;
68
+ } else {
69
+
70
+ var delta = minus(d1, d2);
71
+ }
72
+ if (delta) return delta;
73
+ }
74
+ if (match1) return -1;
75
+ if (match2) return 1;
76
+ return 0;
77
+ };
78
+ var parse干支 = function (a) {
79
+ var [g, z] = a;
80
+ g = map甲乙丙[g];
81
+ z = map子丑寅[z];
82
+ return (12 + g - z) % 12 / 2 * 10 + g + 1;
83
+ };
84
+ var compare = function (a, b) {
85
+ for (var cx1 = a.length - 1, cx2 = a.length - 1; cx1 >= 0 && cx2 >= 0; cx1--, cx2--) {
86
+ while (/\s\u00a0/.test(a[cx1])) cx1--;
87
+ while (/\s\u00a0/.test(b[cx2])) cx2--;
88
+ if (a[cx1] !== b[cx2] || a[cx1] in map子丑寅 || a[cx1] in map一二三 || a in power) break;
89
+ }
90
+ a = a.slice(0, cx1 + 1);
91
+ b = b.slice(0, cx2 + 1);
92
+ for (var cx1 = 0, cx2 = 0, dx1 = a.length, dx2 = b.length; cx1 < dx1 && cx2 < dx2; cx1++, cx2++) {
93
+ while (/[\s\u00a0]/.test(a[cx1])) cx1++;
94
+ while (/[\s\u00a0]/.test(b[cx2])) cx2++;
95
+ if (a[cx1] !== b[cx2] || a[cx1] in map甲乙丙 || a[cx1] in map一二三 || a in power) break;
96
+ }
97
+ if (cx1) a = a.slice(cx1);
98
+ if (cx2) b = b.slice(cx2);
99
+ if (!a) return -1;
100
+ if (!b) return 1;
101
+ var delta = getDelta(a, b, reg123);
102
+ if (delta) return delta;
103
+ delta = getDelta(a, b, reg一二三, parse一二三);
104
+ if (delta) return delta;
105
+ delta = getDelta(a, b, reg天干地支, parse干支);
106
+ if (delta) return delta;
107
+ delta = getDelta(a, b, reg甲乙丙, d => map甲乙丙[d]);
108
+ if (delta) return delta;
109
+ delta = getDelta(a, b, reg子丑寅, d => map子丑寅[d]);
110
+ if (delta) return delta;
111
+ return 0;
112
+ }
113
+ function sortname(list = this) {
114
+ if (this !== arguments[1] && arguments.length === 2) {
115
+ return compare(arguments[0], arguments[1]);
116
+ }
117
+ list = list.sort(compare);
118
+ return list;
119
+ }
@@ -1,7 +1,6 @@
1
1
  var page = document.createElement("都说我负天下人_可你们天下人_又何曾善待过我");
2
2
  page.innerHTML = left;
3
3
  if (!user.avatar) user.avatar = "user/avatar.png";
4
- frame$route.fetch('menu.yml')
5
4
  render(page, {
6
5
  ylist: menu,
7
6
  btn: button,
@@ -11,6 +10,9 @@ render(page, {
11
10
  popup,
12
11
  menus: frame$route,
13
12
  });
13
+ on('append')(page, function () {
14
+ frame$route.open();
15
+ });
14
16
  function main() {
15
17
  return page;
16
18
  }
@@ -98,9 +98,9 @@
98
98
  if (!active || result.indexOf(active) < 0) {
99
99
  actived = mmap[opened.active] || actived;
100
100
  if (actived) {
101
- if (actived_value === historys.length) result.open(actived);
102
- } else {
103
- result.open(result[0]);
101
+ if (actived_value === historys.length) {
102
+ result.active = actived;
103
+ };
104
104
  }
105
105
  }
106
106
  return result;
@@ -133,7 +133,10 @@
133
133
  }
134
134
  });
135
135
  result.open = function (menu) {
136
- if (!menu) return;
136
+ if (!menu) {
137
+ menu = result.active || result[0];
138
+ delete result.active;
139
+ }
137
140
  if (!menu.path) {
138
141
  menu.closed = !menu.closed;
139
142
  return;
@@ -176,7 +179,6 @@
176
179
  data.from(url).loading_promise.then(result.update);
177
180
  return result;
178
181
  };
179
- if (items.length) result.update(items);
180
-
182
+ result.update(items);
181
183
  return result;
182
184
  });
@@ -104,10 +104,10 @@ function main(mainPath, historyName = "") {
104
104
  }
105
105
  zimoli();
106
106
  };
107
- if (leftPath) {
107
+ if (typeof leftPath === 'string') {
108
108
  zimoli.prepare(leftPath, hook);
109
109
  } else hook();
110
- if (topPath) {
110
+ if (typeof topPath === 'string') {
111
111
  zimoli.prepare(topPath, hook);
112
112
  } else hook();
113
113
  });
@@ -8,8 +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" -repeat="o in f.options">
12
- <span -text=o.name></span>
11
+ <a on-click="o.do(d)" -if="f.options" _type="o.type" -repeat="o in f.options">
12
+ <span -text="o.name instanceof Function?o.name(d):o.name"></span>
13
13
  </a>
14
14
  </td>
15
15
  </tr>
@@ -337,11 +337,17 @@ function prepare(pgpath, ok) {
337
337
  }, state);
338
338
  }
339
339
  function create(pagepath, args, from, needroles) {
340
- var page_object = isObject(pagepath) ? pagepath : page_generators[getpgpath(pagepath)];
341
- if (!page_object) {
342
- throw new Error(`调用create前请确保prepare执行完毕:${pagepath}`);
340
+ if (typeof pagepath === 'string') {
341
+ var page_object = isObject(pagepath) ? pagepath : page_generators[getpgpath(pagepath)];
342
+ if (!page_object) {
343
+ throw new Error(`调用create前请确保prepare执行完毕:${pagepath}`);
344
+ }
345
+ var { pg, "with": _with_elements, state, onback: _pageback_listener, roles } = page_object;
346
+ }
347
+ else if (isFunction(pagepath)) {
348
+ var pg = pagepath;
349
+ var { with: _with_elements, state = {}, onback: _pageback_listener, roles } = pg;
343
350
  }
344
- var { pg, "with": _with_elements, state, onback: _pageback_listener, roles } = page_object;
345
351
  if (!checkroles(user.roles, roles) || !checkroles(user.roles, needroles)) {
346
352
  // 检查权限
347
353
  if (!user.isLogin && user.loginPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.5.9",
3
+ "version": "3.5.13",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {