efront 4.23.9 → 4.24.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.
Files changed (64) hide show
  1. package/#/345/233/275/351/231/205/345/214/226.yml +237 -0
  2. package/apps/pivot/#/345/233/275/351/231/205/345/214/226.yml +2 -0
  3. package/apps/pivot/auth/login.html +2 -1
  4. package/apps/pivot/auth/login.js +1 -0
  5. package/apps/pivot/auth/login.less +1 -0
  6. package/apps/pivot/cert/edit.js +1 -1
  7. package/apps/pivot/cert/list.js +1 -1
  8. package/apps/pivot/cert/main.xht +6 -6
  9. package/apps/pivot/cert/orders.xht +8 -8
  10. package/apps/pivot/cert/update.xht +3 -3
  11. package/apps/pivot/db/config.xht +1 -1
  12. package/apps/pivot/db/edit.xht +2 -2
  13. package/apps/pivot/db/list.xht +4 -4
  14. package/apps/pivot/dht/list.js +4 -4
  15. package/apps/pivot/dict/edit.js +1 -1
  16. package/apps/pivot/dict/list.js +1 -1
  17. package/apps/pivot/home/welcome.html +12 -9
  18. package/apps/pivot/home/welcome.js +3 -3
  19. package/apps/pivot/link/index.js +7 -4
  20. package/apps/pivot/link/list.html +2 -2
  21. package/apps/pivot/link/room.js +2 -2
  22. package/apps/pivot/main.js +2 -0
  23. package/apps/pivot/menu-en.yml +16 -0
  24. package/apps/pivot/proxy/edit.js +1 -1
  25. package/apps/pivot/proxy/list.js +2 -2
  26. package/apps/pivot/share/edit.html +3 -3
  27. package/apps/pivot/share/list.js +3 -3
  28. package/apps/pivot/task/edit.js +1 -1
  29. package/apps/pivot/task/invoke.html +1 -1
  30. package/apps/pivot/task/invoke.js +2 -2
  31. package/apps/pivot/task/list.js +3 -3
  32. package/apps/pivot/task/rsync.html +3 -3
  33. package/apps/pivot/task/rsync.js +1 -1
  34. package/apps/pivot/token/edit.js +1 -1
  35. package/apps/pivot/token/list.js +1 -1
  36. package/apps/pivot/wow/root.js +1 -1
  37. package/apps/pivot//344/270/273/351/241/265.html +1 -1
  38. package/coms/basic/#loader.js +7 -0
  39. package/coms/basic/cross_.js +4 -3
  40. package/coms/basic/i18n-chooser.xht +17 -0
  41. package/coms/basic/i18n-supports.js +30 -0
  42. package/coms/basic/i18n.js +25 -1
  43. package/coms/basic_/Promise.js +21 -18
  44. package/coms/basic_/WeakMap.js +12 -6
  45. package/coms/compile/Program.js +4 -4
  46. package/coms/frame/list.html +1 -1
  47. package/coms/frame/list.js +1 -1
  48. package/coms/frame/route.js +22 -9
  49. package/coms/pivot/left-footer.xht +4 -1
  50. package/coms/zimoli/chooseFile.js +1 -1
  51. package/coms/zimoli/cless.js +2 -2
  52. package/coms/zimoli/createUploadURL.js +1 -1
  53. package/coms/zimoli/field.html +1 -1
  54. package/coms/zimoli/field.js +1 -0
  55. package/coms/zimoli/menuItem.js +3 -1
  56. package/coms/zimoli/render.js +3 -2
  57. package/coms/zimoli/selectList.js +3 -3
  58. package/coms/zimoli/selectListEdit.html +5 -5
  59. package/coms/zimoli/yousure.js +2 -2
  60. package/coms/zimoli/zimoli.js +46 -15
  61. package/docs/main.xht +19 -6
  62. package/docs//345/267/245/345/205/267//345/233/275/351/231/205/345/214/226.xht +3 -36
  63. package/package.json +1 -1
  64. package/public/efront.js +1 -1
@@ -15,5 +15,5 @@
15
15
  </div>
16
16
  </div>
17
17
  <div foot>
18
- <btn @click="run">执行</btn>
18
+ <btn @click="run">${i18n`执行`}</btn>
19
19
  </div>
@@ -19,12 +19,12 @@ function main(a) {
19
19
  jscode: 茨菰$编辑框,
20
20
  async run() {
21
21
  var id = ++taskid;
22
- this.output = "正在执行..";
22
+ this.output = i18n`正在执行..`;
23
23
  this.error = false;
24
24
  var params = JSON.stringify(this.data);
25
25
  try {
26
26
  var res = await data.from("invoke", { key: a.key, params: encode62.packencode(params) }, function (a) {
27
- return a ? encode62.packdecode(a) : '完成!';
27
+ return a ? encode62.packdecode(a) : i18n`完成!`;
28
28
  });
29
29
  if (id !== taskid) return;
30
30
  this.output = res;
@@ -5,7 +5,7 @@ model.setEditor('jscode', function (element) {
5
5
  return element;
6
6
  });
7
7
  model.setReader('jscode', "text");
8
- return plist.bind(null, '任务管理', "task", refilm`
8
+ return plist.bind(null, i18n`任务管理`, "task", refilm`
9
9
  *任务ID/key 100
10
10
  *任务名/name 100
11
11
  *是否启用/status radio 不启用#ccc,启用#396
@@ -15,7 +15,7 @@ return plist.bind(null, '任务管理', "task", refilm`
15
15
  when(o) {
16
16
  return o.status === 1;
17
17
  },
18
- name: "执行", do(o) {
18
+ name: i18n`执行`, do(o) {
19
19
  popup("/task/invoke", o);
20
20
  }
21
21
  },
@@ -23,7 +23,7 @@ return plist.bind(null, '任务管理', "task", refilm`
23
23
  when(o) {
24
24
  return o.status === 1;
25
25
  },
26
- name: "同步", do(o) {
26
+ name: i18n`同步`, do(o) {
27
27
  popup("/task/rsync", o);
28
28
  }
29
29
  },
@@ -1,5 +1,5 @@
1
1
  <div head>
2
- 同步任务&nbsp;-&nbsp; <span -text=task.name></span>(<span -text=task.key></span>)
2
+ ${i18n`同步任务`}&nbsp;-&nbsp; <span -text=task.name></span>(<span -text=task.key></span>)
3
3
  <close @click="remove()"></close>
4
4
  </div>
5
5
  <div body>
@@ -7,10 +7,10 @@
7
7
  <a @click="checked[h.key]=!checked[h.key]" disabled:="h.key===base.host" :class="{finished:finished[h.key]}">
8
8
  <checker -model="checked[h.key]"></checker>
9
9
  <span -text="h.name"></span>
10
- <span v-if="h.key===base.host">(当前)</span>
10
+ <span v-if="h.key===base.host">(${i18n`当前`})</span>
11
11
  </a>
12
12
  </padding>
13
13
  </div>
14
14
  <div foot>
15
- <btn @click="flush()">同步</btn>
15
+ <btn @click="flush()">${i18n`同步`}</btn>
16
16
  </div>
@@ -29,7 +29,7 @@ function main(task) {
29
29
  });
30
30
  finished[h.key] = true;
31
31
  }
32
- alert('同步完成!');
32
+ alert(i18n`同步完成!`);
33
33
  },
34
34
  remove() {
35
35
  remove(page);
@@ -1 +1 @@
1
- pedit.bind(null, "密钥", "private");
1
+ pedit.bind(null, i18n`密钥`, "private");
@@ -1,4 +1,4 @@
1
- plist.bind(null, '密钥管理', "private", refilm`
1
+ plist.bind(null, i18n`密钥管理`, "private", refilm`
2
2
  *键名/key 100
3
3
  显示名/name input/300
4
4
  密钥/value text/100
@@ -126,7 +126,7 @@ function main(path) {
126
126
  },
127
127
  async mov(from, distpath) {
128
128
  var currentHost = data.getInstance("base").base;
129
- if (from.host !== currentHost) return alert("暂不支持跨服务器操作!");
129
+ if (from.host !== currentHost) return alert(i18n`暂不支持跨服务器操作!`);
130
130
  from = encode62.packencode(from.fullpath);
131
131
  distpath = encode62.packencode(distpath);
132
132
  await data.from("folder", { opt: 'mov', path: from, to: distpath }).loading_promise;
@@ -36,7 +36,7 @@
36
36
  </style>
37
37
  </head>
38
38
 
39
- <body scroll=no menu="menu.yml">
39
+ <body scroll=no>
40
40
  雪下的那么深,下的那么认真..
41
41
  </body>
42
42
 
@@ -494,11 +494,17 @@ var createModule = function (exec, originNames, compiledNames, prebuilds = {}) {
494
494
  for (var k in prebuilds) if (hasOwnProperty.call(prebuilds, k)) prebuilds2[k] = prebuilds[k];
495
495
  prebuilds = prebuilds2;
496
496
  }
497
+ var isCless = argName === 'cless';
498
+ if (isCless && exec[argName]) return exec[argName];
497
499
  var promise = init(aName, function (res) {
500
+ if (isCless) res = exec[argName] = res.bind(document.createElement('style'));
498
501
  result = res;
499
502
  created = true;
500
503
  }, prebuilds);
501
504
  if (created) return result;
505
+ if (isCless) promise = exec[argName] = promise.then(a => {
506
+ return result;
507
+ })
502
508
  return promise;
503
509
  });
504
510
  var _this = isModuleInit ? exports : window;
@@ -651,6 +657,7 @@ var init = function (url, then, prebuilds, keeppage) {
651
657
  if (saveAsModule) {
652
658
  penddings[key] = created;
653
659
  created.then(function (res) {
660
+ delete penddings[key];
654
661
  then(modules[url] = res);
655
662
  });
656
663
  return;
@@ -379,9 +379,10 @@ function cross_(jsonp, digest = noop, method, url, headers) {
379
379
  if (is_gb2312) method = method.slice(1);
380
380
  if (nocross) {
381
381
  extend(realHeaders, _headers);
382
- xhr.open(method, url);
382
+ method = method.toUpperCase();
383
+ xhr.open(method, url, true);
383
384
  } else {
384
- xhr.open(method, getCrossUrl(url, _headers, isencrypt && code));
385
+ xhr.open(method, getCrossUrl(url, _headers, isencrypt && code), true);
385
386
  }
386
387
  if (is_gb2312) xhr.overrideMimeType("text/plain; charset=gb2312");
387
388
  if (location_href) delete realHeaders.Cookie;
@@ -393,7 +394,7 @@ function cross_(jsonp, digest = noop, method, url, headers) {
393
394
  else send.call(xhr);
394
395
  digest();
395
396
  };
396
- Promise.resolve(xhr.encrypt).then(fire, onerror1);
397
+ Promise.resolve(xhr.encrypt).then(fire).catch(onerror1);
397
398
  }
398
399
  var setRequestHeader = xhr.setRequestHeader;
399
400
  var realHeaders = Object.create(null);
@@ -0,0 +1,17 @@
1
+ <style>
2
+ &>select {
3
+ background: inherit;
4
+ vertical-align: top;
5
+ color: inherit;
6
+ margin-left: -2px;
7
+ padding-left: 2px;
8
+ }
9
+ </style>
10
+ <template>
11
+ <select -model="i18n.getIndex,i18n.setIndex" title:="title()" -src="(s,i) in i18n.supports">
12
+ <option -value="i" -bind="s.land===s.name?'🌏'+s.land:'🌐'+s.land +' - '+s.name"></option>
13
+ </select>
14
+ </template>
15
+ <script>
16
+ var title = () => i18n`切换语言`;
17
+ </script>
@@ -0,0 +1,30 @@
1
+ var supports = [
2
+ { land: i18n`中文简体`, name: `中文简体`, id: "zh", lang: "zh-CN" },
3
+ { land: i18n`中文繁体`, name: `中文繁體`, id: "cht", lang: "zh-TW" },
4
+ { land: i18n`英文`, name: `English`, id: "en", lang: "en" },
5
+ { land: i18n`日语`, name: `日本語`, id: "jp", lang: "ja" },
6
+ { land: i18n`法语`, name: `Français`, id: "fra", lang: 'fr' },
7
+ { land: i18n`俄语`, name: `Русский язык`, id: "ru", lang: 'ru' },
8
+ { land: i18n`韩语`, name: `한국어`, id: "kor", lang: "ko" },
9
+ { land: i18n`德语`, name: `Deutsch`, id: "de", lang: "de" },
10
+ { land: i18n`意大利语`, name: `Italiano`, id: "it", lang: 'it' },
11
+ { land: i18n`泰语`, name: `ภาษาไทย`, id: "th", lang: "th" },
12
+ { land: i18n`越南语`, name: `Tiếng Việt`, id: "vie", lang: 'vi' },
13
+ { land: i18n`阿拉伯语`, name: `بالعربية`, id: "ara", lang: "ar" },
14
+ { land: i18n`荷兰语`, name: `Nederlands`, id: "nl", lang: "nl" },
15
+ { land: i18n`芬兰语`, name: `suomi`, id: "fin", lang: "fi" },
16
+ { land: i18n`希腊语`, name: `Ελληνικά`, id: "el", lang: "el" },
17
+ { land: i18n`西班牙语`, name: `Español`, id: "spa", lang: "es" },
18
+ { land: i18n`葡萄牙语`, name: `Português`, id: "pt", lang: /pt\-(BR|PT)/ },
19
+ { land: i18n`匈牙利语`, name: `Húngaro`, id: "hu", lang: 'hu' },
20
+ { land: i18n`瑞典语`, name: `Svenska`, id: "swe", lang: 'sv' },
21
+ { land: i18n`丹麦语`, name: `Dansk`, id: "dan", lang: 'da' },
22
+ { land: i18n`捷克语`, name: `Čeština`, id: "cs", lang: 'cs' },
23
+ { land: i18n`波兰语`, name: `Polski`, id: "pl" },
24
+ { land: i18n`保加利亚语`, name: `Български`, id: "bul", lang: "bg" },
25
+ { land: i18n`爱沙尼亚语`, name: `Eesti keel`, id: "est", lang: 'et' },
26
+ { land: i18n`罗马尼亚语`, name: `Română`, id: "rom", lang: 'ro' },
27
+ { land: i18n`斯洛文尼亚语`, name: `slovenski jezik`, id: "slo", lang: 'sl' },
28
+ ];
29
+ supports.forEach(s => s.key = s.id);
30
+ module.exports = supports;
@@ -28,4 +28,28 @@ var getLanguageIndexFromName = function (language) {
28
28
  i18n.setLanguage = function (language) {
29
29
  languageIndex = getLanguageIndexFromName(language);
30
30
  };
31
- if (this.navigator) i18n.setLanguage(this.navigator.language);
31
+ i18n.getIndex = function () {
32
+ return languageIndex;
33
+ };
34
+ i18n.setIndex = function (index) {
35
+ languageIndex = +index;
36
+ localStorage.setItem('language-index', index);
37
+ supports = [];
38
+ i18n.supports = supports;
39
+ i18n.reload();
40
+ };
41
+ var relaods = [];
42
+ i18n.reload = function () {
43
+ relaods.forEach(a => a());
44
+ };
45
+ i18n.setReloader = function () {
46
+ relaods = [];
47
+ for (var callback of arguments) {
48
+ if (isFunction(callback)) relaods.push(callback);
49
+ }
50
+ };
51
+ if (this.navigator) i18n.setLanguage(this.navigator.language);
52
+ var i = +localStorage.getItem('language-index');
53
+ if (i >= 0) i18n.setIndex(i);
54
+ else i18n.setIndex(languageIndex);
55
+ var supports;
@@ -15,32 +15,35 @@ if (!Promise) {
15
15
  var isThenable = function (pendding) {
16
16
  return pendding instanceof Promise || pendding && isFunction(pendding.then);
17
17
  };
18
+ var thro = function (error) {
19
+ // <!--
20
+ console.error(i18n`在异步过程中发现未处理的异常:`, error);
21
+ // -->
22
+ };
18
23
  var queue = [];
19
24
  var running = false;
20
- var run = function (q) {
25
+ var run = function () {
21
26
  while (queue.length) {
22
27
  var threads = queue.splice(0, queue.length);
23
28
  for (var t of threads) {
24
- var PromiseRejectReactions = t.PromiseRejectReactions.splice(0, t.PromiseRejectReactions.length);
25
- var PromiseFulfillReactions = t.PromiseFulfillReactions.splice(0, t.PromiseFulfillReactions.length);
29
+ var { $j, $s } = t;
30
+ var PromiseRejectReactions = $j.splice(0, $j.length);
31
+ var PromiseFulfillReactions = $s.splice(0, $s.length);
26
32
  if (t.oked) {
33
+ var oked = t.oked[0];
27
34
  for (var r of PromiseFulfillReactions) {
28
- r.call(null, t.oked[0]);
35
+ r(oked);
29
36
  }
30
37
  }
31
38
  if (t.ohed) {
32
39
  var throwed = t.throwed;
33
40
  t.throwed = true;
41
+ var ohed = t.ohed[0];
34
42
  if (!throwed && !PromiseRejectReactions.length) {
35
- // <!--
36
- console.warn(i18n`在异步过程中发现未处理的异常:`, t.ohed[0], t.ohed[1], t.ohed[2]);
37
- // -->
38
- requestAnimationFrame(function () {
39
- throw t.ohed[0];
40
- })
43
+ requestAnimationFrame(thro.bind(null, ohed));
41
44
  }
42
45
  for (var r of PromiseRejectReactions) {
43
- r.apply(null, t.ohed);
46
+ r(ohed);
44
47
  }
45
48
  }
46
49
  }
@@ -54,8 +57,8 @@ if (!Promise) {
54
57
  requestAnimationFrame(run);
55
58
  };
56
59
  var Promise = function (executor) {
57
- this.PromiseFulfillReactions = []; //thens
58
- this.PromiseRejectReactions = []; //catches
60
+ this.$j = []; // rejects
61
+ this.$s = []; // resolves
59
62
  this.oked = this.ohed = null;
60
63
  var p = this;
61
64
  var ResolvingFunctions_resolve = function (result) { //ok
@@ -82,7 +85,7 @@ if (!Promise) {
82
85
  a = onok(a);
83
86
  ok(a);
84
87
  } catch (e) {
85
- oh(e, onok, onoh);
88
+ oh(e);
86
89
  }
87
90
  };
88
91
  else resolve = ok;
@@ -91,13 +94,13 @@ if (!Promise) {
91
94
  a = onoh.apply(null, arguments);
92
95
  ok(a);
93
96
  } catch (e) {
94
- oh(e, onok, onoh);
97
+ oh(e);
95
98
  }
96
99
  };
97
100
  else reject = oh;
98
101
  })
99
- if (resolve) this.PromiseFulfillReactions.push(resolve);
100
- if (reject) this.PromiseRejectReactions.push(reject);
102
+ if (resolve) this.$s.push(resolve);
103
+ if (reject) this.$j.push(reject);
101
104
  if (this.oked || this.ohed) fire(this);
102
105
  return promise;
103
106
  }
@@ -107,7 +110,7 @@ if (!Promise) {
107
110
  Promise.all = function (penddings) {
108
111
  return new Promise(function (ok, oh) {
109
112
  if (!(penddings && penddings.length)) {
110
- return ok();
113
+ return ok([]);
111
114
  }
112
115
  var resolved_count = 0,
113
116
  results = Array(penddings.length);
@@ -4,11 +4,12 @@ var id = 0;
4
4
  WeakMap = class WeakMap {
5
5
  id = "#" + ++id;
6
6
  get(o) {
7
+ if (o == null) return;
7
8
  return o[this.id];
8
9
  }
9
10
  set(o, v) {
10
11
  defineObj.value = v;
11
- Object.defineProperty(o, this.id, defineObj);
12
+ defineProperty(o, this.id, defineObj);
12
13
  }
13
14
  has(o) {
14
15
  return this.id in o;
@@ -19,18 +20,23 @@ WeakMap = class WeakMap {
19
20
  }
20
21
  var defineObj = {
21
22
  value: null,
22
- enumerable: true,
23
+ enumerable: false,
23
24
  writable: true,
24
- configurable: false
25
+ configurable: true
25
26
  }
26
27
  var defineProperty = Object.defineProperty;
27
28
  try {
28
29
  defineProperty(document, '#weakmap', defineObj);
29
30
  delete document["#weakmap"];
30
31
  } catch {
31
- defineProperty = function (o, k, d) {
32
- o[k] = d.value;
32
+ try {
33
+ delete defineObj.enumerable;
34
+ defineProperty(document, '#weakmap', defineObj);
35
+ delete document["#weakmap"];
36
+ } catch {
37
+ defineProperty = function (o, k, d) {
38
+ o[k] = d.value;
39
+ }
33
40
  }
34
- delete defineObj.enumerable;
35
41
  }
36
42
  return WeakMap;
@@ -76,7 +76,7 @@ class Program {
76
76
  ["`", "`", /\\[\s\S]/, ["${", "}"]],
77
77
  ]
78
78
  tags = [
79
- [["<", "</"], /\/?>/, /\\[\s\S]/, "'", '"', "<!--", ["${", "}"]]
79
+ [["<", "</"], /\/?>/, /\\[\s\S]/, "'", '"', "<!--", ["${", "}"], ["<%", "%>"]]
80
80
  ];
81
81
  scriptTags = [];
82
82
  ignoreTags = ["STYLE", "SCRIPT"];
@@ -90,6 +90,7 @@ class Program {
90
90
  ["(", ")"],
91
91
  ["[", "]"],
92
92
  ["{", "}"],
93
+ ["<%", "%>"],
93
94
  ]
94
95
  stamps = "/=+;|:?<>-!~%^&*,".split("");
95
96
  prefix = '&^%?:'.split('');
@@ -1048,8 +1049,7 @@ class Program {
1048
1049
  this.stamps.forEach(s => {
1049
1050
  if (s.length === 1) tokens[s] = true;
1050
1051
  });
1051
- var scopes = this.scopes.map(a => a.join("")).join("");
1052
- scopes = this.compile(scopes);
1052
+ var scopes = this.scopes.map(a => a.map(this.compile).join("|")).join("|");
1053
1053
  tokens = Object.keys(tokens).join("");
1054
1054
  tokens = this.compile(tokens);
1055
1055
  var express = `(?:\\\\u\\{[^\\}]+\\}|${spaceDefined.avoid(tokens, false)})+`;
@@ -1066,7 +1066,7 @@ class Program {
1066
1066
  this.prefix_reg = prefix_reg;
1067
1067
  var numbers = number_reg.source.replace(/^\^|\$$/g, "");
1068
1068
  this.digit_reg = new RegExp(/^[+\-]?/.source + numbers, number_reg.flags);
1069
- this.entry_reg = new RegExp([`${spaceDefined.reg.source}|${quotes_entries}|[${scopes}]|${numbers}(?:${spaceDefined.avoid(tokens)})*|${express}|${powers_entries}|[${stamps}]`], "gi");
1069
+ this.entry_reg = new RegExp([`${spaceDefined.reg.source}|${quotes_entries}|${scopes}|${numbers}(?:${spaceDefined.avoid(tokens)})*|${express}|${powers_entries}|[${stamps}]`], "gi");
1070
1070
  var stamps = this.stamps.slice();
1071
1071
  for (var k in this.powermap) {
1072
1072
  if (k.length === 1 && stamps.indexOf(k) < 0) stamps.push(k);
@@ -1,5 +1,5 @@
1
1
  <div>
2
- <btn -if="hasedit" @click="add()">添加</btn>
2
+ <btn -if="hasedit" @click="add()">${i18n`添加`}</btn>
3
3
  <btn -repeat="b in buttons" @click="b.do()">
4
4
  <span -text="b.name"></span>
5
5
  </btn>
@@ -65,7 +65,7 @@ function main(title, { fields, options: options0, load, remove, buttons }, edit_
65
65
  this.data = load();
66
66
  },
67
67
  fields: fields.filter(f => !f.hidden && f.inlist !== false).concat({
68
- name: "操作",
68
+ name: i18n`操作`,
69
69
  options
70
70
  }),
71
71
  buttons,
@@ -1,6 +1,15 @@
1
- (document.body.hasAttribute('menu-path') || document.body.hasAttribute("menu") || document.body.hasAttribute("config-path") ? data.fromURL(document.body.getAttribute('menu-path') || document.body.getAttribute('menu') || document.body.getAttribute('config-path') || 'menu.yml').loading_promise : Promise.resolve([])).then(function (items) {
1
+ (document.body.hasAttribute('menu-path')
2
+ || document.body.hasAttribute("menu")
3
+ || document.body.hasAttribute("config-path")
4
+ ? data.fromURL(document.body.getAttribute('menu-path')
5
+ || document.body.getAttribute('menu')
6
+ || document.body.getAttribute('config-path')
7
+ || 'menu.yml'
8
+ ).loading_promise
9
+ : Promise.resolve([])
10
+ ).then(function (items) {
2
11
  var result = [];
3
- var menuid = 0;
12
+ var idmap = Object.create(null);
4
13
  var savedChildren = Object.create(null);
5
14
  var savedMenus = Object.create(null);
6
15
  var keymap = {};
@@ -30,10 +39,6 @@
30
39
  if (!icon && /(?!\.)\.(?=[\w\-])/.test(k)) {
31
40
  icon = k.slice(k.indexOf(/(?!\.)\.(?=[\w\-])/));
32
41
  }
33
- if (!icon && /\s+/.test(k)) {
34
- [icon] = k.split(/\s+/);
35
- k = k.slice(icon.length).trim();
36
- }
37
42
  if (!name) name = k;
38
43
  var item = {};
39
44
  if (icon) item.icon = icon.replace(/\./g, ' ');
@@ -52,7 +57,10 @@
52
57
  }
53
58
  var getChildren = function (menu) {
54
59
  if (!menu.id) {
55
- menu.id = ++menuid;
60
+ var pathid = menu.path;
61
+ if (!idmap[pathid]) idmap[pathid] = 0;
62
+ menu.id = (menu.path || "") + "#" + idmap[pathid];
63
+ idmap[pathid]++;
56
64
  }
57
65
  if (!savedMenus[menu.id]) {
58
66
  savedMenus[menu.id] = menu;
@@ -124,6 +132,10 @@
124
132
  result.update = function (items) {
125
133
  delete result.loading_promise;
126
134
  delete result.then;
135
+ delete result.active;
136
+ savedChildren = Object.create(null);
137
+ savedMenus = Object.create(null);
138
+ idmap = Object.create(null);
127
139
  firstMenu = null;
128
140
  items = result.parse(items);
129
141
  items.map(getChildren);
@@ -158,7 +170,7 @@
158
170
  if (actived_value === historys.length) {
159
171
  setActive(actived, true);
160
172
  result.active = actived;
161
- };
173
+ }
162
174
  }
163
175
  }
164
176
  first_opened = false;
@@ -195,6 +207,7 @@
195
207
  var menu = getChild(zimoli);
196
208
  if (!menu) return;
197
209
  if (menu !== result.active) {
210
+ console.log(zimoli, menu);
198
211
  setActive(result.active, false);
199
212
  setActive(menu, true);
200
213
  result.active = menu;
@@ -210,6 +223,7 @@
210
223
  result.open = function (menu) {
211
224
  if (!menu) {
212
225
  if (first_opened && result.active) return;
226
+ if (!result.length) result.update(items);
213
227
  var zimoilPath = zimoli.getInitPath();
214
228
  menu = result.active || findMenu(zimoilPath) || firstMenu;
215
229
  if (!menu?.path) return;
@@ -280,6 +294,5 @@
280
294
  ok(result);
281
295
  result.then = then;
282
296
  };
283
- result.update(items);
284
297
  return result;
285
298
  });
@@ -9,13 +9,16 @@
9
9
  display: block;
10
10
  text-align: center;
11
11
  }
12
+
12
13
  </style>
13
14
  <div>
14
- <a @click="logout">${i18n`退出登录`}</a>
15
+ <i18n-chooser style="float: left;"></i18n-chooser>
16
+ <a @click="logout" -bind="exitLabel()"></a>
15
17
  </div>
16
18
 
17
19
  <script>
18
20
  var a = button;
21
+ var exitLabel = () => i18n`退出登录`;
19
22
  async function logout() {
20
23
  data.setSource({});
21
24
  await user.Logout();
@@ -3,7 +3,7 @@ function chooseFile(accept, multiple, extra) {
3
3
  form.innerHTML = `<input tabindex=0 ${extra ? extra + " " : ''}type='file'${accept ? ` accept="${accept}"` : ''}${multiple ? ' multiple' : ''} />`;
4
4
  var [input] = form.children;
5
5
  var result = new Promise(function (ok, oh) {
6
- if (/msie\s+[2-9]/i.test(navigator.userAgent)) return alert("无法在当前浏览器操作!");
6
+ if (/msie\s+[2-9]/i.test(navigator.userAgent)) return alert(i18n`无法在当前浏览器操作!`);
7
7
  input.onfocus = function () {
8
8
  // focus 事件比change事件早40-80毫秒
9
9
  if (opened && document.hasFocus()) {
@@ -50,7 +50,7 @@ var _create = function (commFactory, className, _invoke) {
50
50
  var head = document.getElementsByTagName("head")[0];
51
51
  function cless(commFactory, innerCss, className) {
52
52
  if (innerCss) {
53
- var stylesheet = document.createElement("style");
53
+ var stylesheet = isNode(this) ? this : document.createElement("style");
54
54
  //<!-- stylesheet.setAttribute("scope",className) -->
55
55
  stylesheet.type = "text/css";
56
56
  stylesheet.savedText = innerCss;
@@ -59,7 +59,7 @@ function cless(commFactory, innerCss, className) {
59
59
  } else {
60
60
  stylesheet.innerHTML = innerCss;
61
61
  }
62
- appendChild(head, stylesheet);
62
+ if (!stylesheet.parentNode) appendChild(head, stylesheet);
63
63
  }
64
64
  return _create(commFactory, className, _create);
65
65
  }
@@ -1,7 +1,7 @@
1
1
  var URL = window.URL, Blob = window.Blob;
2
2
  function main(basepath) {
3
3
  if (!URL || !Blob) {
4
- alert("无法在当前浏览器操作!");
4
+ alert(i18n`无法在当前浏览器操作!`);
5
5
  return;
6
6
  }
7
7
  var url = URL.createObjectURL(new Blob);
@@ -8,7 +8,7 @@
8
8
  <model _data=data _field=field _readonly="readonly"></model>
9
9
  <container class="error" -src="error"></container>
10
10
  </div>
11
- <div class="foot" ng-if="field.msg">
11
+ <div ng-if="field.msg">
12
12
  <span ng-bind=field.msg></span>
13
13
  </div>
14
14
  </template>
@@ -27,6 +27,7 @@ var reshape = function () {
27
27
  }
28
28
  if (!body) body = head;
29
29
  if (foot && body) {
30
+ console.log(foot)
30
31
  var right = foot.offsetWidth + 1;
31
32
  if (isInlineBlock && right < (this.break || body.offsetWidth >> 2)) {
32
33
  css(foot, {
@@ -6,6 +6,8 @@ function main(elem, scope, hasIcon) {
6
6
  if (isObject(scope) && scope !== ms) {
7
7
  }
8
8
  else if (ms) {
9
+ var parentScopes = hasIcon;
10
+ hasIcon = null;
9
11
  var scope = ms;
10
12
  }
11
13
  var menu = scope;
@@ -21,7 +23,7 @@ function main(elem, scope, hasIcon) {
21
23
  checker,
22
24
  };
23
25
  if (hasIcon || menu.icon) scope.hasIcon = true;
24
- render(item.children, scope);
26
+ render(item.children, scope, parentScopes);
25
27
  if (menu.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
26
28
  return item;
27
29
  }
@@ -779,8 +779,9 @@ var directives = {
779
779
  return src2.call(this, parsedSrc && /[\{\[\s]/.test(src) ? parsedSrc.srcName : src);
780
780
  },
781
781
  model(search, target, change) {
782
- var getter = createGetter(this, search);
783
- var setter = createSetter(this, search);
782
+ search = search.split(',');
783
+ var getter = search.length > 1 ? createGetter(this, search[0])(this) : createGetter(this, search[0]);
784
+ var setter = search.length > 1 ? createGetter(this, search[1] || search[0])(this) : createSetter(this, search[0]);
784
785
  var model = new Model(getter, setter, target);
785
786
  return model.hook(this, change !== false);
786
787
  },
@@ -173,7 +173,7 @@ function main() {
173
173
  })
174
174
  if (addable) {
175
175
  var adder = document.createElement("div");;
176
- adder.innerHTML = "<a>添加</a><a>管理</a>";
176
+ adder.innerHTML = `<a>${i18n`添加`}</a><a>${i18n`管理`}</a>`;
177
177
  adder.setAttribute('insert', '');
178
178
  button(adder.firstChild);
179
179
  button(adder.children[1]);
@@ -182,10 +182,10 @@ function main() {
182
182
  var target = getTargetIn(this, event.target, false);
183
183
  switch (target) {
184
184
  case this.children[0]:
185
- var a = prompt("请输入", a => {
185
+ var a = prompt(i18n`请输入`, a => {
186
186
  if (!a) return false;
187
187
  if (a in itemMap) {
188
- return `选项 ${a} 已存在!`;
188
+ return i18n`选项 ${a} 已存在!`;
189
189
  }
190
190
  });
191
191
  page.with = a;