efront 3.7.0 → 3.7.6

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,7 +4,6 @@ var fields = refilm`
4
4
  服务器地址/host* select?a ${hosts}
5
5
  密码/password* password
6
6
  `;
7
- console.log(fields)
8
7
  function main() {
9
8
  var page = view();
10
9
  page.innerHTML = login;
@@ -1,5 +1,5 @@
1
1
  <div class="clusters">
2
- <a -repeat="(c,i) in clusters" @click="active(i)">
2
+ <a -repeat="(c,i) in clusters" ng-class="{current:i===index}" @click="active(i,c)">
3
3
  <span -text="c"></span>
4
4
  </a>
5
5
  </div>
@@ -7,6 +7,6 @@
7
7
  <padding>
8
8
  <span -text=c.id></span>
9
9
  <span class="time" -text=filterTime(c.optime)></span>
10
-
10
+
11
11
  </padding>
12
12
  </lattice>
@@ -3,21 +3,21 @@ function main() {
3
3
  page.innerHTML = template;
4
4
  renderWithDefaults(page, {
5
5
  async load() {
6
- var cs = this.clusters = data.from("cluster", { opt: "list" });
7
- await cs.loading_promise;
6
+ this.clusters = data.from("cluster", { opt: "list" });
7
+ await this.clusters;
8
8
  this.active();
9
9
  },
10
- index: 0,
10
+ index: data.getInstance("index").index || 0,
11
11
  clusters: [],
12
12
  filterTime(d) {
13
13
  return ((new Date - d) / 1000 | 0) + "秒";
14
14
  },
15
15
  clients: [],
16
- async active() {
17
- var index = this.index;
16
+ active(index = this.index) {
17
+ data.setInstance('index', { index });
18
18
  var clusters = this.clusters;
19
19
  if (index >= clusters.length) index = clusters.length - 1;
20
- this.clients = data.lazyInstance("cluster", { opt: "list", id: clusters[index] });
20
+ this.clients = data.from("cluster", { opt: "list", id: clusters[index] });
21
21
  },
22
22
  });
23
23
  page.$scope.load();
@@ -6,4 +6,9 @@
6
6
 
7
7
  .time {
8
8
  color: #bbb;
9
+ }
10
+
11
+ .button.current {
12
+ background: #28c;
13
+ color: #fff;
9
14
  }
@@ -1,5 +1,6 @@
1
1
  frame$edit.bind(null, "密钥", {
2
- submit(a) {
2
+ submit(a, fields) {
3
+ a = submit(fields, a);
3
4
  return data.from("private-edit", {
4
5
  key: encode62.timeencode(a.key),
5
6
  value: encode62.timeencode(JSON.stringify(a)),
@@ -6,8 +6,8 @@ frame$list.bind(null, "密钥管理", {
6
6
  return data.from("private-edit", { key: encode62.timeencode(o.key), value: encode62.timeencode("") }).loading_promise;
7
7
  },
8
8
  fields: refilm`
9
- 显示名/name input
10
- *键名/key
11
- 密钥/value
12
- 备注/comment
9
+ *键名/key 100
10
+ 显示名/name input/300
11
+ 密钥/value text/100
12
+ 备注/comment text/200
13
13
  `}, "/token/edit");
@@ -1,6 +1,6 @@
1
1
  var d = 0b10000000, s = 0b00111111;
2
2
  function numberUTF8(t, dist = []) {
3
- if (t < 127) {//0b0xxxxxxx - 0b10xxxxxx
3
+ if (t < 128) {//0b0xxxxxxx - 0b10xxxxxx
4
4
  dist.push(0b00000000 | t)
5
5
  }
6
6
  else if (t < 2048) {// 0b110xxxxx 10xxxxxx
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  module.exports = encode62;
3
+ var encodeUTF8 = require("../basic/encodeUTF8");
4
+ var decodeUTF8 = require("../basic/decodeUTF8");
3
5
  var src = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
4
6
  var map = {};
5
7
  src.split("").forEach((s, i) => map[s] = i);
@@ -69,6 +71,20 @@ Object.assign(encode62, {
69
71
  });
70
72
  return result;
71
73
  },
74
+ encodestr(data, sign) {
75
+ if (!sign) return data;
76
+ var result = encodeUTF8(data);
77
+ sign = Buffer.from(sign);
78
+ var delta = 0, c = 0;
79
+ for (var cx = 0, dx = data.length; cx < dx; cx++) {
80
+ if (result[cx] < 128) result[cx] = result[cx] ^ sign[cx % sign.length];
81
+ else if (result[cx] < 192) {
82
+ var c = c << 8 | sign[(delta += 6) / 8 | 0];
83
+ result[cx] = result[cx] ^ (c >> 8 - delta % 8 & 0x3f);
84
+ }
85
+ }
86
+ return decodeUTF8(result);
87
+ },
72
88
  decode(data, sign) {
73
89
  if (!sign) return data;
74
90
  var result = Buffer.from(data);
@@ -101,5 +117,6 @@ Object.assign(encode62, {
101
117
  encode62.ab2c = encode62.ba2d = encode62.huan;
102
118
  encode62.db2a = encode62.ca2b = encode62.yuan;
103
119
  encode62.da2b = encode62.cb2a = encode62.suan;
120
+ encode62.decodestr = encode62.encodestr;
104
121
  encode62.encode = encode62.decode;
105
122
  encode62.decode62 = encode62.encode62;
@@ -18,7 +18,7 @@ function main(title, { submit }, { data: origin, fields, }) {
18
18
  });
19
19
  on('submit')(page, async function (e) {
20
20
  e.preventDefault();
21
- await submit(item);
21
+ await submit(item, fields);
22
22
  dispatch(this, 'submited');
23
23
  remove(this);
24
24
  });
@@ -0,0 +1,3 @@
1
+ &{
2
+ width: 600px;
3
+ }
@@ -1,3 +1,23 @@
1
- btn{
1
+ btn {
2
2
  padding: 0 16px;
3
+ }
4
+
5
+ & {
6
+ height: 100%;
7
+ overflow: auto;
8
+ }
9
+
10
+ table {
11
+
12
+ td {
13
+ >span {
14
+ white-space: normal;
15
+ word-break: break-all;
16
+ overflow: hidden;
17
+ display: -webkit-box;
18
+ -webkit-line-clamp: 2;
19
+ -webkit-box-orient: vertical;
20
+ text-overflow: ellipsis;
21
+ }
22
+ }
3
23
  }
@@ -1,4 +1,5 @@
1
1
  & {
2
2
  border-top-width: 0;
3
3
  width: 100%;
4
+ overflow: auto;
4
5
  }
@@ -0,0 +1,27 @@
1
+ // class LoadingArray extends Array {
2
+ // totalCount = 0;
3
+ // data = [];
4
+ // is_errored = null;
5
+ // error_message = null;
6
+ // is_loading = true;
7
+ // is_loaded = false;
8
+ // is_readonly = null;
9
+ // loading = null;
10
+ // loading_promise = null;
11
+ // then (ok, oh) {
12
+ // if (this.loading_promise) this.loading_promise.then(ok, oh);
13
+ // }
14
+ // }
15
+ function LoadingArray() {
16
+ var this0 = [];
17
+ this0.totalCount = 0;
18
+ this0.data = [];
19
+ this0.is_errored = null;
20
+ this0.error_message = null;
21
+ this0.is_loading = true;
22
+ this0.is_loaded = false;
23
+ this0.is_readonly = null;
24
+ this0.loading = null;
25
+ this0.loading_promise = null;
26
+ return this0;
27
+ };
@@ -402,6 +402,12 @@ function createApiMap(data) {
402
402
  }
403
403
  var _configfileurl;
404
404
  var configPormise;
405
+ function LoadingArray_then(ok, oh) {
406
+ if (this.loading_promise) this.loading_promise.then(ok, oh);
407
+ else if (this.is_errored) oh(this.error_message);
408
+ else ok();
409
+ }
410
+
405
411
  var privates = {
406
412
  loadAfterConfig(serviceId, params) {
407
413
  var promise = this.getApi(serviceId).then((api) => {
@@ -622,6 +628,7 @@ var data = {
622
628
  if (isObject(response)) {
623
629
  response.is_loaded = true;
624
630
  response.is_loading = false;
631
+ if (response.then === LoadingArray_then) delete response.then;
625
632
  }
626
633
  this.loading_count--;
627
634
  },
@@ -630,6 +637,7 @@ var data = {
630
637
  if (isObject(response)) {
631
638
  response.is_loaded = false;
632
639
  response.is_loading = true;
640
+ response.then = LoadingArray_then;
633
641
  }
634
642
  this.loading_count++;
635
643
  },
@@ -90,7 +90,7 @@ var initialComment = function (renders, type, expression) {
90
90
  var parseRepeat = function (expression) {
91
91
  var reg =
92
92
  // /////////////////////////////////////////// i // r ///////////////////////// o ///// a ///////////////////// t /////
93
- /^(?:let\b|var\b|const\b)?\s*(?:[\(\{\[]\s*)?(.+?)((?:\s*,\s*.+?)*)?(?:\s*[\)\}\]]\s*|\s+)(in|of)\s+(.+?)(\s+?:track\s*by\s+(.+?))?$/i;
93
+ /^(?:let\b|var\b|const\b)?\s*(?:[\(\{\[]\s*)?(.+?)((?:\s*,\s*.+?)*)?(?:\s*[\)\}\]]\s*|\s+)(in|of)\s+(.+?)(?:\s+track\s*by\s+(.+?))?$/i;
94
94
  var res = reg.exec(expression);
95
95
  if (!res) return res;
96
96
  var [_, i, k, r, s, t] = res;
@@ -125,7 +125,7 @@ var createRepeat = function (search, id = 0) {
125
125
  var [context, expression] = search;
126
126
  var res = parseRepeat(expression);
127
127
  if (!res) throw new Error(`不能识别循环表达式: ${expression} `);
128
- var { keyName, itemName, indexName, srcName } = res;
128
+ var { keyName, itemName, indexName, srcName, trackBy } = res;
129
129
  // 懒渲染
130
130
  var getter = createGetter([context, srcName]).bind(this);
131
131
  var element = this, clonedElements = [], savedValue, savedOrigin;
@@ -151,17 +151,26 @@ var createRepeat = function (search, id = 0) {
151
151
  var clonedElements1 = Object.create(null);
152
152
  var cloned = keys.map(function (key, cx) {
153
153
  var k = isArrayResult ? cx : key;
154
- var c = changes[k];
155
- if (clonedElements[k]) if (!c || !isObject(c.previous) && !isObject(c.current)) return clonedElements1[k] = clonedElements[k];
156
- var clone = element.cloneNode();
157
- clone.innerHTML = element.innerHTML;
158
- clone.renderid = id;
159
- clone.$parentScopes = $parentScopes;
160
154
  var $scope = {
161
155
  [keyName || '$key']: k,
162
156
  [itemName || '$item']: result[k],
163
157
  [indexName || '$index']: cx
164
158
  };
159
+ if (trackBy) {
160
+ k = seek($scope, trackBy);
161
+ if (clonedElements[k]) {
162
+ clonedElements[k].$scope = $scope;
163
+ return clonedElements1[k] = clonedElements[k];
164
+ }
165
+ }
166
+ else {
167
+ var c = changes[k];
168
+ if (clonedElements[k]) if (!c || !isObject(c.previous) && !isObject(c.current)) return clonedElements1[k] = clonedElements[k];
169
+ }
170
+ var clone = element.cloneNode();
171
+ clone.innerHTML = element.innerHTML;
172
+ clone.renderid = id;
173
+ clone.$parentScopes = $parentScopes;
165
174
  clone.$scope = $scope;
166
175
  clone.$parentScopes = $parentScopes;
167
176
  clone.$struct = $struct;
@@ -1,6 +1,7 @@
1
1
  <thead>
2
2
  <tr>
3
- <td -repeat="f in fields"><i -if="f.icon" -class="f.icon"></i></span><span -if="f.name" -html="f.name"></span>
3
+ <td -repeat="f in fields track by f.id" :style="{width:f.width}"><i -if="f.icon"
4
+ -class="f.icon"></i></span><span -if="f.name" -html="f.name"></span>
4
5
  </td>
5
6
  </tr>
6
7
  </thead>
@@ -91,11 +91,11 @@ var adaptTarget = function (event) {
91
91
  }
92
92
  if (target) target = getFirstSingleColCell(this, target.colend);
93
93
  if (target) {
94
- if (position.right >= getSelection(this).right - 7) {
94
+ if (position.right >= getScreenPosition(this).right - 7) {
95
95
  target = this;
96
96
  return;
97
97
  }
98
- css(this, { 'cursor': 'e-resize' });
98
+ css(document.body, { 'cursor': 'col-resize' });
99
99
  result = {
100
100
  target,
101
101
  restX: event.clientX - target.offsetWidth
@@ -106,18 +106,66 @@ var adaptTarget = function (event) {
106
106
  }
107
107
  if (!result) {
108
108
  this.resizing = false;
109
- css(this, { 'cursor': 'default' });
109
+ css(document.body, { 'cursor': '' });
110
110
  }
111
111
  };
112
112
  var tdElementReg = /^t[hd]$/i;
113
113
  var trElementReg = /^tr$/i;
114
+ var id = 0;
115
+ function enrichField(f) {
116
+ if (!f.id) f.id = ++id;
117
+ if (f.width) return;
118
+ var width;
119
+ if (f.size) {
120
+ width = f.size;
121
+ if (width < 40) width = width * 16;
122
+ }
123
+ else switch (f.type) {
124
+ case "text":
125
+ width = 30;
126
+ break;
127
+ case "input":
128
+ width = 200;
129
+ break;
130
+ case "date":
131
+ width = 180;
132
+ case "datetime":
133
+ width = 200;
134
+ break;
135
+ case "time":
136
+ width = 120;
137
+ break;
138
+ default:
139
+ if (f.options) {
140
+ width = f.options.map(o => o.name instanceof Function ? o.name() : o.name).join(" ").length * 20;
141
+ } else {
142
+ width = String(f.name || f.key).length * 16;
143
+ }
144
+ }
145
+ if (width > 600) width = 600;
146
+ f.width = width + 60;
147
+ }
148
+
114
149
 
115
150
  function table(elem) {
116
151
  var tableElement = isElement(elem) ? elem : document.createElement("table");
117
152
  var activeCols = [];
118
- onmousemove(tableElement, adaptTarget);
153
+ var adaptCursor = adaptTarget.bind(tableElement);
154
+ var off;
155
+ tableElement.init = function () {
156
+ off = on("mousemove")(window, adaptCursor);
157
+ };
158
+ tableElement.dispose = tableElement.destroy = function () {
159
+ off();
160
+ };
161
+ on("append")(tableElement, tableElement.init);
162
+ on("remove")(tableElement, tableElement.destroy);
163
+ if (isMounted(tableElement)) tableElement.init();
164
+
119
165
  moveupon(tableElement, {
120
- start() { },
166
+ start(event) {
167
+ if (this.resizing) event.preventDefault();
168
+ },
121
169
  move: resizeTarget,
122
170
  });
123
171
  onmousemove(tableElement, function (event) {
@@ -142,7 +190,7 @@ function table(elem) {
142
190
  removeClass(td, "y-ing");
143
191
  });
144
192
  });
145
- var table = tableElement.hasAttribute("ng-src") || tableElement.hasAttribute("src") ? list(tableElement) : tableElement;
193
+ var table = tableElement;
146
194
  var thead;
147
195
  var cellMatchManager = function (element) {
148
196
  if (!thead) [thead] = table.getElementsByTagName("thead");
@@ -162,10 +210,14 @@ function table(elem) {
162
210
  care(table, function ([fields, data]) {
163
211
  thead = null;
164
212
  this.innerHTML = template;
213
+ fields.forEach(enrichField);
165
214
  render(this, {
166
215
  fields,
167
216
  tbody: list,
168
217
  data,
218
+ setWidth(target, f) {
219
+ css(target, { width: f.width });
220
+ },
169
221
  a: button,
170
222
  }, this.$parentScopes.concat(this.$scope));
171
223
  })
@@ -1,4 +1,5 @@
1
1
  &[dragchildren] {
2
+
2
3
  >thead,
3
4
  >tbody,
4
5
  & {
@@ -74,8 +75,9 @@ table,
74
75
  line-height: 32px;
75
76
  height: 100%;
76
77
  min-height: 30px;
77
-
78
+ user-select: auto;
78
79
  display: table-row-group;
80
+ overflow: auto;
79
81
 
80
82
  >tr {
81
83
 
@@ -16,6 +16,5 @@
16
16
  model>& {
17
17
  width: 100% !important;
18
18
  display: block;
19
- margin: 10px 0;
20
19
  height: 120px;
21
20
  }
@@ -249,9 +249,11 @@ function prepare(pgpath, ok) {
249
249
  return _with_elements;
250
250
  };
251
251
  state.path = function (url) {
252
- if (isString(url) && /^\.+[\\\/]/.test(url)) {
253
- url = url.replace(/^\.[\\\/]/, '');
252
+ if (/^\.+\//.test(url)) {
254
253
  url = pgpath.replace(/[^\/]*$/, url);
254
+ }
255
+ if (isString(url) && /[\\\/\.]/.test(url)) {
256
+ url = url.replace(/^\.[\\\/]/, '');
255
257
  var ps = url.split(/[\\\/]/);
256
258
  var ds = [];
257
259
  for (var p of ps) {
@@ -262,7 +264,7 @@ function prepare(pgpath, ok) {
262
264
  ds.push(p);
263
265
  }
264
266
  }
265
- url = ds.join('/');
267
+ url = "/" + ds.join('/').replace(/^\//, '');
266
268
  }
267
269
  return url;
268
270
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.7.0",
3
+ "version": "3.7.6",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {