atr-components 0.2.237 → 0.2.239

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.
@@ -387,12 +387,31 @@ class ToolsUtil {
387
387
  }
388
388
  return date.getFullYear() + "-" + month + "-" + strDate + " " + hours + ":" + seconds;
389
389
  }
390
+ static getFormatDateHour(date) {
391
+ let month = date.getMonth() + 1;
392
+ let strDate = date.getDate();
393
+ let hours = date.getHours();
394
+ let seconds = date.getMinutes();
395
+ if (month <= 9) {
396
+ month = "0" + month;
397
+ }
398
+ if (strDate <= 9) {
399
+ strDate = "0" + strDate;
400
+ }
401
+ if (hours <= 9) {
402
+ hours = "0" + hours;
403
+ }
404
+ if (seconds <= 9) {
405
+ seconds = "0" + seconds;
406
+ }
407
+ return date.getFullYear() + "" + month + strDate + hours;
408
+ }
390
409
  static getOssUrl(url, needTime = false) {
391
410
  if (!url) {
392
411
  return "";
393
412
  }
394
413
  if (needTime) {
395
- url = url + "?v=" + new Date().getTime();
414
+ url = url + "?v=" + ToolsUtil.getFormatDateHour(new Date());
396
415
  }
397
416
  if (url.startsWith("http")) {
398
417
  return url;
@@ -1817,8 +1836,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
1817
1836
  class OssImgPipe {
1818
1837
  constructor() {
1819
1838
  }
1820
- transform(value, isVideoCover = false) {
1821
- return isVideoCover ? ToolsUtil.getVideoCover(value) : ToolsUtil.getOssUrl(value);
1839
+ transform(value, isVideoCover = false, needTime = false) {
1840
+ return isVideoCover ? ToolsUtil.getVideoCover(value) : ToolsUtil.getOssUrl(value, needTime);
1822
1841
  }
1823
1842
  }
1824
1843
  OssImgPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: OssImgPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
@@ -4747,8 +4766,16 @@ class ImgCanvasComponent {
4747
4766
  this.width = 800;
4748
4767
  this.height = 800;
4749
4768
  this.clipArr = [];
4769
+ this.rotateNum = 0;
4770
+ this.loadOver = new EventEmitter();
4750
4771
  }
4751
4772
  set url(url) {
4773
+ if (url && url.indexOf('?v=') < 0) {
4774
+ if (url.indexOf("?") < 0) {
4775
+ url += "?";
4776
+ }
4777
+ url += "v=" + new Date().getTime();
4778
+ }
4752
4779
  this.imgUrl = url;
4753
4780
  }
4754
4781
  ngOnInit() {
@@ -4790,7 +4817,7 @@ class ImgCanvasComponent {
4790
4817
  imgH: imgH
4791
4818
  };
4792
4819
  }
4793
- initImg() {
4820
+ initImg(needSession = true) {
4794
4821
  this.canvasDom = this.canvas1.nativeElement;
4795
4822
  // this.canvasDom = document.getElementById(this.canvasId);
4796
4823
  //检测支持性
@@ -4798,24 +4825,29 @@ class ImgCanvasComponent {
4798
4825
  return;
4799
4826
  //获得 2d 上下文对象
4800
4827
  let context1 = this.canvasDom.getContext('2d');
4828
+ let image = this.imgUrl;
4801
4829
  this.img = new Image(); //创建img元素
4802
4830
  this.img.setAttribute('crossOrigin', 'anonymous');
4803
4831
  this.img.src = this.imgUrl; //设置图片源地址
4804
4832
  // this.img.src = ToolsUtil.getOssUrl(this.imgUrl);//设置图片源地址
4805
4833
  this.img.onload = () => {
4806
- console.log("图片加载完毕", this.img.height);
4807
- console.log("图片加载完毕", this.img.width);
4808
- const { imgW, imgH } = this.getCanvasFull();
4809
- this.canvasDom.width = this.width;
4810
- this.canvasDom.height = this.height;
4811
- if (this.clipArr && this.clipArr.length > 0) {
4812
- this.goClip(context1);
4813
- }
4814
- // 参数 1:要绘制的 img 参数 2、3:绘制的 img 在 canvas 中的坐标 参数4,5是width,height
4815
- context1.drawImage(this.img, 0, 0, this.width, this.height);
4816
- console.log("图片加载完毕", this.canvasDom.width + "," + this.canvasDom.height);
4834
+ this.initBase(context1);
4835
+ this.loadOver.emit({ code: 'loadOver' });
4817
4836
  };
4818
4837
  }
4838
+ initBase(context1) {
4839
+ console.log("图片加载完毕", this.img.height);
4840
+ console.log("图片加载完毕", this.img.width);
4841
+ const { imgW, imgH } = this.getCanvasFull();
4842
+ this.canvasDom.width = this.width;
4843
+ this.canvasDom.height = this.height;
4844
+ if (this.clipArr && this.clipArr.length > 0) {
4845
+ this.goClip(context1);
4846
+ }
4847
+ // 参数 1:要绘制的 img 参数 2、3:绘制的 img 在 canvas 中的坐标 参数4,5是width,height
4848
+ context1.drawImage(this.img, 0, 0, this.width, this.height);
4849
+ console.log("图片加载完毕", this.canvasDom.width + "," + this.canvasDom.height);
4850
+ }
4819
4851
  goClip(context) {
4820
4852
  context.beginPath();
4821
4853
  context.moveTo(this.clipArr[0].x1, this.clipArr[0].y1);
@@ -4835,10 +4867,10 @@ class ImgCanvasComponent {
4835
4867
  }
4836
4868
  }
4837
4869
  ImgCanvasComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ImgCanvasComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
4838
- ImgCanvasComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ImgCanvasComponent, selector: "app-img", inputs: { url: "url", clipArr: "clipArr" }, viewQueries: [{ propertyName: "canvas1", first: true, predicate: ["canvas1"], descendants: true }], ngImport: i0, template: "<canvas #canvas1 style=\"width: 100%;height: 100%\">\n \u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u753B\u5E03\uFF01\n</canvas>\n", styles: [""] });
4870
+ ImgCanvasComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ImgCanvasComponent, selector: "app-img", inputs: { url: "url", clipArr: "clipArr", rotateNum: "rotateNum" }, outputs: { loadOver: "loadOver" }, viewQueries: [{ propertyName: "canvas1", first: true, predicate: ["canvas1"], descendants: true }], ngImport: i0, template: "<canvas #canvas1 style=\"width: 100%;height: 100%;\">\n \u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u753B\u5E03\uFF01\n</canvas>\n<ng-content></ng-content>\n", styles: [""] });
4839
4871
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ImgCanvasComponent, decorators: [{
4840
4872
  type: Component,
4841
- args: [{ selector: 'app-img', template: "<canvas #canvas1 style=\"width: 100%;height: 100%\">\n \u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u753B\u5E03\uFF01\n</canvas>\n", styles: [""] }]
4873
+ args: [{ selector: 'app-img', template: "<canvas #canvas1 style=\"width: 100%;height: 100%;\">\n \u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u753B\u5E03\uFF01\n</canvas>\n<ng-content></ng-content>\n", styles: [""] }]
4842
4874
  }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { url: [{
4843
4875
  type: Input
4844
4876
  }], canvas1: [{
@@ -4846,6 +4878,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
4846
4878
  args: ['canvas1', { static: false }]
4847
4879
  }], clipArr: [{
4848
4880
  type: Input
4881
+ }], rotateNum: [{
4882
+ type: Input
4883
+ }], loadOver: [{
4884
+ type: Output
4849
4885
  }] } });
4850
4886
 
4851
4887
  const THIRDMODULES = [