efront 4.24.1 → 4.24.3

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.
Files changed (39) hide show
  1. package/#/345/233/275/351/231/205/345/214/226.yml +30 -12
  2. package/apps/pivot/auth/login.js +4 -4
  3. package/apps/pivot/cert/edit.js +1 -1
  4. package/apps/pivot/cert/list.js +1 -1
  5. package/apps/pivot/cert/main.xht +2 -3
  6. package/apps/pivot/dht/list.js +6 -7
  7. package/apps/pivot/dict/edit.js +1 -1
  8. package/apps/pivot/dict/list.js +8 -6
  9. package/apps/pivot/home/welcome.html +10 -10
  10. package/apps/pivot/home/welcome.js +1 -0
  11. package/apps/pivot/link/room.js +3 -3
  12. package/apps/pivot/log/count.js +22 -22
  13. package/apps/pivot/main.js +8 -2
  14. package/apps/pivot/proxy/edit.js +1 -1
  15. package/apps/pivot/proxy/list.js +4 -5
  16. package/apps/pivot/share/list.js +3 -3
  17. package/apps/pivot/task/edit.js +1 -1
  18. package/apps/pivot/task/list.js +1 -1
  19. package/apps/pivot/token/edit.js +1 -1
  20. package/apps/pivot/token/list.js +1 -1
  21. package/apps/pivot/wow/root.js +0 -3
  22. package/coms/basic/i18n.js +18 -5
  23. package/coms/basic/migrate.js +43 -0
  24. package/coms/explorer/context.js +2 -2
  25. package/coms/explorer/main.js +1 -1
  26. package/coms/frame/edit.html +1 -1
  27. package/coms/frame/edit.js +13 -6
  28. package/coms/frame/list.js +75 -42
  29. package/coms/frame/route.js +11 -6
  30. package/coms/pivot/plist.js +8 -5
  31. package/coms/zimoli/autodragchildren.js +5 -1
  32. package/coms/zimoli/render.js +1 -0
  33. package/coms/zimoli/yousure.js +5 -1
  34. package/coms/zimoli/zimoli.js +13 -2
  35. package/coms//350/214/250/350/217/260//347/274/226/350/276/221/346/241/206.xht +33 -7
  36. package/docs/main.xht +21 -17
  37. package/docs//345/221/275/344/273/244.xht +33 -32
  38. package/package.json +1 -1
  39. package/public/efront.js +1 -1
@@ -1,6 +1,68 @@
1
- function main(title, { fields, options: options0, load, remove, buttons }, edit_ref) {
1
+ function main(gtTitle, { fields: gtFields, options: gtOptions, load, remove, buttons: gtButtons }, edit_ref) {
2
+ var title, fields, fieldsL, options, options, buttons;
3
+ var gt = function (gt, o) {
4
+ if (isFunction(gt)) gt = gt();
5
+ if (isArray(o)) {
6
+ o.splice(0, o.length);
7
+ o.push.apply(o, gt);
8
+ }
9
+ else o = gt;
10
+ return o;
11
+ }
12
+ var update = function () {
13
+ title = gt(gtTitle, title);
14
+ var options0 = gt(gtOptions);
15
+ var options1 = [
16
+ {
17
+ name: i18n`修改`,
18
+ async do(o) {
19
+ await edit(o);
20
+ },
21
+ },
22
+ {
23
+ type: "danger",
24
+ name(o) {
25
+ return this.confirm === o ? i18n`确认删除` : i18n`删除`;
26
+ },
27
+ type(o) {
28
+ return this.confirm === o ? "dark" : "danger";
29
+ },
30
+ confirm: false,
31
+ timer: 0,
32
+ async do(o) {
33
+ if (this.confirm !== o) {
34
+ this.confirm = o;
35
+ clearTimeout(this.timer);
36
+ var that = this;
37
+ this.timer = setTimeout(function () {
38
+ that.confirm = null;
39
+ render.refresh();
40
+ }, 2000);
41
+ return;
42
+ }
43
+ await remove(o);
44
+ page_scope.load();
45
+ }
46
+ }
47
+ ];
48
+ if (options1) options1.push.apply(options1, options0);
49
+ options = gt(options1, options);
50
+ buttons = gt(gtButtons, buttons);
51
+ fields = gt(gtFields, fields);
52
+ var fields1 = fields.filter(f => !f.hidden && f.inlist !== false).concat({
53
+ name: i18n`操作`,
54
+ options
55
+ })
56
+ fieldsL = gt(fields1, fieldsL);
57
+ };
2
58
  if (isString(edit_ref)) prepare(edit_ref);
3
59
  var page = document.createElement("div");
60
+ on('append')(page, function () {
61
+ i18n.addReloader(update);
62
+ });
63
+ on('remove')(page, function () {
64
+ i18n.removeReloader(update);
65
+ });
4
66
  var edit = async function (o) {
5
67
  if (!edit_ref) {
6
68
  return;
@@ -24,58 +86,29 @@ function main(title, { fields, options: options0, load, remove, buttons }, edit_
24
86
  on("submited")(p, callback);
25
87
  })
26
88
  };
27
- page.innerHTML = template;
28
- var options = [
29
- {
30
- name: i18n`修改`,
31
- async do(o) {
32
- await edit(o);
33
- },
34
- },
35
- {
36
- type: "danger",
37
- name(o) {
38
- return this.confirm === o ? i18n`确认删除` : i18n`删除`;
39
- },
40
- type(o) {
41
- return this.confirm === o ? "dark" : "danger";
42
- },
43
- confirm: false,
44
- timer: 0,
45
- async do(o) {
46
- if (this.confirm !== o) {
47
- this.confirm = o;
48
- clearTimeout(this.timer);
49
- var that = this;
50
- this.timer = setTimeout(function () {
51
- that.confirm = null;
52
- render.refresh();
53
- }, 2000);
54
- return;
55
- }
56
- await remove(o);
57
- page_scope.load();
58
- }
59
- }
60
- ];
61
- if (options0) options = options.concat(options0);
89
+ update();
62
90
  var page_scope = {
63
- title,
91
+ get title() {
92
+ return title
93
+ },
64
94
  load() {
65
95
  this.data = load();
66
96
  },
67
- fields: fields.filter(f => !f.hidden && f.inlist !== false).concat({
68
- name: i18n`操作`,
69
- options
70
- }),
97
+ fields,
71
98
  buttons,
72
99
  hasedit: !!edit_ref,
73
100
  data: [],
74
101
  async add() {
75
102
  await edit();
76
103
  },
77
- }
104
+ };
105
+ page.innerHTML = template;
78
106
  renderWithDefaults(page, page_scope);
107
+ page.reload = function () {
108
+ update();
109
+ page.innerHTML = template;
110
+ renderWithDefaults(page, page_scope);
111
+ };
79
112
  on("append")(page, function () {
80
113
  page_scope.load();
81
114
  });
@@ -138,17 +138,22 @@
138
138
  idmap = Object.create(null);
139
139
  firstMenu = null;
140
140
  items = result.parse(items);
141
- items.map(getChildren);
141
+ migrate(result, items);
142
+ result.map(getChildren);
142
143
  var opened = data.getInstance("menu-opened");
143
144
  var historys = zimoli.getCurrentHistory();
144
145
  var map = {}, mmap = {};
145
146
  historys.forEach((a, i) => map[a] = i + 1);
146
- result.splice(0, result.length);
147
147
  var actived, actived_value = 0;
148
- var a = function (menu) {
148
+ var a = function (menu, i, arr) {
149
149
  var res = checkroles(user.roles, menu.roles);
150
- if (res) {
151
- if (savedChildren[menu.id] instanceof Array) menu.children = savedChildren[menu.id].filter(a);
150
+ if (!res) arr.splice(i, 1);
151
+ else {
152
+ if (savedChildren[menu.id] instanceof Array) {
153
+ var children = savedChildren[menu.id];
154
+ backEach(children, a);
155
+ menu.children = children;
156
+ }
152
157
  if (menu.path) {
153
158
  if (!firstMenu) firstMenu = menu;
154
159
  if (map[menu.path] > actived_value) {
@@ -161,7 +166,7 @@
161
166
  }
162
167
  return res;
163
168
  };
164
- result.push.apply(result, items.filter(a));
169
+ backEach(result, a);
165
170
  result.opened = opened.map(a => mmap[a]).filter(a => !!a);
166
171
  var active = result.active;
167
172
  if (!active || result.indexOf(active) < 0) {
@@ -9,8 +9,7 @@ function plist() {
9
9
  var parse = function (a) {
10
10
  switch (typeof a) {
11
11
  case "string":
12
- if (!title) title = a;
13
- else if (!type) type = a;
12
+ if (!type) type = a;
14
13
  else if (!edit_ref) edit_ref = a;
15
14
  else idkey = a;
16
15
  break;
@@ -31,11 +30,16 @@ function plist() {
31
30
  } = a);
32
31
  }
33
32
  break;
33
+ case "function":
34
+ if (!title) title = a;
35
+ else if (!fields) fields = a;
36
+ else if (!options) options = a;
37
+ else if (!buttons) buttons = a;
34
38
  }
35
39
  }
36
40
  for (var a of arguments) parse(a);
37
41
  if (!fields) parse(this);
38
- if (!idkey) idkey = fields[0].key;
42
+ if (!idkey) idkey = (isFunction(fields) ? fields() : fields)[0].key;
39
43
  return frame$list(title, {
40
44
  load() {
41
45
  return load(type, idkey);
@@ -49,8 +53,7 @@ function plist() {
49
53
  }, edit_ref ? edit_ref : function (o) {
50
54
  var p = pedit(title, type, o);
51
55
  p.initialStyle = popup.style;
52
- popup(p, true);
53
- move.setPosition(p, [.5, .5]);
56
+ popup(p, [.5, .5]);
54
57
  return p;
55
58
  });
56
59
  }
@@ -353,7 +353,11 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
353
353
  var copyZIndex = function (e) {
354
354
  e.style.zIndex = zIndex;
355
355
  var z = zIndex - 1;
356
- if (e.with) for (var w of e.with) w.style.zIndex = z;
356
+ var ws = e.with;
357
+ if (ws){
358
+ if (isNode(ws)) ws = [ws];
359
+ for (var w of ws) w.style.zIndex = z;
360
+ }
357
361
  };
358
362
  if (zIndex > 2) {
359
363
  previousElements.forEach(copyZIndex);
@@ -435,6 +435,7 @@ var ifset = function (shouldMount) {
435
435
  e = c.$template = render(e);
436
436
  e.$comment = c;
437
437
  }
438
+ c.with = [e];
438
439
  }
439
440
  else {
440
441
  remove(c.$template);
@@ -3,7 +3,11 @@
3
3
  * 确定就继续,取消就中断
4
4
  */
5
5
  function yousure(title = i18n`您确定要这么做吗?`, content = i18n`当前操作需要您再次确认`) {
6
- var options = [button(i18n`确定` + "(Y)"), button(i18n`取消` + "(N)", "white")];
6
+ var options = isArray(content) ? content : arguments[2] || [button(i18n`确定` + "(Y)"), button(i18n`取消` + "(N)", "white")];
7
+ options = options.map(a => {
8
+ if (typeof a === 'string') a = button(a);
9
+ return a;
10
+ });
7
11
  options[0].tabindex = -1;
8
12
  options[1].tabindex = -1;
9
13
  var changeFocus = function (event) {
@@ -430,7 +430,7 @@ function create(pagepath, args, from, needroles, zimolidata) {
430
430
  isRecover = isR;
431
431
  addGlobal(this, history_name, isRecover);
432
432
  }
433
- _page.$reload = function () {
433
+ _page.$reload = _page.$reload || _page.reload || function () {
434
434
  var _page = create(pagepath, undefined, from, undefined, zimolidata);
435
435
  _page.mount(history_name, isRecover);
436
436
  return _page;
@@ -891,7 +891,7 @@ zimoli.enableTouchBack = function () {
891
891
  }
892
892
  }, 'x')
893
893
  };
894
- zimoli.reload = function () {
894
+ var reloadFully = function () {
895
895
  for (var k in history) {
896
896
  var h = history[k];
897
897
  if (!h) continue;
@@ -913,6 +913,17 @@ zimoli.reload = function () {
913
913
  current_history = default_history;
914
914
  body = document.body;
915
915
  zimoli();
916
+ }
917
+ var reloadMounted = function () {
918
+ for (var k in global) {
919
+ var o = global[k];
920
+ if (!o || !o.$reload) continue;
921
+ if (isMounted(o)) o.$reload();
922
+ }
923
+ }
924
+ zimoli.reload = function (reloadAll = true) {
925
+ if (!reloadAll) reloadMounted();
926
+ else reloadFully();
916
927
  };
917
928
  zimoli.alert = function () {
918
929
  var ae = alert.apply(this, arguments);
@@ -179,10 +179,36 @@
179
179
  render.refresh(nlist);
180
180
  };
181
181
  var spacing = false;
182
+ var isEqual = function (a, b) {
183
+ return a === b || !a && !b;
184
+ };
185
+ var getNodeText = function (node) {
186
+ if (!node) return '';
187
+ if (node.nodeType === 3) return node.nodeValue;
188
+ if (node.nodeType === 1) return node.innerText;
189
+ return '';
190
+ }
182
191
  var getNodeAt = function (row, col) {
183
192
  var d = clist.at(row);
184
193
  if (!d) return [];
185
194
  var c = d.firstChild;
195
+ if (!spacing) {
196
+ var t = d.innerText;
197
+ var tbb = t.charAt(col - 3);
198
+ var tb = t.charAt(col - 2);
199
+ var ta = t.charAt(col - 1);
200
+ var tf = t.charAt(col);
201
+ var tff = t.charAt(col + 1);
202
+ if (ta === " " && isEqual(tb, anchorChar)) {
203
+ col++;
204
+ }
205
+ else if (isEqual(ta, anchorChar) && !isEqual(tb, anchorChar)) {
206
+ col++;
207
+ }
208
+ else if (anchorChar === " " && isEqual(ta, followChar) && !isEqual(tf, followChar)) {
209
+ col--;
210
+ }
211
+ }
186
212
  var inc = 0;
187
213
  while (c) {
188
214
  if (c.nodeType === 1) {
@@ -201,14 +227,10 @@
201
227
  if (inc + tl > col) {
202
228
  col -= inc;
203
229
  inc = 0;
204
- if (!spacing && t.charAt(col - 1) === " ") {
205
- col++;
206
- }
207
230
  break;
208
231
  }
209
232
  else if (inc + tl === col) {
210
- if (!spacing && t.charAt(col - inc - 1) === " ") col++;
211
- else break;
233
+ break;
212
234
  }
213
235
  inc += tl;
214
236
  c = c.nextSibling;
@@ -430,13 +452,17 @@
430
452
  document.execCommand('forwardDelete');
431
453
  }
432
454
  else if (data in pairsmap) {
433
- if (inText || beforeText) return;
455
+ if (inText) {
456
+ if (/^'/.test(data)) return;
457
+ }
434
458
  patchAfter = pairsmap[data];
435
459
  }
436
460
  }
437
461
  else {
438
462
  if (data in pairsmap) {
439
- if (inText || beforeText) return;
463
+ if (inText) {
464
+ if (/^'/.test(data)) return;
465
+ }
440
466
  patchAfter = pairsmap[data];
441
467
  }
442
468
  }
package/docs/main.xht CHANGED
@@ -172,8 +172,10 @@
172
172
  <div1 #content></div1>
173
173
  <open #switch @click="switchMenu()" insert></open>
174
174
  <script>
175
- i18n.setReloader(zimoli.reload);
176
- var menus = [
175
+ i18n.setReloader(function () {
176
+ initMenus();
177
+ });
178
+ var menus = () => [
177
179
  {
178
180
  name: i18n`efront简介`,
179
181
  children: [
@@ -214,12 +216,12 @@
214
216
  }
215
217
  ]);
216
218
  });
217
- var initVersionInfo = async function () {
219
+ var initVersionInfo = async function (menus) {
218
220
  var xhr = await cross("get", "version");
219
221
  var version = xhr.response.split(",");
220
222
  menus[0].name += ` <v>${version[0]}</v>`;
221
223
  };
222
- var initCommandsDocs = async function () {
224
+ var initCommandsDocs = async function (menus) {
223
225
  delete modules['docs$helps'];
224
226
  var helps = await init("docs$helps");
225
227
  var m = {
@@ -244,7 +246,7 @@
244
246
  });
245
247
  menus.splice(1, 0, m);
246
248
  };
247
- var initComponentDocs = async function () {
249
+ var initComponentDocs = async function (menus) {
248
250
  var m = await cross("get", "components");
249
251
  m = JSON.parse(m.response);
250
252
  for (var c of m) {
@@ -280,17 +282,19 @@
280
282
  menus[2].children = m;
281
283
  };
282
284
  var initMenus = async function () {
283
- menus[0].children.forEach(c => { c.path = "/mark/" + c.md });
284
- zimoli.switch('', scope.content, menus[0].children[0].path);
285
- await initVersionInfo();
286
- await initCommandsDocs();
287
- await initComponentDocs();
288
- var route = await init("frame$route");
289
- scope.menus = route.update(menus);
285
+ var ms = menus();
286
+ ms[0].children.forEach(c => { c.path = "/mark/" + c.md });
287
+ zimoli.switch('', scope.content, ms[0].children[0].path);
288
+ await initVersionInfo(ms);
289
+ await initCommandsDocs(ms);
290
+ await initComponentDocs(ms);
291
+ var route = frame$route;
292
+ scope.menus = route;
293
+ route.update(ms);
290
294
  route.open(route.active);
291
295
  };
292
296
  var scope = {
293
- menus,
297
+ menus: [],
294
298
  div2(elem, scope) {
295
299
  if (scope.m.data?.mark) elem.setAttribute("mark", '');
296
300
  if (scope.m.data?.test) elem.setAttribute("test", '');
@@ -326,10 +330,10 @@
326
330
  drag.on(close, window);
327
331
  }
328
332
  render(page, scope);
329
- var s = scrollbar();
333
+ var scrbar = scrollbar();
330
334
  on("mounted")(page, initMenus);
331
- s.bindTarget(scope.content);
332
- page.with = s;
335
+ scrbar.bindTarget(scope.content);
336
+ page.with = scrbar;
333
337
  resizingList.set(page, function () {
334
338
  if (page.adapted === true) return;
335
339
  if (calcPixel(page.offsetWidth) < 720) return;
@@ -338,7 +342,7 @@
338
342
  });
339
343
  bind("render")(page, function () {
340
344
  requestAnimationFrame(function () {
341
- s.reshape();
345
+ scrbar.reshape();
342
346
  })
343
347
  });
344
348
  drag.on(scope.switch);
@@ -66,41 +66,42 @@
66
66
  </div>
67
67
  <script>
68
68
  var position = [.2, .2];
69
- var page = view();
70
- page.innerHTML = template;
71
- once("append")(page, function () {
72
- move.setPosition(this, position);
73
- });
74
- var scope = {
75
- help: null,
76
- dict: helps.topics,
77
- cmds(elem, scope) {
78
- var topics = scope.topics = [];
79
- var cmds = scope.c.split(/\s+/).map(a => a.split("|"));
80
- cmds = combine(...cmds).map(a => "<efront></efront>" + a.join("&ensp;")).join("<br/>");
81
- elem.innerHTML = cmds.replace(/[A-Z]+(\_[A-Z]+)*/g, m => {
82
- if (topics.indexOf(m) < 0) topics.push(m);
83
- return `<w>${m}</w>`;
84
- });
85
- },
86
- topic(elem, s) {
87
- var topics = s.topics.filter(a => scope.dict[a]);
88
- if (!topics.length) return;
89
- elem.innerHTML = i18n`其中,` + topics.map(a => {
90
- var d = scope.dict[a];
91
- var t = i18n`${a}是${d[0]}`;
92
- if (d.length > 1) t += i18n`,可取值有${d.slice(1).join('、')}`;
93
- if (d.default) t += i18n`,默认值是${d.default}`;
94
- return t;
95
- }).join(';');
96
- }
97
- }
98
- drag.on(page, page.firstElementChild);
99
- resize.on(page);
100
- render(page, scope);
101
69
  function main(dict) {
70
+ var page = view();
71
+ var helps = init('docs$helps');
72
+ once("append")(page, function () {
73
+ move.setPosition(this, position);
74
+ });
75
+ var scope = {
76
+ help: null,
77
+ dict: helps.topics,
78
+ cmds(elem, scope) {
79
+ var topics = scope.topics = [];
80
+ var cmds = scope.c.split(/\s+/).map(a => a.split("|"));
81
+ cmds = combine(...cmds).map(a => "<efront></efront>" + a.join("&ensp;")).join("<br/>");
82
+ elem.innerHTML = cmds.replace(/[A-Z]+(\_[A-Z]+)*/g, m => {
83
+ if (topics.indexOf(m) < 0) topics.push(m);
84
+ return `<w>${m}</w>`;
85
+ });
86
+ },
87
+ topic(elem, s) {
88
+ var topics = s.topics.filter(a => scope.dict[a]);
89
+ if (!topics.length) return;
90
+ elem.innerHTML = i18n`其中,` + topics.map(a => {
91
+ var d = scope.dict[a];
92
+ var t = i18n`${a}是${d[0]}`;
93
+ if (d.length > 1) t += i18n`,可取值有${d.slice(1).join('、')}`;
94
+ if (d.default) t += i18n`,默认值是${d.default}`;
95
+ return t;
96
+ }).join(';');
97
+ }
98
+ }
102
99
  var [help] = helps.helps.filter(h => dict === h.info);
103
100
  scope.help = help;
101
+ drag.on(page, page.firstElementChild);
102
+ resize.on(page);
103
+ page.innerHTML = template;
104
+ render(page, scope);
104
105
  return page;
105
106
  }
106
107
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.24.1",
3
+ "version": "4.24.3",
4
4
  "description": "一个开发环境,提供一种自由的前端开发模式,也可作为辅助工具使用。",
5
5
  "main": "public/efront.js",
6
6
  "directories": {