efront 4.3.6 → 4.3.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.
@@ -103,7 +103,7 @@ inertia.MOVING = 移动;
103
103
  inertia.SLOWING_DWON = 减速;
104
104
  inertia.REBOUNDING = 回弹;
105
105
  inertia.DOCKING = 停靠;
106
- var performance = window.performance;
106
+ var performance = this.performance;
107
107
  if (!performance || !performance.now) performance = Date;
108
108
  var now = performance.now;
109
109
  if (!performance.now) performance.now = function () {
@@ -309,5 +309,3 @@ function main(text) {
309
309
  format();
310
310
  return result;
311
311
  }
312
- window.wordslike = wordslike;
313
- window.words = words;
@@ -2,7 +2,7 @@
2
2
  var languageMap = {};
3
3
  var languageIndex = 0;
4
4
  function i18n(arg) {
5
- if (typeof arg === 'string') arg = arguments;
5
+ if (typeof arg === 'string' || !isArrayLike(arg)) arg = arguments;
6
6
  return arg[isFinite(this) ? this : languageIndex];
7
7
  };
8
8
  i18n.lang = function (type) {
@@ -1,3 +1,4 @@
1
+ var window = this;
1
2
  function isArrayLike(a) {
2
3
  if (a === null || a === window || typeof a !== 'object' || isNode(a)) return false;
3
4
  if (isFinite(a.length)) {
@@ -52,6 +52,11 @@ var cross = cross_.bind(function (callback, onerror) {
52
52
  auth,
53
53
  headers: this.headers,
54
54
  };
55
+ var onerror1 = function (e) {
56
+ xhr.readyState = 4;
57
+ error = e;
58
+ onerror(e);
59
+ };
55
60
  var req = this.http.request(options, function (res) {
56
61
  var data = [];
57
62
  xhr.status = res.statusCode;
@@ -65,16 +70,11 @@ var cross = cross_.bind(function (callback, onerror) {
65
70
  xhr.readyState = 4;
66
71
  callback();
67
72
  });
68
- var onerror1 = function (e) {
69
- xhr.readyState = 4;
70
- error = e;
71
- onerror(e);
72
- };
73
- res.on("error", onerror1);
74
- res.on('timeout', onerror1);
75
73
  this.readyState = 2;
76
74
  });
77
75
  this.readyState = 1;
76
+ req.on("error", onerror1);
77
+ req.on("timeout", onerror1);
78
78
  req.setTimeout(3000);
79
79
  if (data) req.end(data);
80
80
  else req.end();
@@ -1,7 +1,6 @@
1
1
  第三方代码来源及日期,后续版本请自行更新
2
2
  2022-12-30 https://npmjs.com/package/crypto-js
3
3
  2022-11-12 https://github.com/kazuhikoarase/qrcode-generator 逻辑有修改 qrcode.js
4
- 2022-09-29 https://github.com/richtr/NoSleep.js
5
4
  2021-06-15 https://www.npmjs.com/package/html2canvas
6
5
  2019-08-03 https://github.com/gorhill/Javascript-Voronoi
7
6
  2017-05-17 https://github.com/dankogai/js-deflate
@@ -67,7 +67,7 @@ function alert() {
67
67
  var waitclose = function (autoclose, deltaTime) {
68
68
  if (autoclose) {
69
69
  if (autoclose === true) {
70
- autoclose = text.length * 160 + deltaTime;
70
+ autoclose = text && text.length * 160 + deltaTime;
71
71
  } else if (autoclose < 100) {
72
72
  autoclose = autoclose * 1000;
73
73
  }
@@ -104,8 +104,12 @@ function getErrorMessage(error = this) {
104
104
  if (error[a]) {
105
105
  return String(error[a]);
106
106
  }
107
+ a = a.charAt(0).toUpperCase() + a.slice(1);
108
+ if (error[a]) return String(error[a]);
109
+ a = a.toUpperCase();
110
+ if (error[a]) return String(error[a]);
107
111
  }
108
- return JSON.stringify(error);
112
+ return Object.keys(error).map(k => `${k}: ${error[k]}`).join(',\r\n');
109
113
  }
110
114
 
111
115
  function getTranspile(url) {
@@ -44,6 +44,7 @@
44
44
  <div -else>
45
45
  <button @click="chooseFolder">${i18n`选择代码文件夹`}</button>
46
46
  <button @click="editCode()">${i18n`修改国际化参数`}</button>
47
+ <button @click="显示翻译窗口()">${i18n`翻译工具`}</button>
47
48
  <button style="float:right" -if="tableData.length" @click="exportCSV">${i18n`导出到文件`}</button>
48
49
  <hr />
49
50
  <form>
@@ -389,14 +390,21 @@
389
390
  a: button,
390
391
  async baidu() {
391
392
  var fanyi = this.fanyi;
392
- var liang = this.item.liang;
393
+ var item = this.item;
394
+ if (item) {
395
+ var liang = item.liang;
396
+ var text = item.text;
397
+ }
398
+ if (!text) for (var k in fanyi) {
399
+ if (fanyi[k]) text = fanyi[k];
400
+ }
393
401
  for (var s of this.supports) {
394
402
  if (fanyi[s.id] && fanyi[s.id].trim()) continue;
395
- fanyi[s.id] = await requestBaiduFanyi(this.item.text, s.id);
403
+ fanyi[s.id] = await requestBaiduFanyi(text, s.id);
396
404
  liang++;
397
405
  render.digest();
398
406
  }
399
- this.item.liang = liang;
407
+ if (item) item.liang = liang;
400
408
  },
401
409
  save() {
402
410
 
@@ -406,12 +414,11 @@
406
414
  }
407
415
  };
408
416
  var activedRow;
409
- var showDetail = function (event) {
410
- var tr = getTargetIn(tableElement.children[1], event.active, false);
417
+ var initDetailWindow = function () {
411
418
  if (!detailWindow) {
412
419
  detailWindow = view();
413
420
  on('submit')(detailWindow, e => e.preventDefault());
414
- detailWindow.innerHTML = `<div head>${i18n`翻译: `}"<span -bind="item?.text"></span>"<drop @click="close()"></drop></div><lattice itemwidth=260 -src="s in supports" body><field style="display:inline-block;padding:0 0 6px 12px;" ><label style="padding-left:0"><span -bind="s.name"></span>(<span -bind="s.lang"></span>)</label><textarea -model="fanyi[s.id]" class='body' style="resize:none"></textarea></field></lattice><div foot><a style="float:left" @click="baidu">${i18n`一键百度`}</a></div>`;
421
+ detailWindow.innerHTML = `<div head><span -if=!item? >${i18n`翻译工具`} </span><template -else>${i18n`翻译: `}"<span -bind="item?.text"></span>"</template><drop @click="close()"></drop></div><lattice itemwidth=260 -src="s in supports" body><field style="display:inline-block;padding:0 0 6px 12px;" ><label style="padding-left:0"><span -bind="s.name"></span>(<span -bind="s.lang"></span>)</label><textarea -model="fanyi[s.id]" class='body' style="resize:none"></textarea></field></lattice><div foot><a style="float:left" @click="baidu">${i18n`一键百度`}</a></div>`;
415
422
  drag.on(detailWindow, detailWindow.firstElementChild);
416
423
  resize.on(detailWindow);
417
424
  css(detailWindow, `position:absolute;left:0;top:0;bottom:0;width:260px;`);
@@ -423,12 +430,21 @@
423
430
  for (var s of supports) {
424
431
  if (fanyi[s.id] && fanyi[s.id].trim()) count++;
425
432
  }
426
- detailScope.item.liang = count;
427
- removeClass(activedRow, "actived");
428
- activedRow = null;
433
+ if (detailScope.item) {
434
+ detailScope.item.liang = count;
435
+ }
436
+ if (activedRow) {
437
+ removeClass(activedRow, "actived");
438
+ activedRow = null;
439
+ delete detailScope.item;
440
+ }
429
441
  })
430
442
 
431
443
  }
444
+ }
445
+ var showDetail = function (event) {
446
+ initDetailWindow();
447
+ var tr = getTargetIn(tableElement.children[1], event.active, false);
432
448
  var item = detailScope.item = event.item;
433
449
  if (activedRow !== tr) {
434
450
  if (activedRow) removeClass(activedRow, 'actived');
@@ -445,7 +461,12 @@
445
461
  // }
446
462
  if (!item.fanyi) item.fanyi = {}, item.fanyi[supports[0].id] = item.text;
447
463
  detailScope.fanyi = item.fanyi;
448
-
464
+ if (!isMounted(detailWindow)) popup(detailWindow);
465
+ };
466
+ var 显示翻译窗口 = function () {
467
+ initDetailWindow();
468
+ delete detailScope.item;
469
+ detailScope.fanyi = Object.create(null);
449
470
  if (!isMounted(detailWindow)) popup(detailWindow);
450
471
  }
451
472
  var readText = async function (e) {
@@ -61,6 +61,7 @@
61
61
  var v = window.parseFloat(_value);
62
62
  if (s) v = -v;
63
63
  var i = Math.log2(v) | 0;
64
+ if (i < 0) i--;
64
65
  if (!v) i = 0;
65
66
  else v = (v * Math.pow(2, -i) - 1) * Math.pow(2, 52), i += 1023;
66
67
  return [
@@ -77,6 +78,7 @@
77
78
  var i = parseInt(v.slice(0, 3), 16) & 0x7ff;
78
79
  v = parseInt(v.slice(3), 16);
79
80
  if (i === 0 && v === 0) v = 0;
81
+ else if (i < 1023) v = (v + Math.pow(2, 52)) * Math.pow(2, i - 1022 - 53);
80
82
  else v = (v + Math.pow(2, 53)) * Math.pow(2, i - 1023 - 53);
81
83
  if (s) v = -v;
82
84
  _value = v;
@@ -71,7 +71,7 @@
71
71
  overflow: auto;
72
72
  width: 100%;
73
73
  height: 100%;
74
- padding: 10px 20px 600px 20px;
74
+ padding: 10px 20px 60px 20px;
75
75
  white-space: nowrap;
76
76
  outline: none;
77
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.3.6",
3
+ "version": "4.3.7",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {