efront 3.26.14 → 3.26.16

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.
package/LICENSE CHANGED
@@ -18,3 +18,5 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
18
  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
19
  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
20
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ 共产党与狗不得使用
@@ -3,7 +3,8 @@
3
3
  run: options :::run
4
4
  share: options ::share-:opt?:path
5
5
  folder: options ::file-:opt:::path?:to
6
- cluster: options ::cluster-:opt?:id
6
+ cluster: options ::cluster-list
7
+ clients: options ::cluster-list?:id
7
8
  list: options :::type
8
9
  edit: options :::type-:key?:value
9
10
  add: options :::type-:key+:value
@@ -1,2 +1,2 @@
1
- <menu -src="m in menus" #navbar></menu>
1
+ <menu @active="saveIndex(i)" -src="(m,i) in menus" #navbar></menu>
2
2
  <container -src="navbar.selected?.path"></container>
@@ -6,8 +6,11 @@ function index() {
6
6
  var [name, path] = a.split(/\s+/);
7
7
  return { name, path };
8
8
  }),
9
+ saveIndex(index) {
10
+ data.setInstance('link-index', index);
11
+ },
9
12
  menu,
10
13
  });
11
- page.$scope.menus[0].actived = true;
14
+ page.$scope.menus[+data.getInstance("link-index")].actived = true;
12
15
  return page;
13
16
  }
@@ -4,7 +4,7 @@ function main() {
4
4
  page.innerHTML = template;
5
5
  renderWithDefaults(page, {
6
6
  load: lazy(async function () {
7
- this.clusters = data.lazyInstance("cluster", { opt: "list" });
7
+ this.clusters = data.lazyInstance("cluster");
8
8
  await this.clusters;
9
9
  this.active();
10
10
  }, -1000),
@@ -25,11 +25,12 @@ function main() {
25
25
  return ((new Date - d) / 1000 | 0) + "秒";
26
26
  },
27
27
  clients: [],
28
- active(index = this.index.index | 0) {
28
+ async active(index = this.index.index | 0, c) {
29
29
  data.setInstance('index', { index });
30
30
  var clusters = this.clusters;
31
31
  if (index >= clusters.length) index = clusters.length - 1;
32
- this.clients = data.from("cluster", { opt: "list", id: clusters[index] });
32
+ if (c) this.clients = [];
33
+ this.clients = await data.asyncInstance("clients", { id: clusters[index] });
33
34
  },
34
35
  });
35
36
  var loadid = 0;
@@ -3,7 +3,7 @@
3
3
  </template>
4
4
  <close @click="remove()"></close>
5
5
  </div>
6
- <grid body #body>
6
+ <grid #body disabled>
7
7
  <chat -src="m in msglist">
8
8
  <padding>
9
9
  <msg class="msg"></msg>
@@ -14,14 +14,36 @@ function msg(elem, { m: data }, parentScopes) {
14
14
  elem.innerText = data;
15
15
  }
16
16
  }
17
+ var userManager = function (users, m) {
18
+ for (var cx = 0, dx = users.length; cx < dx; cx++) {
19
+ var u = users[cx];
20
+ if (u.id === m.id) {
21
+ if (m.deleted) users.splice(cx, 1);
22
+ else Object.assign(u, m);
23
+ return;
24
+ }
25
+ }
26
+ if (!m.deleted) users.push(m);
27
+ };
17
28
  function chat(title = '会话窗口') {
18
29
  var page = view();
19
30
  page.innerHTML = template;
20
31
  drag.on(page.firstElementChild, page);
21
32
  resize.on(page);
22
33
  var localid = Date.now() + Math.sin(Math.random());
34
+ var users = [];
23
35
  page.push = function (msgs) {
24
36
  var { msglist } = this.$scope;
37
+ msgs = msgs.filter(m => {
38
+ if (!m) return false;
39
+ if (isString(m)) return true;
40
+ switch (m.type) {
41
+ case 'user':
42
+ userManager(users, m);
43
+ break;
44
+ }
45
+ return false;
46
+ });
25
47
  msglist.push.apply(msglist, msgs);
26
48
  var chat = page.querySelector("chat");
27
49
  var lastmsg = chat.getLastVisibleElement();
@@ -35,8 +57,8 @@ function chat(title = '会话窗口') {
35
57
  renderWithDefaults(page, {
36
58
  chat: list,
37
59
  title,
38
- grid,
39
60
  msglist: [],
61
+ users,
40
62
  text: '',
41
63
  localid,
42
64
  msg,
@@ -47,8 +69,7 @@ function chat(title = '会话窗口') {
47
69
  var textarea = body.querySelector("[textarea]");
48
70
  var lastElementChild = textarea.lastElementChild;
49
71
  var targetHeight = Math.min(textarea.scrollHeight, body.clientHeight * .6, lastElementChild.offsetTop + lastElementChild.offsetHeight);
50
- if (Math.abs(targetHeight - textarea.clientHeight) < 2) return;
51
-
72
+ if (Math.abs(targetHeight - textarea.clientHeight - textarea.clientTop) < 2) return;
52
73
  body.resizeCell(textarea, 'top', textarea.clientHeight - targetHeight - 2);
53
74
  },
54
75
  send() {
@@ -61,8 +82,7 @@ function chat(title = '会话窗口') {
61
82
 
62
83
  data = encode62.timeencode(data);
63
84
  if (this.text.length > 2000) {
64
- alert("信息太长,无法发送!");
65
- return;
85
+ return alert("信息太长,无法发送!");
66
86
  }
67
87
  cast(page, "send", data);
68
88
  this.body.lastElementChild.focus();
@@ -76,19 +76,26 @@ msg {
76
76
  line-height: 24px;
77
77
  }
78
78
 
79
- >grid[body] {
79
+ >grid {
80
80
  padding-top: 0;
81
81
  margin-bottom: 0;
82
+ height: 100%;
83
+ background-color: #f2f4f6;
84
+ width: 100%;
82
85
 
83
86
  >div {
84
87
  height: 100%;
85
88
  position: relative;
86
89
  }
90
+
91
+ >chat {
92
+ padding-top: 50px;
93
+ }
87
94
  }
88
95
 
89
96
 
90
97
  .editor-height(@height) {
91
- >grid[body]:not(:last-child) {
98
+ >grid:not(:last-child) {
92
99
  padding-bottom: @height;
93
100
  }
94
101
 
@@ -811,12 +811,12 @@ var data = {
811
811
  },
812
812
  fromApi(api, params, parse) {
813
813
  var id = parse instanceof Function ? getInstanceId() : 0;
814
+ var p = privates.fromApi(api, params);
814
815
  if (id) this.removeInstance(id);
815
816
  var url = api.url;
816
817
  var response = this.getInstance(id || url);
817
818
  if (!isObject(response)) response = new LoadingArray;
818
819
  this.responseLoading(response);
819
- var p = privates.fromApi(api, params);
820
820
  response.loading = p.loading;
821
821
  p = response.loading_promise = p.then((data) => {
822
822
  response.loading = null;
@@ -838,11 +838,11 @@ var data = {
838
838
  },
839
839
  fromURL(url, parse) {
840
840
  var id = parse instanceof Function ? getInstanceId() : 0;
841
+ var p = privates.loadIgnoreConfig('get', url);
841
842
  if (id) this.removeInstance(id);
842
843
  var response = this.getInstance(id || url);
843
844
  if (!isObject(response)) response = new LoadingArray;
844
845
  this.responseLoading(response);
845
- var p = privates.loadIgnoreConfig('get', url);
846
846
  response.loading = p.loading;
847
847
  p = response.loading_promise = p.then((data) => {
848
848
  response.loading = null;
@@ -925,6 +925,7 @@ var data = {
925
925
  }
926
926
  var outdate = new Error("request outdate.");
927
927
  var aborted = new Error("request aborted.");
928
+ this.responseLoading(instance);
928
929
  promise1 = instance.loading_promise = new Promise(function (ok) {
929
930
  if (!instance.loading) {
930
931
  instance.loading = false;
@@ -938,7 +939,6 @@ var data = {
938
939
  if (instance.loading) {
939
940
  instance.loading.abort();
940
941
  }
941
- this.responseLoading(instance);
942
942
  var params2 = privates.pack(sid, params1);
943
943
  if (!privates.validApi(api, params2)) throw aborted;
944
944
  let url = api.url;
@@ -979,6 +979,7 @@ var data = {
979
979
  this.responseLoaded(instance);
980
980
  return data;
981
981
  });
982
+ promise1.params = params;
982
983
  promise1.catch((e) => {
983
984
  if (e === outdate || e === aborted) return;
984
985
  this.responseCrash(e, instance);
@@ -203,6 +203,7 @@ var resizeView = function (event) {
203
203
  grid.reshape();
204
204
  };
205
205
  var clearResizer = function (grid) {
206
+ if (!grid.editting) return;
206
207
  var target = grid.editting.target;
207
208
  if (target) target.style.zIndex = null;
208
209
  var { clientX, clientY } = grid.editting;
@@ -758,7 +759,6 @@ var createPointsWithChildren = function () {
758
759
  points = [0, points];
759
760
  }
760
761
  grid.setData(points);
761
- console.log(grid.clientHeight, elements)
762
762
  grid.reshape();
763
763
  };
764
764
  function main(elem) {
@@ -380,7 +380,10 @@ var renderStructure = function (element) {
380
380
  if ($struct.if) var { name: ifkey, key, value: ifexp } = $struct.if;
381
381
  if ($struct.repeat) var { value: repeat } = $struct.repeat;
382
382
  if (!ifkey) return createRepeat.call(element, repeat);
383
- if (!ifexp || !repeat) return structures[key].call(element, ifexp);
383
+ if (!ifexp || !repeat) {
384
+ if (repeat) delete $struct.if;
385
+ return structures[key].call(element, ifexp);
386
+ }
384
387
  var { before, after } = parseIfWithRepeat(ifexp, repeat);
385
388
  if (after.length) {
386
389
  $struct.if = { key, name: ifkey, value: after.join("&&") };
@@ -875,7 +878,6 @@ function createStructure(element) {
875
878
  if (isArrayLike(element)) return Array.prototype.map.call(element, createStructure);
876
879
  if (element.$struct) return element.$struct;
877
880
  // 处理结构流
878
- if (!element.attributes) console.log(element)
879
881
  var attrs = Array.prototype.slice.call(element.attributes);
880
882
  var types = {};
881
883
  var emiter_reg = /^(?:(v|ng|on|once)?\-|v\-on\:|@|once|on)/i;
@@ -902,7 +904,7 @@ function createStructure(element) {
902
904
  continue;
903
905
  }
904
906
  var key = name.replace(/^(ng|v|.*?)\-/i, "").toLowerCase();
905
- if (structures.hasOwnProperty(key) && isFunction(structures[key])) {
907
+ if (structures.hasOwnProperty(key)) {
906
908
  if (element.renderid <= -2) {
907
909
  if (/^if$|^else/i.test(key)) {
908
910
  if (types.if) {
@@ -145,13 +145,16 @@ moveupon(window, handle);
145
145
  var offmousemove;
146
146
  var resizeh = lazy(function () {
147
147
  // 用于刷新自定义的scrollbar/lattice/gallery组件
148
+ /**
149
+ * @type {HTMLElement}
150
+ */
148
151
  var elem = this;
149
152
  var resized = false;
150
- if (elem.scrollWidth > elem.clientWidth) {
153
+ if (elem.scrollWidth > elem.offsetWidth + elem.clientLeft + 1) {
151
154
  css(elem, { width: elem.offsetWidth });
152
155
  resized = true;
153
156
  }
154
- if (elem.scrollHeight > elem.clientHeight) {
157
+ if (elem.scrollHeight > elem.offsetHeight + elem.clientTop + 1) {
155
158
  css(elem, { height: elem.offsetHeight });
156
159
  resized = true;
157
160
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "3.26.14",
3
+ "version": "3.26.16",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {