efront 3.9.10 → 3.9.11

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,4 +1,4 @@
1
- / authorization:
1
+ / authorization=:
2
2
  login: options ::login-:a
3
3
  run: options :::run
4
4
  share: options ::share-:opt?:path
@@ -23,14 +23,13 @@ function main() {
23
23
  this.$scope.pending = true;
24
24
  page.disabled = true;
25
25
  try {
26
- var login = await data.getApi("login");
27
- login.base = location.protocol + "//" + parseURL(this.$scope.data.host).host + "/";
28
- data.setInstance("base", { base: login.base, host: parseURL(login.base).host });
29
- var info = await data.from(login, {
26
+ var base = location.protocol + "//" + parseURL(this.$scope.data.host).host + "/";
27
+ data.setInstance("base", { base, host: parseURL(base).host });
28
+ var info = await data.from("login", {
30
29
  a: encode62.timeencode(encode62.geta(password))
31
30
  }).loading_promise;
32
31
  info = encode62.timeupdate(info);
33
- data.setSource({ authorization: info });
32
+ data.setSource(base, info);
34
33
  user.login({})
35
34
  go('/main')
36
35
  } catch (e) {
@@ -15,7 +15,7 @@ function main() {
15
15
  target.removeAttribute('pending');
16
16
  },
17
17
  async logout() {
18
- data.setSource('authorization', null);
18
+ data.setSource({});
19
19
  await user.Logout();
20
20
  zimoli.switch();
21
21
  zimoli();
@@ -1,26 +1,38 @@
1
1
  data.loadConfig("api.yml");
2
2
  user.loginPath = '/auth/login';
3
- var token = data.getSource('authorization');
4
- if (token) {
5
- user.login({});
6
- }
3
+ data.setReporter(function (m, t) {
4
+ alert(m, t);
5
+ var base = data.getInstance("base").base;
6
+ data.setSource(base, '');
7
+ if (m.status === 401) location.reload();
8
+ });
7
9
  data.bindInstance("base", async function (base) {
10
+ if (!base.base) return;
8
11
  cross.addDirect(base.base);
9
12
  var apimap = await data.getConfig();
10
13
  for (var k in apimap) {
11
14
  apimap[k].base = base.base;
12
15
  }
13
16
  });
17
+ var base = data.getInstance('base').base;
18
+ var token = base && data.getSource(base);
19
+ if (token) {
20
+ user.login({});
21
+ }
14
22
  setInterval(function () {
15
- var auth = data.getSource('authorization');
16
- if (!auth) return;
23
+ var base = data.getInstance("base");
24
+ if (!base.base) return user.token = null;
25
+ var auth = data.getSource(base.base);
26
+ if (!auth) return user.token = null;
17
27
  var auth1 = encode62.timeupdate(auth);
18
- if (auth1 !== auth) data.setSource("authorization", auth1);
28
+ if (auth1 !== auth) data.setSource(base.base, auth1);
19
29
  user.token = auth1;
20
30
  }, 2000);
21
31
  login();
22
32
  var layer = layer$glance({
23
- left: frame$left,
33
+ left: frame$left.bind({
34
+ head: await init("left-header")
35
+ }),
24
36
  top: frame$top
25
37
  });
26
38
  on("append")(layer, function () {
@@ -10,7 +10,7 @@ function main() {
10
10
  if (!$scope.pathlist.length) {
11
11
  return;
12
12
  }
13
- $scope.pathlist.pop();
13
+ data.setInstance("pathlist", $scope.pathlist.slice(0, -1));
14
14
  $scope.open();
15
15
  return false;
16
16
  }
@@ -18,11 +18,11 @@ function main() {
18
18
 
19
19
  renderWithDefaults(page, {
20
20
  lattice,
21
- pathlist: [],
21
+ pathlist: data.getInstance("pathlist"),
22
22
  active: null,
23
23
  open(p) {
24
24
  if (p) p = String(p.name || '').replace(/\/$/, '');
25
- if (p) this.pathlist.push(p);
25
+ if (p) data.setInstance("pathlist", this.pathlist.concat(p));
26
26
  this.data = data.from("folder", { opt: 'list', path: "/" + this.pathlist.join('/') }, files => {
27
27
  if (files) return sortname(files).map(f => {
28
28
  return {
@@ -1,5 +1,5 @@
1
- // -------/// ---------------1-------------//////////////2---3--------//////// ----4----2/////5-----------------------6-----------------------//////////////-7--5///8----9----//10--11---10///--12-----8//
2
- var reg = /^([^\:\/\?#\[]+\:(?![^\:\/\?\#]*@))?(?:\/\/)?(?:(([^\:\/\?#]+)?(?:\:([^\/\?#]+))?)@)?(([^\/@\:\?\#]*(?:[^\d\@\:\/\?#]|\.)[^\/@\?\#]*?)?(?:(?:\:|^)(\d+))?)((\/[^\?#]*)?(\?([^#]*))?(#[\s\S]*)?)$/;
1
+ // -------/// ---------------1---------------------------------///////////////////2-----3--------//////// ------4----2/////5---------------------------------------------------6-----------------------------------------------------------------------------//////////////-7--5///8-------9----------//10--11---10///--12-----8//
2
+ var reg = /^([^\:\/\\\?#\[]+\:(?![^\:\/\\\?\#]*@|[\/\\][^\/\\]))?(?:\/\/|\\\\)?(?:(([^\:\/\\\?#]+)?(?:\:([^\/\\\?#]+))?)@)?(([^\/\\@\?\#\.]*?[^\/\\@\:\?\#\.\d][^\/\\@\:\?\#\.]*?|[^\/\\@\:\?\#\.]+(?:\:[\@\/\\\?#\.]*[^\d\@\:\/\\\?#\.]+|\.[^\/\\@\:\?\#]+?))?(?:(?:\:|^)(\d+))?)(((?:\/|\\|^)[^\?#]*)?(\?([^#]*))?(#[\s\S]*)?)$/;
3
3
  function parseURL(url) {
4
4
  if (url === undefined || url === null) url = '';
5
5
  var [__, protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash] = reg.exec(url);
@@ -36,4 +36,10 @@ test("http://[::]/", "host", "[::]")
36
36
  test("http://[::%12]/", "host", "[::%12]")
37
37
  test("http://[::]:80/", "hostname", "[::]")
38
38
  test("[::]:80/", "hostname", "[::]")
39
- test("[fd64:f52:f52:f52:f52:f52:f52:97]", "hostname", "[fd64:f52:f52:f52:f52:f52:f52:97]")
39
+ test("[fd64:f52:f52:f52:f52:f52:f52:97]", "hostname", "[fd64:f52:f52:f52:f52:f52:f52:97]")
40
+ test("./cluster-opt.html", "pathname", "./cluster-opt.html")
41
+ test(":cluster-opt.html", "pathname", ":cluster-opt.html")
42
+ test("d:/cluster-opt.html", "pathname", "d:/cluster-opt.html")
43
+ test("d:\\cluster-opt.html", "pathname", "d:\\cluster-opt.html")
44
+ test("ftp:\\\\cluster-opt.html", "host", "cluster-opt.html")
45
+ test("\\\\cluster-opt.html", "host", "cluster-opt.html")
@@ -1,10 +1,11 @@
1
1
  var seek = function (object, seeker) {
2
- if (seeker === null || seeker === undefined || !object) return;
2
+ if (seeker === null || seeker === undefined || isEmpty(object)) return;
3
3
  if (seeker instanceof Function) {
4
4
  return seeker(object);
5
5
  }
6
6
  if (typeof seeker === "string") {
7
7
  if (/^(['"`])[\s\S]*$/i.test(seeker)) return seeker.replace(/^(['"`])([\s\S*])\1?$/, "$2");
8
+ if (seeker === '' || seeker === ".") return object;
8
9
  seeker = seeker.split(".");
9
10
  }
10
11
  if (seeker instanceof Array) {
@@ -82,17 +82,17 @@ var parse干支 = function (a) {
82
82
  return (12 + g - z) % 12 / 2 * 10 + g + 1;
83
83
  };
84
84
  var compare = function (a, b) {
85
- for (var cx1 = a.length - 1, cx2 = a.length - 1; cx1 >= 0 && cx2 >= 0; cx1--, cx2--) {
85
+ for (var cx1 = a.length - 1, cx2 = b.length - 1; cx1 >= 0 && cx2 >= 0; cx1--, cx2--) {
86
86
  while (/\s\u00a0/.test(a[cx1])) cx1--;
87
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;
88
+ if (a[cx1] !== b[cx2] || a[cx1] in map子丑寅 || a[cx1] in map一二三 || a in power || /^\d$/.test(a[cx1])) break;
89
89
  }
90
90
  a = a.slice(0, cx1 + 1);
91
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++) {
92
+ for (var cx1 = 0, cx2 = 0, dx1 = b.length, dx2 = b.length; cx1 < dx1 && cx2 < dx2; cx1++, cx2++) {
93
93
  while (/[\s\u00a0]/.test(a[cx1])) cx1++;
94
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;
95
+ if (a[cx1] !== b[cx2] || a[cx1] in map甲乙丙 || a[cx1] in map一二三 || a in power || /^\d/.test(a[cx1])) break;
96
96
  }
97
97
  if (cx1) a = a.slice(cx1);
98
98
  if (cx2) b = b.slice(cx2);
@@ -1,13 +1,13 @@
1
- <div ng-if="!user.isLogin" class="navbar-header">
1
+ <header ng-if="!user.isLogin" class="navbar-header">
2
2
  <!-- <avatar></avatar> -->
3
3
  <a @click="popup('#/user/login')" class="dashboard_text">请登录</a>
4
- </div>
5
- <div -else class="navbar-header">
4
+ </header>
5
+ <header -else class="navbar-header">
6
6
  <span class="dashboard_text" @click="go('/user/profile')">
7
7
  <avatar ng-src="user.avatar" size=30></avatar>
8
8
  <span ng-bind="user.name"></span>
9
9
  <span ng-bind="user.roles"></span>
10
10
  </span>
11
- </div>
11
+ </header>
12
12
  <ylist mode=inline ng-src="menu in menus" class="sidebar-menu" ng-active="menus.open(event.value)">
13
13
  </ylist>
@@ -1,18 +1,21 @@
1
- var page = document.createElement("都说我负天下人_可你们天下人_又何曾善待过我");
2
- page.innerHTML = left;
3
1
  if (!user.avatar) user.avatar = "user/avatar.png";
4
- render(page, {
5
- ylist: menu,
6
- btn: button,
7
- go,
8
- user,
9
- avatar,
10
- popup,
11
- menus: frame$route,
12
- });
13
- on('append')(page, function () {
14
- frame$route.open();
15
- });
16
2
  function main() {
3
+ var page = document.createElement("都说我负天下人_可你们天下人_又何曾善待过我");
4
+ page.innerHTML = template;
5
+ var { head, foot, header = head, footer = foot } = this;
6
+ render(page, extend({
7
+ ylist: menu,
8
+ btn: button,
9
+ go,
10
+ user,
11
+ avatar,
12
+ header,
13
+ footer,
14
+ popup,
15
+ menus: frame$route,
16
+ }, this));
17
+ on('append')(page, function () {
18
+ frame$route.open();
19
+ });
17
20
  return page;
18
21
  }
@@ -4,13 +4,14 @@
4
4
  }
5
5
 
6
6
  .navbar-header {
7
- height: 50px;
7
+ min-height: 50px;
8
8
  padding: 10px 15px 10px 25px;
9
9
  font-size: 25px;
10
10
  line-height: 25px;
11
11
  text-transform: uppercase;
12
12
  color: #b8c7ce;
13
13
  margin-top: -50px;
14
+ display: block;
14
15
  }
15
16
 
16
17
  .dashboard_text {
@@ -0,0 +1 @@
1
+ <select -model="host" @change="setHost(this.value)" direction=y addable><option -repeat="h in hosts" :value=h.key -text="h.name"></option></select>
@@ -0,0 +1,15 @@
1
+ function main() {
2
+ var a = document.createElement("菜单之上");
3
+ a.innerHTML = template;
4
+ render(a, {
5
+ setHost(a) {
6
+ data.setInstance("base", { base: location.protocol + "//" + a + "/", host: a });
7
+ data.abortAll();
8
+ zimoli();
9
+ },
10
+ host: data.getInstance("base").host,
11
+ select,
12
+ hosts: data.getInstance("hosts")
13
+ });
14
+ return a;
15
+ }
@@ -0,0 +1,11 @@
1
+ &.navbar-header {
2
+ padding: 0;
3
+ }
4
+
5
+ select {
6
+ background: transparent;
7
+ color: inherit;
8
+ height: 50px;
9
+ margin: 0;
10
+ width: 100%;
11
+ }
@@ -35,6 +35,8 @@ function alert() {
35
35
  [].map.call(arguments, function (arg) {
36
36
  switch (typeof arg) {
37
37
  case "string":
38
+ case "object":
39
+ arg = String(arg);
38
40
  if (!text) {
39
41
  text = arg;
40
42
  } else if (color_reg.test(text)) {
@@ -8,7 +8,7 @@ function create(commFactory, className) {
8
8
  }
9
9
  if (isFunction(commFactory)) {
10
10
  var result = function () {
11
- var commRelease = commFactory.apply(result, arguments);
11
+ var commRelease = commFactory.apply(this || result, arguments);
12
12
  if (commRelease) {
13
13
  commRelease = create(commRelease, className);
14
14
  }
@@ -154,13 +154,19 @@ function cross(method, url, headers) {
154
154
  xhr.onerror = function (e) {
155
155
  onerror(e);
156
156
  };
157
+ xhr.abort = function () {
158
+ removeFromList(requests, this);
159
+ remove(this);
160
+ };
157
161
  } else {
158
162
  var nocross = notCross(url);
159
163
  var xhr = new XMLHttpRequest;
160
164
  var abort = xhr.abort;
161
165
  xhr.abort = function () {
162
166
  xhr.onreadystatechange = null;
167
+ removeFromList(requests, this);
163
168
  abort.call(this);
169
+ clearTimeout(sendtimer);
164
170
  };
165
171
 
166
172
  xhr.onreadystatechange = function () {
@@ -217,7 +223,7 @@ function cross(method, url, headers) {
217
223
  onerrors.push(oh);
218
224
  flush();
219
225
  };
220
- setTimeout(function () {
226
+ var sendtimer = setTimeout(function () {
221
227
  digest();
222
228
  var isform = /^f/i.test(method);
223
229
  if (isform) {
@@ -252,6 +258,7 @@ function cross(method, url, headers) {
252
258
  }
253
259
  var loaded, errored;
254
260
  var onload = function (xhr) {
261
+ removeFromList(requests, xhr);
255
262
  if (xhr.decoder) {
256
263
  xhr = xhr.decoder(xhr);
257
264
  }
@@ -260,6 +267,7 @@ function cross(method, url, headers) {
260
267
  digest();
261
268
  };
262
269
  var onerror = function (xhr) {
270
+ removeFromList(requests, xhr);
263
271
  errored = xhr;
264
272
  flush();
265
273
  digest();
@@ -317,6 +325,7 @@ function cross(method, url, headers) {
317
325
  flush();
318
326
  return xhr;
319
327
  };
328
+ requests.push(xhr);
320
329
  return xhr;
321
330
  }
322
331
  function addDirect(a) {
@@ -335,7 +344,14 @@ function notCross(domain) {
335
344
  }
336
345
  return false;
337
346
  }
347
+
348
+ var requests = [];
338
349
  extend(cross, {
350
+ requests,
351
+ abortAll() {
352
+ var rs = requests.splice(0, requests.length);
353
+ for (var r of rs) r.abort();
354
+ },
339
355
  setHost,
340
356
  getCookies,
341
357
  addCookie,
@@ -72,7 +72,13 @@ const formulaters = {
72
72
  return formulate(data, params);
73
73
  }
74
74
  };
75
-
75
+ var seekFromSource = function (obj, base) {
76
+ var source = dataSourceMap;
77
+ if (base && base in dataSourceMap) source = source[base];
78
+ obj = seek(source, obj);
79
+ if (isObject(obj)) for (var k in obj) if (obj[k] === dataSourceMap) delete obj[k];
80
+ return obj;
81
+ };
76
82
  function getErrorMessage(error = this) {
77
83
  if (!isObject(error)) return String(error);
78
84
  if (error instanceof Error) return String(error);
@@ -543,7 +549,7 @@ var privates = {
543
549
  if (!promise || currentTime - promise.time > 60 || temp !== promise.params || promise.search !== search) {
544
550
  var promise = new Promise(function (ok, oh) {
545
551
  if (headers) {
546
- headers = seek(dataSourceMap, headers);
552
+ headers = seekFromSource(headers, api.base);
547
553
  }
548
554
  cross(realmethod, uri, headers).send(params).done(e => {
549
555
  ok(e.response || e.responseText);
@@ -555,6 +561,7 @@ var privates = {
555
561
  oh(error);
556
562
  }
557
563
  });
564
+ updateLoadingCount();
558
565
  });
559
566
  promise.search = search;
560
567
  promise.params = temp;
@@ -609,7 +616,6 @@ var loadInstance = function (storage, id) {
609
616
  };
610
617
 
611
618
  function responseCrash(e, data) {
612
- if (data.is_loading) this.loading_count--;
613
619
  data.is_errored = true;
614
620
  data.is_loading = false;
615
621
  data.error_message = getErrorMessage(e);
@@ -619,19 +625,24 @@ function responseCrash(e, data) {
619
625
  } else {
620
626
  data.error = e;
621
627
  }
622
- error_report(data.error_message, e.status < 500 ? 'warn' : 'error');
628
+ error_report(e, e.status < 500 ? 'warn' : 'error');
629
+ updateLoadingCount();
623
630
  }
624
631
  var getData = function () { return this.data };
632
+ var updateLoadingCount = function () {
633
+ data.loading_count = cross.requests.length;
634
+ };
625
635
  var data = {
626
636
  decodeStructure,
627
637
  encodeStructure,
638
+ abortAll: cross.abortAll,
628
639
  responseLoaded(response) {
629
640
  if (isObject(response)) {
630
641
  response.is_loaded = true;
631
642
  response.is_loading = false;
632
643
  if (response.then === LoadingArray_then) delete response.then;
633
644
  }
634
- this.loading_count--;
645
+ updateLoadingCount();
635
646
  },
636
647
  responseCrash,
637
648
  responseLoading(response) {
@@ -640,7 +651,6 @@ var data = {
640
651
  response.is_loading = true;
641
652
  response.then = LoadingArray_then;
642
653
  }
643
- this.loading_count++;
644
654
  },
645
655
  setReporter(report, checker) {
646
656
  if (report instanceof Function) {
@@ -840,7 +850,6 @@ var data = {
840
850
  if (promise1 !== instance.loading_promise) throw outdate;
841
851
  if (instance.loading) {
842
852
  instance.loading.abort();
843
- data.loading_count--;
844
853
  }
845
854
  this.responseLoading(instance);
846
855
  var params = privates.pack(sid, params1);
@@ -852,7 +861,7 @@ var data = {
852
861
  var promise = new Promise(function (ok, oh) {
853
862
  var headers = api.headers;
854
863
  if (headers) {
855
- headers = seek(dataSourceMap, headers);
864
+ headers = seekFromSource(headers, api.base);
856
865
  }
857
866
  instance.loading = cross(method, uri, headers).send(params).done(xhr => {
858
867
  if (instance.loading !== xhr) return oh(aborted);
@@ -862,11 +871,13 @@ var data = {
862
871
  if (instance.loading !== xhr) return oh(aborted);
863
872
  instance.loading = null;
864
873
  try {
865
- oh(parseData(xhr.response || xhr.responseText || xhr.statusText || xhr.status));
874
+ var e = getErrorMessage(parseData(xhr.response || xhr.responseText || xhr.statusText || xhr.status));
875
+ oh({ status: xhr.status, error: e, toString: getErrorMessage })
866
876
  } catch (error) {
867
877
  oh(error);
868
878
  }
869
879
  });
880
+ updateLoadingCount();
870
881
  }).then(function (response) {
871
882
  return transpile(seekResponse(parseData(response), selector), api.transpile, api.root);
872
883
  });
@@ -884,7 +895,6 @@ var data = {
884
895
  });
885
896
  promise1.catch((e) => {
886
897
  if (e === outdate) return;
887
- if (e === aborted) return data.loading_count--;
888
898
  this.responseCrash(e, instance);
889
899
  });
890
900
 
@@ -42,6 +42,9 @@ function select(target, list, removeOnSelect, direction) {
42
42
  direction = removeOnSelect;
43
43
  removeOnSelect = arguments[3];
44
44
  }
45
+ if (direction === undefined) {
46
+ direction = target.getAttribute("direction") || target.direction;
47
+ }
45
48
  if (!target) {
46
49
  target = document.createElement("select");
47
50
  }
@@ -63,11 +66,13 @@ function select(target, list, removeOnSelect, direction) {
63
66
  var onlistchange = function () {
64
67
  if (target.multiple) {
65
68
  } else {
66
- if (!savedOptions) {
67
- target.innerHTML = `<option selected value="${this.value}">${this.name || this.value}</option>`
69
+ if (target.value !== this.value) {
70
+ if (!savedOptions) {
71
+ target.innerHTML = `<option selected value="${this.value}">${this.name || this.value}</option>`
72
+ }
73
+ target.value = this.value;
74
+ dispatch(target, "change");
68
75
  }
69
- target.value = this.value;
70
- dispatch(target, "change");
71
76
  }
72
77
  };
73
78
  var onlistclick = function (event) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.9.10",
3
+ "version": "3.9.11",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {