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