atr-components 0.2.209 → 0.2.210

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.
@@ -651,7 +651,7 @@ class HttpService {
651
651
  * @param url
652
652
  * @param params
653
653
  */
654
- this.post = (url, params, options, headers) => {
654
+ this.post = (url, params, options, headers, noTip = false) => {
655
655
  return new Observable(observe => {
656
656
  // console.log("aaa");
657
657
  let _headers = new HttpHeaders();
@@ -662,6 +662,7 @@ class HttpService {
662
662
  if (headers) {
663
663
  _headers = headers;
664
664
  }
665
+ _headers = _headers.set("noTip", noTip ? "1" : "0");
665
666
  let withCredentials = true;
666
667
  if (options && options.hasOwnProperty('isWithCredentials')) {
667
668
  withCredentials = options.isWithCredentials;
@@ -682,7 +683,7 @@ class HttpService {
682
683
  });
683
684
  });
684
685
  };
685
- this.postBody = (url, params, options, headers) => {
686
+ this.postBody = (url, params, options, headers, noTip = false) => {
686
687
  return new Observable(observe => {
687
688
  // console.log("aaa");
688
689
  let _headers = new HttpHeaders();
@@ -690,6 +691,7 @@ class HttpService {
690
691
  _headers = this.getDefaultHeader(_headers);
691
692
  }
692
693
  _headers = this.getNormalHeader(_headers);
694
+ _headers = _headers.set("noTip", noTip ? "1" : "0");
693
695
  let withCredentials = true;
694
696
  if (options && options.hasOwnProperty('isWithCredentials')) {
695
697
  withCredentials = options.isWithCredentials;
@@ -710,20 +712,25 @@ class HttpService {
710
712
  });
711
713
  });
712
714
  };
713
- this.get = (url, params, options) => {
715
+ this.get = (url, params, options, noTip = false) => {
714
716
  return new Observable(observe => {
715
717
  let _headers = new HttpHeaders();
716
718
  if (options && options.hasOwnProperty('isCommonHttpHeader')) {
717
719
  _headers = this.getDefaultHeader(_headers);
718
720
  }
719
721
  _headers = this.getNormalHeader(_headers);
722
+ _headers = _headers.set("noTip", noTip ? "1" : "0");
720
723
  let withCredentials = false;
721
724
  if (options && options.hasOwnProperty('isWithCredentials')) {
722
725
  withCredentials = options.isWithCredentials;
723
726
  }
724
727
  // console.log(options)
725
728
  // console.log(_headers)
726
- this.httpClient.get(url, { headers: _headers, params: params, withCredentials: withCredentials }).subscribe(result => {
729
+ this.httpClient.get(url, {
730
+ headers: _headers,
731
+ params: params,
732
+ withCredentials: withCredentials
733
+ }).subscribe(result => {
727
734
  observe.next(result);
728
735
  observe.unsubscribe();
729
736
  }, error => {
@@ -855,14 +862,14 @@ class HttpService {
855
862
  }
856
863
  return atr_static_datas.getNormalHeader(_headers);
857
864
  }
858
- postPromAll(urls, options, headers) {
865
+ postPromAll(urls, options, headers, noTip = false) {
859
866
  let param = [];
860
867
  urls.forEach(item => {
861
- param.push(this.postProm(item.url, item.params, options, headers));
868
+ param.push(this.postProm(item.url, item.params, options, headers, noTip = false));
862
869
  });
863
870
  return Promise.all(param);
864
871
  }
865
- postProm(url, params, options, headers) {
872
+ postProm(url, params, options, headers, noTip = false) {
866
873
  // //console.log("aaa");
867
874
  let _headers = new HttpHeaders();
868
875
  if (options && options.hasOwnProperty('isCommonHttpHeader')) {
@@ -872,6 +879,7 @@ class HttpService {
872
879
  if (headers) {
873
880
  _headers = headers;
874
881
  }
882
+ _headers = _headers.set("noTip", noTip ? "1" : "0");
875
883
  let withCredentials = true;
876
884
  if (options && options.hasOwnProperty('isWithCredentials')) {
877
885
  withCredentials = options.isWithCredentials;
@@ -1085,7 +1093,7 @@ class BaseInterceptor {
1085
1093
  // const errortext = CODEMESSAGE[ev.status] || ev.statusText;
1086
1094
  this.message.error('网络错误,请稍后重试:' + ev.status);
1087
1095
  }
1088
- handleData(ev) {
1096
+ handleData(ev, noTip = false) {
1089
1097
  this.checkStatus(ev);
1090
1098
  // 业务处理:一些通用操作
1091
1099
  switch (ev.status) {
@@ -1099,9 +1107,11 @@ class BaseInterceptor {
1099
1107
  if (ev instanceof HttpResponse) {
1100
1108
  const body = ev.body;
1101
1109
  if (body && body.status === 401) {
1102
- this.notification.error(`未登录或登录已过期,请重新登录。`, ``, {
1103
- nzKey: 'outTime'
1104
- });
1110
+ if (!noTip) {
1111
+ this.notification.error(`未登录或登录已过期,请重新登录。`, ``, {
1112
+ nzKey: 'outTime'
1113
+ });
1114
+ }
1105
1115
  // TODO 清空 token 信息
1106
1116
  LocalStorageUtil.clearUs();
1107
1117
  this.menuService.clear();
@@ -1109,23 +1119,33 @@ class BaseInterceptor {
1109
1119
  }
1110
1120
  else if (body && body.status === 1024) {
1111
1121
  // 或者依然保持完整的格式
1112
- this.message.error(body.message);
1122
+ if (!noTip) {
1123
+ this.message.error(body.message);
1124
+ }
1113
1125
  }
1114
1126
  else if (body && body.status === 1025) {
1115
1127
  // 或者依然保持完整的格式
1116
- this.message.error(`参数为空。`);
1128
+ if (!noTip) {
1129
+ this.message.error(`参数为空。`);
1130
+ }
1117
1131
  }
1118
1132
  else if (body && body.status === 503) {
1119
1133
  // 或者依然保持完整的格式
1120
- this.message.error(body.message);
1134
+ if (!noTip) {
1135
+ this.message.error(body.message);
1136
+ }
1121
1137
  }
1122
1138
  else if (body && body.status === 204) {
1123
1139
  // 或者依然保持完整的格式
1124
- this.message.success(body.message);
1140
+ if (!noTip) {
1141
+ this.message.success(body.message);
1142
+ }
1125
1143
  }
1126
1144
  else if (body && body.status === 201) {
1127
1145
  // 或者依然保持完整的格式
1128
- this.message.success(body.message);
1146
+ if (!noTip) {
1147
+ this.message.success(body.message);
1148
+ }
1129
1149
  }
1130
1150
  else {
1131
1151
  return of(ev);
@@ -1164,13 +1184,14 @@ class BaseInterceptor {
1164
1184
  url = atr_static_datas.SERVER_URL + url;
1165
1185
  req = req.clone({ url });
1166
1186
  }
1187
+ let noTip = req.headers.get("noTip");
1167
1188
  return next.handle(req).pipe(mergeMap((event) => {
1168
1189
  // 允许统一对请求错误处理
1169
1190
  if (event instanceof HttpResponseBase)
1170
- return this.handleData(event);
1191
+ return this.handleData(event, noTip == "1");
1171
1192
  // 若一切都正常,则后续操作
1172
1193
  return of(event);
1173
- }), catchError((err) => this.handleData(err)));
1194
+ }), catchError((err) => this.handleData(err, noTip == "1")));
1174
1195
  }
1175
1196
  }
1176
1197
  BaseInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: BaseInterceptor, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });