efront 3.18.3 → 3.19.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.
@@ -14,8 +14,10 @@
14
14
  count: options ::count
15
15
  bootlog: options ::similar
16
16
  link: options ::link
17
+ room: options ::link-:id
17
18
  care: options ::care-:id
18
19
  cast: options ::cast-:id?:msg
20
+ upload: put :path
19
21
  https://www.ip.cn/:
20
22
  iplocation: get https://www.ip.cn/api/index?ip=:ip&type=1
21
23
  # https://ipchaxun.com/ :
@@ -2,7 +2,7 @@ async function link(id, page) {
2
2
  if (!id) {
3
3
  id = await data.from("link");
4
4
  }
5
- page.$scope.title = `会话窗口(<span nodrag>${id}</span>)`;
5
+ if (!page.name) page.$scope.title = `会话窗口(<span nodrag>${id}</span>)`;
6
6
  page.roomid = id;
7
7
  var removed = false;
8
8
  on("remove")(page, function () {
@@ -16,8 +16,11 @@ async function link(id, page) {
16
16
  page.push(await xhr);
17
17
  }
18
18
  }
19
- function main(id) {
20
- var page = frame$chat();
19
+ function main(params) {
20
+ if (isObject(params)) var { linkid: id, name } = params;
21
+ else id = params;
22
+ var page = frame$chat(name);
23
+ if (name) page.name = name;
21
24
  care(page, 'send', function (msg) {
22
25
  data.from("cast", { id: page.roomid, msg });
23
26
  });
@@ -0,0 +1,2 @@
1
+ <menu -src="m in menus" #navbar></menu>
2
+ <container -src="navbar.selected?.path"></container>
@@ -0,0 +1,13 @@
1
+ function index() {
2
+ var page = document.createElement('link-index');
3
+ page.innerHTML = template;
4
+ renderWithDefaults(page, {
5
+ menus: "房间 /link/room, 会话 /link/list".split(/\s*,\s*/).map(a => {
6
+ var [name, path] = a.split(/\s+/);
7
+ return { name, path };
8
+ }),
9
+ menu,
10
+ });
11
+ page.$scope.menus[0].actived = true;
12
+ return page;
13
+ }
File without changes
@@ -0,0 +1,10 @@
1
+ plist.bind(null, '房间', "room", refilm`
2
+ *房间名/name 100
3
+ / $ ${[{
4
+ name: "连接",
5
+ async do(o) {
6
+ var linkid = await data.from("room", { id: encode62.timeencode(o.name) });
7
+ popup("/link/chat", { linkid, name: o.name });
8
+ }
9
+ }]}
10
+ `);
@@ -26,7 +26,7 @@ data.bindInstance("base", async function (base) {
26
26
  cross.addDirect(base.base);
27
27
  var apimap = await data.getConfig();
28
28
  for (var k in apimap) {
29
- if (apimap[k].method === 'options') apimap[k].base = base.base;
29
+ if (/options|put/.test(apimap[k].method)) apimap[k].base = base.base;
30
30
  }
31
31
  });
32
32
  var base = data.getInstance('base').base;
@@ -53,6 +53,12 @@ var layer = layer$glance({
53
53
  on("append")(layer, function () {
54
54
  frame$route.open();
55
55
  });
56
+ on("dragover")(document, function (event) {
57
+ event.preventDefault();
58
+ });
59
+ on("drop")(document, function (event) {
60
+ event.preventDefault();
61
+ });
56
62
  function main() {
57
63
  return layer;
58
64
  }
@@ -3,7 +3,7 @@ WEB:
3
3
  共享目录: /share/list
4
4
  短链接: /proxy/list
5
5
  文件管理: /wow/root
6
- 长连接管理: /link/list
6
+ 长连接管理: /link/index
7
7
  字典: /dict/list
8
8
  接口: /api/list
9
9
  任务:
@@ -10,6 +10,7 @@ function main({ path: root, name }) {
10
10
  renderWithDefaults(a, {
11
11
  fields,
12
12
  pathlist: root,
13
+ origin,
13
14
  isFolder: /\/$/.test(name),
14
15
  data: { name: origin, origin },
15
16
  remove() {
@@ -19,9 +20,11 @@ function main({ path: root, name }) {
19
20
  on('submit')(a, async function (e) {
20
21
  e.preventDefault();
21
22
  var path = root.concat(a.$scope.data.name).join('/');
23
+ path = encode62.timeencode(path);
22
24
  if (origin) {
23
25
  var to = path;
24
26
  path = origin;
27
+ path = encode62.timeencode(path);
25
28
  }
26
29
  await data.from("folder", { opt: origin ? 'mov' : 'add', path, to }).loading_promise;
27
30
  dispatch(this, 'submited');
@@ -1,8 +1,21 @@
1
1
  var fields = refilm`
2
2
  文件
3
3
  `;
4
-
4
+ var passport = encode62.timeencode(encode62.decode62(user._passport, user.session));
5
+ async function upload(f, base) {
6
+ var api = await data.getApi('upload');
7
+ var authorization = await data.getSource(api.base);
8
+ var xhr = cross(api.method, api.base + base + f.name, { authorization: authorization });
9
+ xhr.setRequestHeader('range', 'bytes=1-' + f.size);
10
+ return xhr.send(f);
11
+ }
5
12
  function main() {
13
+ async function uploadAll(files) {
14
+ await queue.call(files, function (f) {
15
+ return upload(f, page.$scope.pathlist.join("/"));
16
+ });
17
+ page.$scope.open();
18
+ }
6
19
  var page = div();
7
20
  page.innerHTML = root;
8
21
  page.onback = function () {
@@ -15,15 +28,24 @@ function main() {
15
28
  return false;
16
29
  }
17
30
  page.setAttribute('ng-mousedown', 'setActive')
31
+ bind('drop')(page, async function (event) {
32
+ event.preventDefault();
33
+ var files = event.dataTransfer.files;
34
+ uploadAll(files);
35
+ });
18
36
 
19
37
  renderWithDefaults(page, {
20
38
  lattice,
21
39
  pathlist: data.getInstance("pathlist"),
22
40
  active: null,
23
41
  open(p) {
42
+ if (p && !/\/$/.test(p.name)) {
43
+ // window.open("/" + this.pathlist.concat(p.name).join('/'))
44
+ return;
45
+ }
24
46
  if (p) p = String(p.name || '').replace(/\/$/, '');
25
47
  if (p) data.setInstance("pathlist", this.pathlist.concat(p));
26
- this.data = data.from("folder", { opt: 'list', path: "/" + this.pathlist.join('/') }, files => {
48
+ this.data = data.from("folder", { opt: 'list', path: encode62.timeencode("/" + this.pathlist.join('/')) }, files => {
27
49
  if (files) return sortname(files).map(f => {
28
50
  return {
29
51
  name: f,
@@ -66,7 +88,14 @@ function main() {
66
88
  }
67
89
  },
68
90
  {
69
- name: '编辑',
91
+ name: "添加文件",
92
+ when: e => !getActive(e),
93
+ do() {
94
+ return chooseFile().then(uploadAll);
95
+ }
96
+ },
97
+ {
98
+ name: '重命名',
70
99
  when,
71
100
  do(e) {
72
101
  popupEdit(e.$scope.d.name);
@@ -91,7 +120,7 @@ function main() {
91
120
  }, 2000);
92
121
  return false;
93
122
  }
94
- await data.from("folder", { opt: 'del', path: "/" + page.$scope.pathlist.concat(e.$scope.d.name).join("/") }).loading_promise;
123
+ await data.from("folder", { opt: 'del', path: encode62.timeencode("/" + page.$scope.pathlist.concat(e.$scope.d.name).join("/")) }).loading_promise;
95
124
  page.$scope.open();
96
125
  }
97
126
  }
@@ -19,6 +19,7 @@ function chat(title = '会话窗口') {
19
19
  page.innerHTML = template;
20
20
  drag.on(page.firstElementChild, page);
21
21
  resize.on(page);
22
+ var localid = Date.now() + Math.sin(Math.random());
22
23
  page.push = function (msgs) {
23
24
  var { msglist } = this.$scope;
24
25
  msglist.push.apply(msglist, msgs);
@@ -37,7 +38,7 @@ function chat(title = '会话窗口') {
37
38
  grid,
38
39
  msglist: [],
39
40
  text: '',
40
- localid: Math.random(),
41
+ localid,
41
42
  msg,
42
43
  remove() {
43
44
  remove(page);
@@ -128,7 +128,7 @@ var parse = function (r) {
128
128
  function sex(r = Math.random()) {
129
129
  return r < .5 | 0;
130
130
  }
131
- function sfz(r) {
131
+ function 身份证(r) {
132
132
  var p17, middle;
133
133
  if (typeof r === 'string' || r === 1 || r === 0) {
134
134
  var r0 = Math.random();
@@ -1,13 +1,14 @@
1
1
  var id = 0;
2
- function Item(value) {
3
- this.children = this;
4
- this.count = 0;//子项中的叶子节点数
5
- this.total = 0;//子项中的节点数
6
- this.crack = 0;
7
- this.id = ++id;
8
- this.extends(value);
9
- }
10
- Item.prototype = extend([], {
2
+ class Item extends Array {
3
+ constructor(value) {
4
+ super();
5
+ this.children = this;
6
+ this.count = 0;//子项中的叶子节点数
7
+ this.total = 0;//子项中的节点数
8
+ this.crack = 0;
9
+ this.id = ++id;
10
+ this.extends(value);
11
+ }
11
12
  extends(value) {
12
13
  this.value = value;
13
14
  if (value.children instanceof Array) {
@@ -16,7 +17,6 @@ Item.prototype = extend([], {
16
17
  this.push.apply(this, children);
17
18
  }
18
19
  if (isObject(value)) {
19
- this.name = value.name;
20
20
  this.tab = value.tab;
21
21
  this.icon = value.icon;
22
22
  this.color = value.color;
@@ -28,30 +28,38 @@ Item.prototype = extend([], {
28
28
  if (value.href) this.href = value.href;
29
29
  if (value.src) this.src = value.src;
30
30
  }
31
- else {
32
- this.name = value;
33
- }
34
- },
31
+ }
35
32
 
36
33
  valueOf() {
37
34
  return this.value;
38
- },
35
+ }
39
36
  toString() {
40
37
  return String(this.value);
41
- },
38
+ }
39
+ get warn() {
40
+ if (isObject(this.value)) {
41
+ return /danger|red|warn/.test(this.value.type) || this.value.warn;
42
+ }
43
+ return false;
44
+ }
45
+ get name() {
46
+ if (isObject(this.value)) return this.value.name;
47
+ return this.value;
48
+ }
49
+
42
50
  isClosed() {
43
51
  return !!this.value.closed;
44
- },
52
+ }
45
53
  setClosed(value) {
46
54
  this.value.closed = value;
47
- },
55
+ }
48
56
  isActive() {
49
57
  if (isObject(this.value)) {
50
58
  if ("active" in this.value) return this.value.active;
51
59
  if ('actived' in this.value) return this.value.actived;
52
60
  }
53
61
  return !!this.actived;
54
- },
62
+ }
55
63
  setActive(value) {
56
64
  if (isObject(this.value)) {
57
65
  if ('active' in this.value) {
@@ -61,15 +69,16 @@ Item.prototype = extend([], {
61
69
  }
62
70
  }
63
71
  this.actived = value;
64
- },
72
+ }
65
73
  isSelected() {
66
74
  return !!this.value.selected;
67
- },
75
+ }
68
76
  isChecked() {
69
77
  return !!this.value.checked;
70
- },
78
+ }
71
79
  getClass() {
72
80
  return !!this.value.class;
73
81
  }
74
- });
82
+
83
+ }
75
84
  Item.prototype.isActived = Item.prototype.isActive;
@@ -8,10 +8,11 @@ var createMenu = function (event, items) {
8
8
  if (!item.when(event)) return false;
9
9
  return true;
10
10
  });
11
- var elem = menuList(menulist, items, async function (item) {
12
- if (await action.call(this, item, event.target) !== false) {
13
- remove(elem);
14
- }
11
+ var elem = menuList(menulist, items, function (item) {
12
+ action.call(this, item, event.target).then(function (e) {
13
+ if (e !== false) remove(elem);
14
+ });
15
+ return false;
15
16
  });
16
17
 
17
18
  return elem;
@@ -1,4 +1,4 @@
1
- <i ng-class="icon" ng-if='useIcon||hasIcon'></i>
1
+ <i ng-class="icon?" ng-if='useIcon||hasIcon'></i>
2
2
  <span ng-html="name?"></span>
3
3
  <template -if="hotkey?">
4
4
  &nbsp;&nbsp; <span ng-repeat="k of hotkey" class="hotkey" ng-html="k"></span>
@@ -8,16 +8,14 @@ function main(elem, scope, hasIcon) {
8
8
  var scope = item.$scope;
9
9
  }
10
10
  if (scope.menu) scope = scope.menu;
11
- var name = scope.name;
12
- var icon = scope.icon;
13
- if (hasIcon === undefined) hasIcon = !!icon;
11
+ if (hasIcon === undefined) hasIcon = !!scope.icon;
14
12
  if (scope.disabled || scope.enabled === false) {
15
13
  item.setAttribute('disabled', '');
16
14
  }
17
15
  else {
18
16
  item.removeAttribute("disabled");
19
17
  }
20
- render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon, name, icon }], 0);
18
+ render(item.children, scope, hasIcon instanceof Array ? hasIcon : [{ useIcon: hasIcon, hasIcon }]);
21
19
  if (scope.line) item.setAttribute("line", ''), on("click")(item, preventDefault);
22
20
  if (scope.hotkey) bindAccesskey(item, scope.hotkey);
23
21
  return item;
@@ -1,6 +1,6 @@
1
1
  <menu-item ng-repeat="menu in menus" ng-if="!menu.hidden" ng-click="open.call(this)" ng-mouseleave="cancel()"
2
2
  ng-mouseenter="popMenu.call(this)" ng-mousedown="popMenu1.call(this,event)" ng-class="{'has-children':menu.children&&menu.children.length,
3
- 'warn':menu.type==='danger'||menu.type==='warn'||menu.type==='red',
3
+ 'warn':menu.warn,
4
4
  'actived':menu.isActived()
5
5
  }">
6
6
  </menu-item>
@@ -226,7 +226,7 @@ function main(page, items, active, direction = 'y') {
226
226
  clear();
227
227
  clearTimeout(popTimer);
228
228
  }
229
- var fire = function () {
229
+ var fire = async function () {
230
230
  cancel();
231
231
  if (this.menu.line) return;
232
232
  if (byMousedown) return;
@@ -297,7 +297,6 @@ function main(page, items, active, direction = 'y') {
297
297
  a.menu = s;
298
298
  return a;
299
299
  },
300
- menus: items.map(i => i instanceof Item ? i : new Item(i)),
301
300
  hasIcon: hasIcon(),
302
301
  open: fire,
303
302
  cancel,
@@ -308,7 +307,7 @@ function main(page, items, active, direction = 'y') {
308
307
  var src = page.$src;
309
308
  var itemName = src.itemName;
310
309
  var className = `{'has-children':${itemName}.children&&${itemName}.children.length,
311
- 'warn':${itemName}.type==='danger'||${itemName}.type==='warn'||${itemName}.type==='red',
310
+ 'warn':${itemName}.warn,
312
311
  actived:${itemName}.isActived()
313
312
  }`;
314
313
  var notHidden = `!${itemName}.hidden`;
@@ -335,6 +334,7 @@ function main(page, items, active, direction = 'y') {
335
334
  }
336
335
  else {
337
336
  page.innerHTML = menuList;
337
+ $scope.menus = items.map(i => i instanceof Item ? i : new Item(i));
338
338
  render(page, $scope);
339
339
  vbox(page);
340
340
  }
@@ -23,6 +23,11 @@
23
23
 
24
24
  &.warn {
25
25
  color: #c28;
26
+
27
+ &.focus {
28
+ color: #c28;
29
+ background: #c282;
30
+ }
26
31
  }
27
32
 
28
33
  &.focus {
@@ -190,7 +190,6 @@ var createRepeat = function (search, id = 0) {
190
190
  var clone = element.cloneNode();
191
191
  clone.innerHTML = element.innerHTML;
192
192
  clone.renderid = id;
193
- clone.$parentScopes = $parentScopes;
194
193
  clone.$scope = $scope;
195
194
  clone.$parentScopes = $parentScopes;
196
195
  clone.$struct = $struct;
@@ -202,7 +201,7 @@ var createRepeat = function (search, id = 0) {
202
201
  if (a.previousSibling !== last) appendChild.after(last, a);
203
202
  last = a;
204
203
  }, this);
205
- cloned.forEach(a => render(a))
204
+ cloned.forEach(a => render(a));
206
205
  for (var k in clonedElements) {
207
206
  if (clonedElements1[k] !== clonedElements[k]) remove(clonedElements[k]);
208
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.18.3",
3
+ "version": "3.19.0",
4
4
  "description": "一个开发工具,开放源代码,自带组件库和编译环境,可以用来开发web组件,web应用或nodejs模块,或做为已有代码的加密工具,也可以做为静态页面服务器或跨域中转服务器使用",
5
5
  "main": "public/efront.js",
6
6
  "directories": {