atr-components 0.2.229 → 0.2.230

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.
@@ -287,6 +287,20 @@ class ToolsUtil {
287
287
  }
288
288
  }
289
289
  }
290
+ static dataURLtoBlob(dataurl) {
291
+ var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
292
+ while (n--) {
293
+ u8arr[n] = bstr.charCodeAt(n);
294
+ }
295
+ return new Blob([u8arr], { type: mime });
296
+ }
297
+ static dataURLtoFile(dataurl, filename) {
298
+ var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
299
+ while (n--) {
300
+ u8arr[n] = bstr.charCodeAt(n);
301
+ }
302
+ return new File([u8arr], (filename || ToolsUtil.getRandomFileName()), { type: mime });
303
+ }
290
304
  static getYesterday(day) {
291
305
  let time = day.getTime() - 1000 * 60 * 60 * 24;
292
306
  day = new Date(time);
@@ -1982,12 +1996,12 @@ class UploadOssService {
1982
1996
  constructor(httpService, httpClient) {
1983
1997
  this.httpService = httpService;
1984
1998
  this.httpClient = httpClient;
1985
- this.uploadOss = (file, dir = 'ueditor') => {
1999
+ this.uploadOss = (file, dir = 'ueditor', fullUrl = true) => {
1986
2000
  return new Observable(observe => {
1987
2001
  const success = (result) => {
1988
2002
  if (result.status === 200) {
1989
2003
  this.uploadData = result.data;
1990
- this.customReq(file).subscribe((url) => {
2004
+ this.customReq(file, fullUrl).subscribe((url) => {
1991
2005
  observe.next(url);
1992
2006
  observe.unsubscribe();
1993
2007
  });
@@ -2002,10 +2016,13 @@ class UploadOssService {
2002
2016
  observe.unsubscribe();
2003
2017
  };
2004
2018
  let fileName = ToolsUtil.getRandomFileName() + "." + ToolsUtil.getFileExt(file.name);
2005
- this.httpService.post(atr_static_datas.OSS_POLICY, { dir: dir, fileName: fileName }, ToolsUtil.getHttpOptions()).subscribe(success, error);
2019
+ this.httpService.post(atr_static_datas.OSS_POLICY, {
2020
+ dir: dir,
2021
+ fileName: fileName
2022
+ }, ToolsUtil.getHttpOptions()).subscribe(success, error);
2006
2023
  });
2007
2024
  };
2008
- this.customReq = (file) => {
2025
+ this.customReq = (file, fullUrl = true) => {
2009
2026
  const formData = new FormData();
2010
2027
  for (let key in this.uploadData) {
2011
2028
  if (key != 'host')
@@ -2020,7 +2037,7 @@ class UploadOssService {
2020
2037
  if (event.type === HttpEventType.UploadProgress) {
2021
2038
  }
2022
2039
  else if (event instanceof HttpResponse) {
2023
- const url = event.url + this.uploadData.key;
2040
+ const url = fullUrl ? (event.url + this.uploadData.key) : this.uploadData.key;
2024
2041
  observe.next(url);
2025
2042
  observe.unsubscribe();
2026
2043
  }
@@ -4724,6 +4741,7 @@ class ImgCanvasComponent {
4724
4741
  this.elementRef = elementRef;
4725
4742
  this.width = 800;
4726
4743
  this.height = 800;
4744
+ this.clipArr = [];
4727
4745
  }
4728
4746
  set url(url) {
4729
4747
  this.imgUrl = url;
@@ -4785,11 +4803,25 @@ class ImgCanvasComponent {
4785
4803
  const { imgW, imgH } = this.getCanvasFull();
4786
4804
  this.canvasDom.width = this.width;
4787
4805
  this.canvasDom.height = this.height;
4806
+ if (this.clipArr && this.clipArr.length > 0) {
4807
+ this.goClip(context1);
4808
+ }
4788
4809
  // 参数 1:要绘制的 img 参数 2、3:绘制的 img 在 canvas 中的坐标 参数4,5是width,height
4789
4810
  context1.drawImage(this.img, 0, 0, this.width, this.height);
4790
4811
  console.log("图片加载完毕", this.canvasDom.width + "," + this.canvasDom.height);
4791
4812
  };
4792
4813
  }
4814
+ goClip(context) {
4815
+ context.beginPath();
4816
+ context.moveTo(this.clipArr[0].x1, this.clipArr[0].y1);
4817
+ this.clipArr.forEach((item, index) => {
4818
+ if (index > 0) {
4819
+ context.lineTo(item.x1, item.y1);
4820
+ }
4821
+ });
4822
+ context.lineTo(this.clipArr[0].x1, this.clipArr[0].y1);
4823
+ context.clip();
4824
+ }
4793
4825
  ngAfterViewInit() {
4794
4826
  setTimeout(() => {
4795
4827
  console.log('当前组件宽高', this.elementRef.nativeElement.offsetHeight);
@@ -4798,7 +4830,7 @@ class ImgCanvasComponent {
4798
4830
  }
4799
4831
  }
4800
4832
  ImgCanvasComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ImgCanvasComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
4801
- ImgCanvasComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: ImgCanvasComponent, selector: "app-img", inputs: { url: "url" }, 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: [""] });
4833
+ 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: [""] });
4802
4834
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: ImgCanvasComponent, decorators: [{
4803
4835
  type: Component,
4804
4836
  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: [""] }]
@@ -4807,6 +4839,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
4807
4839
  }], canvas1: [{
4808
4840
  type: ViewChild,
4809
4841
  args: ['canvas1', { static: false }]
4842
+ }], clipArr: [{
4843
+ type: Input
4810
4844
  }] } });
4811
4845
 
4812
4846
  const THIRDMODULES = [