efront 3.7.6 → 3.7.7

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,5 +4,5 @@
4
4
  share: options ::share-:opt?:path
5
5
  folder: options ::file-:opt:::path?:to
6
6
  cluster: options ::cluster-:opt?:id
7
- private-list: options ::private
8
- private-edit: options ::private-:key?:value
7
+ list: options :::type
8
+ edit: options :::type-:key?:value
@@ -1,7 +1,11 @@
1
1
  首页: /home/welcome
2
- 共享目录管理: /share/list
3
- 短链接: /home/short
4
- WEB文件管理: /wow/root
5
- 长连接管理: /link/list
6
- 密钥管理: /token/list
2
+ WEB:
3
+ 共享目录: /share/list
4
+ 短链接: /home/short
5
+ 文件管理: /wow/root
6
+ 长连接管理: /link/list
7
+ 任务:
8
+ 密钥管理: /token/list
9
+ 任务建立: /task/list
10
+ 定期执行: /tick/list
7
11
  # 用户列表: /user/list
@@ -0,0 +1 @@
1
+ pedit.bind(null, "任务", "task");
@@ -0,0 +1,6 @@
1
+ plist.bind(null, '任务管理', "task", refilm`
2
+ *任务ID/key 100
3
+ *任务名/name 100
4
+ *启用/status swap [关闭,开启]
5
+ 任务代码/code text
6
+ `, '/task/edit');
@@ -0,0 +1,5 @@
1
+ function main() {
2
+ var a = div();
3
+ a.innerHTML = "定时任务管理,敬请期待";
4
+ return a;
5
+ }
@@ -1,10 +1 @@
1
- frame$edit.bind(null, "密钥", {
2
- submit(a, fields) {
3
- a = submit(fields, a);
4
- return data.from("private-edit", {
5
- key: encode62.timeencode(a.key),
6
- value: encode62.timeencode(JSON.stringify(a)),
7
- }).loading_promise;
8
- },
9
-
10
- });
1
+ pedit.bind(null, "密钥", "private");
@@ -1,13 +1,6 @@
1
- frame$list.bind(null, "密钥管理", {
2
- load() {
3
- return data.from("private-list", a => JSAM.parse(encode62.timedecode(a)));
4
- },
5
- remove(o) {
6
- return data.from("private-edit", { key: encode62.timeencode(o.key), value: encode62.timeencode("") }).loading_promise;
7
- },
8
- fields: refilm`
1
+ plist.bind(null, '密钥管理', "private", refilm`
9
2
  *键名/key 100
10
3
  显示名/name input/300
11
4
  密钥/value text/100
12
5
  备注/comment text/200
13
- `}, "/token/edit");
6
+ `, "/token/edit");
@@ -79,7 +79,7 @@ Object.assign(encode62, {
79
79
  for (var cx = 0, dx = data.length; cx < dx; cx++) {
80
80
  if (result[cx] < 128) result[cx] = result[cx] ^ sign[cx % sign.length];
81
81
  else if (result[cx] < 192) {
82
- var c = c << 8 | sign[(delta += 6) / 8 | 0];
82
+ var c = c << 8 | sign[(delta += 6) / 8 % sign.length | 0];
83
83
  result[cx] = result[cx] ^ (c >> 8 - delta % 8 & 0x3f);
84
84
  }
85
85
  }
@@ -1,4 +1,4 @@
1
- function main(title, { fields, load, remove }, edit_ref) {
1
+ function main(title, { fields, options: options0, load, remove }, edit_ref) {
2
2
  prepare(edit_ref);
3
3
  var page = document.createElement("div");
4
4
  var edit = function (o) {
@@ -11,6 +11,40 @@ function main(title, { fields, load, remove }, edit_ref) {
11
11
  })
12
12
  };
13
13
  page.innerHTML = template;
14
+ var options = [
15
+ {
16
+ name: "修改",
17
+ do(o) {
18
+ edit(o);
19
+ },
20
+ },
21
+ {
22
+ type: "danger",
23
+ name(o) {
24
+ return this.confirm === o ? "确认删除" : "删除";
25
+ },
26
+ type(o) {
27
+ return this.confirm === o ? "dark" : "danger";
28
+ },
29
+ confirm: false,
30
+ timer: 0,
31
+ async do(o) {
32
+ if (this.confirm !== o) {
33
+ this.confirm = o;
34
+ clearTimeout(this.timer);
35
+ var that = this;
36
+ this.timer = setTimeout(function () {
37
+ that.confirm = null;
38
+ render.refresh();
39
+ }, 2000);
40
+ return;
41
+ }
42
+ await remove(o);
43
+ page.$scope.load();
44
+ }
45
+ }
46
+ ];
47
+ if (options0) options = options.concat(options0);
14
48
  renderWithDefaults(page, {
15
49
  title,
16
50
  load() {
@@ -18,39 +52,7 @@ function main(title, { fields, load, remove }, edit_ref) {
18
52
  },
19
53
  fields: fields.concat({
20
54
  name: "操作",
21
- options: [
22
- {
23
- name: "修改",
24
- do(o) {
25
- edit(o);
26
- },
27
- },
28
- {
29
- type: "danger",
30
- name(o) {
31
- return this.confirm === o ? "确认删除" : "删除";
32
- },
33
- type(o) {
34
- return this.confirm === o ? "dark" : "danger";
35
- },
36
- confirm: false,
37
- timer: 0,
38
- async do(o) {
39
- if (this.confirm !== o) {
40
- this.confirm = o;
41
- clearTimeout(this.timer);
42
- var that = this;
43
- this.timer = setTimeout(function () {
44
- that.confirm = null;
45
- render.refresh();
46
- }, 2000);
47
- return;
48
- }
49
- await remove(o);
50
- page.$scope.load();
51
- }
52
- }
53
- ]
55
+ options
54
56
  }),
55
57
  data: [],
56
58
  add() {
@@ -10,7 +10,9 @@ btn {
10
10
  table {
11
11
 
12
12
  td {
13
- >span {
13
+
14
+ >span,
15
+ >model {
14
16
  white-space: normal;
15
17
  word-break: break-all;
16
18
  overflow: hidden;
@@ -0,0 +1,13 @@
1
+ function main(title, type, params) {
2
+ return frame$edit(title, {
3
+ submit(a, fields) {
4
+ a = submit(fields, a);
5
+ return data.from("edit", {
6
+ type,
7
+ key: encode62.timeencode(a.key),
8
+ value: encode62.timeencode(JSON.stringify(a)),
9
+ }).loading_promise;
10
+ },
11
+
12
+ }, params);
13
+ }
@@ -0,0 +1,13 @@
1
+
2
+ function main(title, type, fields, edit_ref, options) {
3
+ return frame$list(title, {
4
+ load() {
5
+ return data.from("list", { type }, a => JSAM.parse(encode62.timedecode(a)));
6
+ },
7
+ remove(o) {
8
+ return data.from("edit", { type, key: encode62.timeencode(o.key), value: encode62.timeencode("") }).loading_promise;
9
+ },
10
+ fields,
11
+ options,
12
+ }, edit_ref);
13
+ }
@@ -37,6 +37,17 @@ var renderModel = function (field, data) {
37
37
  var constructors = {
38
38
  input,
39
39
  raw: input,
40
+ swap(e) {
41
+ var { field } = e;
42
+ e = swap(e);
43
+ if (field.options) {
44
+ e.getValue = function () {
45
+ return field.options[+this.checked].value;
46
+ };
47
+ }
48
+ return e;
49
+ },
50
+ switch: swap,
40
51
  row: textarea,
41
52
  password,
42
53
  text: textarea,
@@ -134,8 +145,18 @@ var readonly_types = {
134
145
  "size"({ field }, data) {
135
146
  var f = data[field.key];
136
147
  return size(f);
137
- }
148
+ },
149
+ swap(e, data) {
150
+ var { field } = e;
151
+ var v = data[field.key];
152
+ if (field.options) {
153
+ var o = field.options[v];
154
+ if (o) return o.name;
155
+ }
156
+ return v;
157
+ },
138
158
  };
159
+ readonly_types.select = readonly_types.swap;
139
160
  function main(elem) {
140
161
  var build = function () {
141
162
  var { data, readonly, field } = elem;
@@ -222,7 +243,6 @@ function main(elem) {
222
243
  }
223
244
  };
224
245
  on("changes")(elem, function ({ changes }) {
225
-
226
246
  if (changes.data || changes.field || changes.readonly) {
227
247
  build();
228
248
  }
@@ -565,7 +565,8 @@ function getFromScopes(key, scope, parentScopes) {
565
565
  if (key in scope) {
566
566
  return scope[key];
567
567
  }
568
- if (parentScopes) for (var o of parentScopes) {
568
+ if (parentScopes) for (var cx = parentScopes.length - 1; cx >= 0; cx--) {
569
+ var o = parentScopes[cx];
569
570
  if (key in o) {
570
571
  return o[key];
571
572
  }
@@ -30,7 +30,7 @@
30
30
  -o-appearance: none;
31
31
  appearance: none;
32
32
  &:before {
33
- background-color: #26f;
33
+ background-color: #28c;
34
34
  transition: all .1s ease-out;
35
35
  left: 50%;
36
36
  top: 50%;
@@ -8,8 +8,8 @@
8
8
  <tbody -src="d in data">
9
9
  <tr>
10
10
  <td -repeat="f in fields">
11
- <span -if="f.key" -text="d[f.key]"></span>
12
- <a on-click="o.do(d)" -if="f.options" _type="o.type instanceof Function?o.type(d):o.type"
11
+ <model -if="f.key" :field=f :data=d readonly ></model>
12
+ <a on-click="o.do(d)" -if="!f.key&&f.options" _type="o.type instanceof Function?o.type(d):o.type"
13
13
  -repeat="o in f.options">
14
14
  <span -text="o.name instanceof Function?o.name(d):o.name"></span>
15
15
  </a>
@@ -215,6 +215,7 @@ function table(elem) {
215
215
  fields,
216
216
  tbody: list,
217
217
  data,
218
+ model,
218
219
  setWidth(target, f) {
219
220
  css(target, { width: f.width });
220
221
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.7.6",
3
+ "version": "3.7.7",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {