atr-components 0.2.305 → 0.2.308

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.
@@ -12,6 +12,7 @@ import * as i2$3 from 'ng-zorro-antd/message';
12
12
  import { NzMessageService, NzMessageModule } from 'ng-zorro-antd/message';
13
13
  import * as i3$1 from '@angular/forms';
14
14
  import { Validators, FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR, FormControl } from '@angular/forms';
15
+ import { ulid } from 'ulid';
15
16
  import { NzAffixModule } from 'ng-zorro-antd/affix';
16
17
  import { NzAlertModule } from 'ng-zorro-antd/alert';
17
18
  import { NzAnchorModule } from 'ng-zorro-antd/anchor';
@@ -128,7 +129,6 @@ const transAnimation = animation([
128
129
  ]);
129
130
 
130
131
  const atr_static_datas = {
131
- test: '1',
132
132
  /**
133
133
  * oss地址前缀
134
134
  */
@@ -246,6 +246,9 @@ class SessionStorageUtil {
246
246
  }
247
247
 
248
248
  class ToolsUtil {
249
+ static getUlid() {
250
+ return ulid();
251
+ }
249
252
  static isBase64(string) {
250
253
  let reg = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;
251
254
  return reg.test(string);
@@ -282,6 +285,93 @@ class ToolsUtil {
282
285
  static httpSucces(res) {
283
286
  return ['200', '201', '204'].some(v => res.status == v);
284
287
  }
288
+ /**
289
+ * 计算两点坐标距离
290
+ * @param point1
291
+ * @param point2
292
+ */
293
+ static getDistance(point1, point2) {
294
+ let distance = Math.sqrt((point2.x - point1.x) * (point2.x - point1.x) + (point2.y - point1.y) * (point2.y - point1.y));
295
+ return distance;
296
+ }
297
+ /**
298
+ * 判断线段是否相交,相交返回交点坐标
299
+ * @param p1
300
+ * @param p2
301
+ */
302
+ static checkIntersect(lineArr1, lineArr2) {
303
+ //解线性方程组求线段交点
304
+ //如果父母为0,则不需要计算交点 两线平行
305
+ let a = lineArr1[0], b = lineArr1[1], c = lineArr2[0], d = lineArr2[1];
306
+ a = { x: parseFloat(a.x.toFixed(2)), y: parseFloat(a.y.toFixed(2)) };
307
+ b = { x: parseFloat(b.x.toFixed(2)), y: parseFloat(b.y.toFixed(2)) };
308
+ c = { x: parseFloat(c.x.toFixed(2)), y: parseFloat(c.y.toFixed(2)) };
309
+ d = { x: parseFloat(d.x.toFixed(2)), y: parseFloat(d.y.toFixed(2)) };
310
+ console.log((b.y - a.y));
311
+ console.log((d.x - c.x));
312
+ console.log((a.x - b.x));
313
+ console.log((c.y - d.y));
314
+ let denominator = (b.y - a.y) * (d.x - c.x) - (a.x - b.x) * (c.y - d.y);
315
+ if (denominator == 0) {
316
+ return false;
317
+ }
318
+ let x = ((b.x - a.x) * (d.x - c.x) * (c.y - a.y)
319
+ + (b.y - a.y) * (d.x - c.x) * a.x
320
+ - (d.y - c.y) * (b.x - a.x) * c.x) / denominator, y = -((b.y - a.y) * (d.y - c.y) * (c.x - a.x)
321
+ + (b.x - a.x) * (d.y - c.y) * a.y
322
+ - (d.x - c.x) * (b.y - a.y) * c.y) / denominator;
323
+ //判断交点是否在两条线段上
324
+ if (
325
+ //交点在线段1
326
+ (x - a.x) * (x - b.x) <= 0 && (y - a.y) * (y - b.y) <= 0 &&
327
+ //并且交点在线段2上
328
+ (x - c.x) * (x - d.x) <= 0 && (y - c.y) * (y - d.y) <= 0) {
329
+ return { x: x, y: y };
330
+ }
331
+ return false;
332
+ }
333
+ //判断点是否在线段上
334
+ static checkInLine(startP, endP, a) {
335
+ //点和端点重合
336
+ if ((startP.x == endP.x && startP.y == endP.y)
337
+ || (startP.x == a.x && startP.y == a.y)
338
+ || (endP.x == a.x && endP.y == a.y)) {
339
+ return true;
340
+ }
341
+ if (startP.x == endP.x && endP.x != a.x) {
342
+ return false;
343
+ }
344
+ else if (startP.x == endP.x && endP.x == a.x) {
345
+ if (startP.y > endP.y) {
346
+ return startP.y > a.y && endP.y < a.y;
347
+ }
348
+ return startP.y < a.y && endP.y < a.y;
349
+ }
350
+ //判断点在线段上
351
+ //斜率是否一致
352
+ let k1 = (endP.y - startP.y) / (endP.x - startP.x);
353
+ let b = startP.y - k1 * startP.x;
354
+ //y = kx + y1 - kx1
355
+ //b = y1 - kx1
356
+ let y = k1 * a.x + b, num = y - a.y;
357
+ if (num > -5 && num < 5) {
358
+ //5像素的误差
359
+ let startLen = ToolsUtil.getLength(startP, a);
360
+ let endLen = ToolsUtil.getLength(a, endP);
361
+ let len = ToolsUtil.getLength(startP, endP);
362
+ return len >= startLen && len >= endLen;
363
+ }
364
+ // let k2 = (a.y - startP.y) / (a.x - startP.x);
365
+ // //Number.EPSILON是精度误差
366
+ // if (Math.abs(k1 - k2) <= Number.EPSILON) {
367
+ // //斜率一致,并且a在线段上
368
+ // let startLen = ToolsUtil.getLength(startP, a)
369
+ // let endLen = ToolsUtil.getLength(a, endP)
370
+ // let leng = ToolsUtil.getLength(startP, endP)
371
+ // return leng >= startLen && leng >= endLen
372
+ // }
373
+ return false;
374
+ }
285
375
  /**
286
376
  *判断点是否在坐标区域内
287
377
  * @param p 判定的点
@@ -342,6 +432,9 @@ class ToolsUtil {
342
432
  action();
343
433
  }
344
434
  }
435
+ static deepCopy(obj) {
436
+ return JSON.parse(JSON.stringify(obj));
437
+ }
345
438
  static diffInputs(chng, action) {
346
439
  if (chng === undefined)
347
440
  return;
@@ -649,11 +742,21 @@ class ToolsUtil {
649
742
  return { 'maxHeight': ToolsUtil.windowHeight() - 200 + 'px', 'overflow-y': 'auto' };
650
743
  }
651
744
  static getLength(pointA, pointB) {
745
+ pointA.x1 = pointA.x || pointA.x1;
746
+ pointA.y1 = pointA.y || pointA.y1;
747
+ pointB.y1 = pointB.y || pointB.y1;
748
+ pointB.x1 = pointB.x || pointB.x1;
652
749
  var lengthAB = Math.sqrt(Math.pow(pointA.x1 - pointB.x1, 2) +
653
750
  Math.pow(pointA.y1 - pointB.y1, 2));
654
751
  return lengthAB;
655
752
  }
656
753
  static getRotateNum(pointB, pointC, pointA) {
754
+ pointA.x1 = pointA.x || pointA.x1;
755
+ pointA.y1 = pointA.y || pointA.y1;
756
+ pointB.x1 = pointB.y || pointB.x1;
757
+ pointB.y1 = pointB.x || pointB.x1;
758
+ pointC.x1 = pointC.y || pointC.x1;
759
+ pointC.y1 = pointC.x || pointC.x1;
657
760
  //ABC中心点,起始点,终点
658
761
  let AB = {};
659
762
  let AC = {};
@@ -2249,16 +2352,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
2249
2352
 
2250
2353
  class HelloComponent {
2251
2354
  constructor() {
2252
- this.test = atr_static_datas.test;
2253
2355
  }
2254
2356
  ngOnInit() {
2255
2357
  }
2256
2358
  }
2257
2359
  HelloComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: HelloComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2258
- HelloComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: HelloComponent, selector: "atr-hello", ngImport: i0, template: "<p>hello works!</p>\n<p>\u6D4B\u8BD5:{{test}}</p>\n", styles: [""] });
2360
+ HelloComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: HelloComponent, selector: "atr-hello", ngImport: i0, template: "<p>hello works!</p>\n", styles: [""] });
2259
2361
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: HelloComponent, decorators: [{
2260
2362
  type: Component,
2261
- args: [{ selector: 'atr-hello', template: "<p>hello works!</p>\n<p>\u6D4B\u8BD5:{{test}}</p>\n", styles: [""] }]
2363
+ args: [{ selector: 'atr-hello', template: "<p>hello works!</p>\n", styles: [""] }]
2262
2364
  }], ctorParameters: function () { return []; } });
2263
2365
 
2264
2366
  class HelloModule {