efront 4.5.13 → 4.5.15

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.
@@ -1,4 +1,3 @@
1
- cross.addDirect(/^https?\:\/\/([[a-z\.\d\:\/%]+\]|[\d\.]+)(\:\d+)?\//);
2
1
  var checkPort = async function (p, ip) {
3
2
  if (!p.host) {
4
3
  if (/^::ffff:\d+\.\d+\.\d+\.\d+$/i.test(ip)) {
@@ -11,10 +10,13 @@ var checkPort = async function (p, ip) {
11
10
  }
12
11
  try {
13
12
  p.locate("/:version");
14
- var { response } = await cross("options", p.href);
15
- if (/^efront/.test(response)) {
13
+ var xhr = await cross("@options", p.href);
14
+ if (/^efront/.test(xhr.response)) {
16
15
  p.ok = true;
17
16
  }
17
+ else {
18
+ p.error = '异常';
19
+ }
18
20
  } catch (e) {
19
21
  p.error = e;
20
22
  }
@@ -50,7 +52,7 @@ function main() {
50
52
  page.innerHTML = template;
51
53
  var items = data.from("bootlog", datas => {
52
54
  datas.forEach(a => {
53
- var [v, p] = a.ppid.split("/");
55
+ var [v, p] = String(a.ppid).split("/");
54
56
  a.version = v;
55
57
  a.pid = p;
56
58
  });
@@ -77,7 +77,7 @@ class Table extends Array {
77
77
  var [p, m] = mark.power(name, searchtext);
78
78
  if (p > power) power = p;
79
79
  if (p >= searchtext.length) this.coverCount++;
80
- if (!isEmpty(f.key)) o[f.key] = m;
80
+ if (!isEmpty(f.key) && !isFunction(f.key)) o[f.key] = m;
81
81
  else o.name = m, o.toString = returnName, o.valueOf = returnName;
82
82
  }
83
83
  o.power = power;
@@ -195,7 +195,9 @@ function cross_(jsonp, digest = noop, method, url, headers) {
195
195
  else {
196
196
  var isencrypt = /^[夏商周秦xszq]/i.test(method);
197
197
  if (isencrypt) method = method.slice(1);
198
- var nocross = notCross(url, isencrypt);
198
+ var nocross = /^@/.test(method);
199
+ if (nocross) method = method.slice(1);
200
+ else nocross = notCross(url, isencrypt);
199
201
  if (nocross) isencrypt = false;
200
202
  var callback = async function () {
201
203
  if (xhr.getResponseHeader) {
@@ -4,7 +4,7 @@ function fixLength(minute, length = 2) {
4
4
  if (minute.length >= length) return minute;
5
5
  return new Array(length - minute.length + 1).join("0") + minute;
6
6
  }
7
- var days = "天一二三四五六";
7
+ var days = "日一二三四五六天";
8
8
  function format(formater) {
9
9
  var v = getSplitedDate(this);
10
10
  var o = {};
@@ -39,8 +39,25 @@ function format(formater) {
39
39
  }
40
40
  function filterTime(time, formater) {
41
41
  if (!isHandled(time)) return '';
42
- if (isFinite(time)) time = +time;
43
- var value = new Date(time);
42
+ var value = time;
43
+ if (isFinite(value)) value = +value;
44
+ if (typeof value === 'string') value = value.replace(/[\\\/]/g, "-")
45
+ .replace(/[年月](\d+)/g, '-$1')
46
+ .replace(/[日号]/, ' ')
47
+ .replace(/[时点分]/g, ":")
48
+ .replace(/[半]/g, "30")
49
+ .replace(/[整]/g, "00")
50
+ .replace(/[一1]刻/g, "15")
51
+ .replace(/[三3]刻/g, "45")
52
+ .replace(/凌晨|早上|上午/g, ' ')
53
+ .replace(/(?:傍?晚上?|下午)(\d+)/g, (_, d) => " " + (+d + 12))
54
+ .replace(/秒/g, '.')
55
+ .replace(/毫/, "")
56
+ .replace(/\.+$/, '')
57
+ .replace(/\s+$/, '')
58
+ .replace(/\s+/g, " ")
59
+ .replace(/^([^\s]+)\s+(\d+)$/g, "$1 $2:00");
60
+ var value = new Date(value);
44
61
  if (!+value) {
45
62
  return time;
46
63
  }
@@ -48,7 +65,7 @@ function filterTime(time, formater) {
48
65
  return format.call(value, formater);
49
66
  }
50
67
  if (formater) {
51
- formater = format.charAt(0);
68
+ formater = formater.charAt(0);
52
69
  }
53
70
  var splited = getSplitedDate(value);
54
71
  var now = new Date;
@@ -67,6 +84,7 @@ function filterTime(time, formater) {
67
84
  return `星期` + days[day] + time;
68
85
  }
69
86
  else if (delta > -7 && delta < -2) {
87
+ console.log(day, day1)
70
88
  if (day <= day1) {
71
89
  return `下星期` + days[day] + time;
72
90
  }
@@ -97,12 +115,12 @@ function filterTime(time, formater) {
97
115
  switch (year1 - year) {
98
116
  case 0:
99
117
  if (value > now) {
100
- return `今年${month}${format || '月'}${date}${format ? '' : '日'} ${time}`;
118
+ return `今年${month}${formater || '月'}${date}${formater ? '' : '日'} ${time}`;
101
119
  }
102
- return `${month}${format || '月'}${date}${format ? '' : '日'} `;
120
+ return `${month}${formater || '月'}${date}${formater ? '' : '日'} `;
103
121
  case 1:
104
122
  if (month1 < month) {
105
- return `${month}${format || '月'}${date}${format ? '' : '日'} `;
123
+ return `${month}${formater || '月'}${date}${formater ? '' : '日'} `;
106
124
  }
107
125
  return "去年" + month + "月";
108
126
  case -1:
@@ -112,6 +130,6 @@ function filterTime(time, formater) {
112
130
  case -2:
113
131
  return "后年" + month + "月" + date + "日";
114
132
  }
115
- return `${year}${format || '年'}${month}${format || "月"}`;
133
+ return `${year}${formater || '年'}${month}${formater || "月"}`;
116
134
  }
117
135
  }
@@ -2,7 +2,17 @@ assert(filterTime(''), ``);
2
2
  assert(filterTime(null), '');
3
3
  assert(filterTime(undefined), '');
4
4
  assert(filterTime("我出生的第二年"), `我出生的第二年`);
5
- assert(filterTime(new Date(new Date - 100)), `刚刚`);
6
- assert(filterTime(new Date(new Date - 60000), `h:mm`), "");
7
- assert(filterTime(new Date(new Date - 86400000), `M月d日 h:mm`), "");
8
- assert(filterTime(new Date(new Date().setFullYear(new Date().getFullYear() - 1)), `y年M月d日 h:mm`), '');
5
+ assert(filterTime(new Date(2024, 3, 3), `y年M月d日 h:mm`), '2024年4月3日 0:00');
6
+ assert(filterTime(new Date(2024, 3, 3), `y年M月d日 h:mm`), '2024年4月3日 0:00');
7
+ assert(filterTime("2024年4月3号", `y年M月d日h:mm`), '2024年4月3日0:00');
8
+ assert(filterTime("2024年4月3号8点半", `y年M月d日h:mm`), '2024年4月3日8:30');
9
+ assert(filterTime("2024年4月3号9点三刻", `y年M月d日h:mm`), '2024年4月3日9:45');
10
+ assert(filterTime("2024年4月3号9点一刻", `y年M月d日h:mm`), '2024年4月3日9:15');
11
+ assert(filterTime("2024年4月3号下午3点一刻", `y年M月d日h:mm`), '2024年4月3日15:15');
12
+ assert(filterTime("2024年4月3号上午9点一刻", `y年M月d日h:mm`), '2024年4月3日9:15');
13
+ assert(filterTime("2024年4月3号晚上9点一刻", `y年M月d日h:mm`), '2024年4月3日21:15');
14
+ assert(filterTime("2024年4月3号傍晚6点一刻", `y年M月d日h:mm`), '2024年4月3日18:15');
15
+ assert(filterTime("2024年4月3号凌晨6点", `y年M月d日h:mm`), '2024年4月3日6:00');
16
+ assert(filterTime("2024年4月3号凌晨6点整", `y年M月d日h:mm`), '2024年4月3日6:00');
17
+ assert(filterTime("2024/4/3凌晨6点整", `y年M月d日h:mm`), '2024年4月3日6:00');
18
+ assert(filterTime("2024-4-3早上6点整", `y年M月d日h:mm`), '2024年4月3日6:00');
@@ -1,3 +1,3 @@
1
1
  function getSplitedDate(date) {
2
- return [date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds(), date.getDay()];
2
+ return [date.getFullYear(), date.getMonth() + 1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds(), date.getDay() || 7];
3
3
  }
@@ -69,7 +69,6 @@ var ASN1 = function (type) {
69
69
  length += bytes.length;
70
70
  }
71
71
  var asn1 = [type];
72
- if (length === (2 << 8 | 36)) console.log(arguments)
73
72
  if (length > 127) {
74
73
  var nums = [];
75
74
  while (length > 0) {
@@ -354,7 +353,7 @@ var acme2 = new class {
354
353
  async autoUpdate(saveUnique, domain, setauth, upload) {
355
354
  if (!domain.length) return;
356
355
  if (acme2.orders.length >= 20) acme2.orders.pop();
357
- this.lastUpdateTime = parseDate(Date.now());
356
+ this.lastUpdateTime = filterTime(Date.now(), 'y-MM-dd hh:mm');
358
357
  this.updateTime();
359
358
  var o = await acme2.newOrder({ domain });
360
359
  await saveUnique();// 及时保存订单信息以便后续查看
@@ -280,7 +280,7 @@ var render = function (value, models = "年月日", message = "") {
280
280
  if (_value instanceof Event) {
281
281
  _value = _value.target.value;
282
282
  }
283
- _value = parseDate(_value);
283
+ _value = filterTime(_value, "y-M-d h:mm:ss");
284
284
  _value = InternelDate(_value);
285
285
  value = _value;
286
286
  };
@@ -289,7 +289,7 @@ var render = function (value, models = "年月日", message = "") {
289
289
  };
290
290
 
291
291
  function main(models = "年月日", value, title) {
292
- value = parseDate(value);
292
+ value = filterTime(value, 'y-M-d h:mm:ss');
293
293
  value = InternelDate(value);
294
294
  var datebox = render(value, models, title);
295
295
  addClass(datebox, 'date-' + models.length);
@@ -171,7 +171,6 @@ function main() {
171
171
  case this.children[0]:
172
172
  var a = prompt("请输入", a => {
173
173
  if (!a) return false;
174
- console.log(itemMap, a);
175
174
  if (a in itemMap) {
176
175
  return `选项 ${a} 已存在!`;
177
176
  }
@@ -9,7 +9,7 @@
9
9
  </tr>
10
10
  </thead>
11
11
  <tbody -src="(d,i) in data" :style="tbodyHeight(this,hasFoot)">
12
- <tr inline-block :style="{width:adapter.style.width}" @click="rowClick(d,i,event)">
12
+ <tr inline-block :style="{width:adapter.style.width}" @click="rowClick(d,i,event)" @mounted="resizeR(this)">
13
13
  <td fixed row-index -bind="i+1" :style="adapter.firstChild.getAttribute('style')">
14
14
  </td>
15
15
  <td fixed:="f.fixed" -repeat="(f,i) in fields" :style="adapter.children[i+1].getAttribute('style')">
@@ -68,11 +68,29 @@ var getRowsOfTdsByCol = function (table, start, end) {
68
68
  var getTdsByCol = function (table, start, end) {
69
69
  return [].concat.apply([], getRowsOfTdsByCol(table, start, end));
70
70
  };
71
+ var resizeR = function (t) {
72
+ var h = 0;
73
+ var children = [];
74
+ for (var c of t.children) {
75
+ if (getColspan(c) > 1) continue;
76
+ children.push(c);
77
+ }
78
+ for (var c of children) {
79
+ var height = c.offsetHeight;
80
+ if (h < height) h = height;
81
+ }
82
+ for (var c of children) {
83
+ var height = c.offsetHeight;
84
+ if (h > height) {
85
+ css(c, { height: h });
86
+ }
87
+ }
88
+ }
71
89
  var resizeT = function (t, w) {
72
90
  if (!w) {
73
91
  var w = 0;
74
- for (var cx = 0, dx = t.children.length; cx < dx; cx++) {
75
- w += t.children[cx].offsetWidth;
92
+ for (var c of t.children) {
93
+ w += c.offsetWidth;
76
94
  }
77
95
  }
78
96
  css(t, { width: w });
@@ -328,9 +346,7 @@ var removeYIng = function (activeCols) {
328
346
  });
329
347
  };
330
348
  var removeXIng = function (activeRows) {
331
- activeRows.forEach(function (td) {
332
- removeClass(td, 'x-ing');
333
- });
349
+ for (var td of activeRows) removeClass(td, 'x-ing');
334
350
  };
335
351
 
336
352
  var getTdsOfSameRow = function (td) {
@@ -517,6 +533,7 @@ function table(elem) {
517
533
  data,
518
534
  adapter: null,
519
535
  resizeT,
536
+ resizeR,
520
537
  model,
521
538
  sort(f) {
522
539
  this.data.sort(f);
@@ -54,6 +54,7 @@ td {
54
54
  top: 0;
55
55
  bottom: 0;
56
56
  right: 0;
57
+ pointer-events: none;
57
58
  background-color: rgba(0, 60, 69, .06);
58
59
  }
59
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.5.13",
3
+ "version": "4.5.15",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {