ng-alain 14.0.0-beta.1 → 14.0.0
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/application/files/src/app/core/net/default.interceptor.ts +18 -17
- package/application/files/src/app/routes/exception/trigger.component.ts +4 -4
- package/ng-update/upgrade-rules/v14/index.js +1 -1
- package/ng-update/upgrade-rules/v14/index.ts +1 -1
- package/package.json +1 -1
- package/utils/lib-versions.js +1 -1
- package/utils/lib-versions.ts +1 -1
- package/utils/versions.js +3 -4
- package/utils/versions.js.map +1 -1
- package/utils/versions.ts +3 -4
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { Injectable, Injector } from '@angular/core';
|
|
11
11
|
import { Router } from '@angular/router';
|
|
12
12
|
import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
|
|
13
|
-
import { ALAIN_I18N_TOKEN, _HttpClient } from '@delon/theme';
|
|
13
|
+
import { ALAIN_I18N_TOKEN, IGNORE_BASE_URL, _HttpClient, CUSTOM_ERROR, RAW_BODY } from '@delon/theme';
|
|
14
14
|
import { environment } from '@env/environment';
|
|
15
15
|
import { NzNotificationService } from 'ng-zorro-antd/notification';
|
|
16
16
|
import { BehaviorSubject, Observable, of, throwError, catchError, filter, mergeMap, switchMap, take } from 'rxjs';
|
|
@@ -88,7 +88,7 @@ export class DefaultInterceptor implements HttpInterceptor {
|
|
|
88
88
|
// 1、若请求为刷新Token请求,表示来自刷新Token可以直接跳转登录页
|
|
89
89
|
if ([`/api/auth/refresh`].some(url => req.url.includes(url))) {
|
|
90
90
|
this.toLogin();
|
|
91
|
-
return throwError(ev);
|
|
91
|
+
return throwError(() => ev);
|
|
92
92
|
}
|
|
93
93
|
// 2、如果 `refreshToking` 为 `true` 表示已经在请求刷新 Token 中,后续所有请求转入等待状态,直至结果返回后再重新发起请求
|
|
94
94
|
if (this.refreshToking) {
|
|
@@ -115,7 +115,7 @@ export class DefaultInterceptor implements HttpInterceptor {
|
|
|
115
115
|
catchError(err => {
|
|
116
116
|
this.refreshToking = false;
|
|
117
117
|
this.toLogin();
|
|
118
|
-
return throwError(err);
|
|
118
|
+
return throwError(() => err);
|
|
119
119
|
})
|
|
120
120
|
);
|
|
121
121
|
}
|
|
@@ -152,15 +152,15 @@ export class DefaultInterceptor implements HttpInterceptor {
|
|
|
152
152
|
return this.refreshTokenRequest();
|
|
153
153
|
})
|
|
154
154
|
)
|
|
155
|
-
.subscribe(
|
|
156
|
-
res => {
|
|
155
|
+
.subscribe({
|
|
156
|
+
next: res => {
|
|
157
157
|
// TODO: Mock expired value
|
|
158
158
|
res.expired = +new Date() + 1000 * 60 * 5;
|
|
159
159
|
this.refreshToking = false;
|
|
160
160
|
this.tokenSrv.set(res);
|
|
161
161
|
},
|
|
162
|
-
() => this.toLogin()
|
|
163
|
-
);
|
|
162
|
+
error: () => this.toLogin()
|
|
163
|
+
});
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// #endregion
|
|
@@ -183,13 +183,14 @@ export class DefaultInterceptor implements HttpInterceptor {
|
|
|
183
183
|
// if (ev instanceof HttpResponse) {
|
|
184
184
|
// const body = ev.body;
|
|
185
185
|
// if (body && body.status !== 0) {
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
// //
|
|
189
|
-
//
|
|
186
|
+
// const customError = req.context.get(CUSTOM_ERROR);
|
|
187
|
+
// if (customError) this.injector.get(NzMessageService).error(body.msg);
|
|
188
|
+
// // 注意:这里如果继续抛出错误会被行258的 catchError 二次拦截,导致外部实现的 Pipe、subscribe 操作被中断,例如:this.http.get('/').subscribe() 不会触发
|
|
189
|
+
// // 如果你希望外部实现,需要手动移除行259
|
|
190
|
+
// return if (customError) throwError({}) : of({});
|
|
190
191
|
// } else {
|
|
191
|
-
// //
|
|
192
|
-
// if (ev.body instanceof Blob) {
|
|
192
|
+
// // 返回原始返回体
|
|
193
|
+
// if (req.context.get(RAW_BODY) || ev.body instanceof Blob) {
|
|
193
194
|
// return of(ev);
|
|
194
195
|
// }
|
|
195
196
|
// // 重新修改 `body` 内容为 `response` 内容,对于绝大多数场景已经无须再关心业务状态码
|
|
@@ -220,7 +221,7 @@ export class DefaultInterceptor implements HttpInterceptor {
|
|
|
220
221
|
break;
|
|
221
222
|
}
|
|
222
223
|
if (ev instanceof HttpErrorResponse) {
|
|
223
|
-
return throwError(ev);
|
|
224
|
+
return throwError(() => ev);
|
|
224
225
|
} else {
|
|
225
226
|
return of(ev);
|
|
226
227
|
}
|
|
@@ -239,7 +240,7 @@ export class DefaultInterceptor implements HttpInterceptor {
|
|
|
239
240
|
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
|
240
241
|
// 统一加上服务端前缀
|
|
241
242
|
let url = req.url;
|
|
242
|
-
if (!url.startsWith('https://') && !url.startsWith('http://')) {
|
|
243
|
+
if (!req.context.get(IGNORE_BASE_URL) && !url.startsWith('https://') && !url.startsWith('http://')) {
|
|
243
244
|
const { baseUrl } = environment.api;
|
|
244
245
|
url = baseUrl + (baseUrl.endsWith('/') && url.startsWith('/') ? url.substring(1) : url);
|
|
245
246
|
}
|
|
@@ -253,8 +254,8 @@ export class DefaultInterceptor implements HttpInterceptor {
|
|
|
253
254
|
}
|
|
254
255
|
// 若一切都正常,则后续操作
|
|
255
256
|
return of(ev);
|
|
256
|
-
})
|
|
257
|
-
catchError((err: HttpErrorResponse) => this.handleData(err, newReq, next))
|
|
257
|
+
})
|
|
258
|
+
// catchError((err: HttpErrorResponse) => this.handleData(err, newReq, next))
|
|
258
259
|
);
|
|
259
260
|
}
|
|
260
261
|
}
|
|
@@ -25,11 +25,11 @@ export class ExceptionTriggerComponent {
|
|
|
25
25
|
refresh(): void {
|
|
26
26
|
this.tokenService.set({ token: 'invalid-token' });
|
|
27
27
|
// 必须提供一个后端地址,无法通过 Mock 来模拟
|
|
28
|
-
this.http.post(`https://localhost:5001/auth`).subscribe(
|
|
29
|
-
res => console.warn('成功', res),
|
|
30
|
-
err => {
|
|
28
|
+
this.http.post(`https://localhost:5001/auth`).subscribe({
|
|
29
|
+
next: res => console.warn('成功', res),
|
|
30
|
+
error: err => {
|
|
31
31
|
console.log('最后结果失败', err);
|
|
32
32
|
}
|
|
33
|
-
);
|
|
33
|
+
});
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -36,7 +36,7 @@ function addEslintPluginDeprecation() {
|
|
|
36
36
|
}
|
|
37
37
|
tree.overwrite(path, content);
|
|
38
38
|
// add deprecation
|
|
39
|
-
(0, utils_1.addPackage)(tree, `eslint-plugin-prettier
|
|
39
|
+
(0, utils_1.addPackage)(tree, `eslint-plugin-prettier@~4.2.1`, 'devDependencies');
|
|
40
40
|
(0, utils_1.logStart)(context, `Add deprecation warn of eslint`);
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -37,7 +37,7 @@ function addEslintPluginDeprecation(): Rule {
|
|
|
37
37
|
|
|
38
38
|
tree.overwrite(path, content);
|
|
39
39
|
// add deprecation
|
|
40
|
-
addPackage(tree, `eslint-plugin-prettier
|
|
40
|
+
addPackage(tree, `eslint-plugin-prettier@~4.2.1`, 'devDependencies');
|
|
41
41
|
logStart(context, `Add deprecation warn of eslint`);
|
|
42
42
|
};
|
|
43
43
|
}
|
package/package.json
CHANGED
package/utils/lib-versions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZORROVERSION = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '^14.0.0
|
|
4
|
+
exports.VERSION = '^14.0.0';
|
|
5
5
|
exports.ZORROVERSION = '^14.0.0';
|
|
6
6
|
//# sourceMappingURL=lib-versions.js.map
|
package/utils/lib-versions.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '^14.0.0
|
|
1
|
+
export const VERSION = '^14.0.0';
|
|
2
2
|
export const ZORROVERSION = '^14.0.0';
|
package/utils/versions.js
CHANGED
|
@@ -29,11 +29,11 @@ function UpgradeMainVersions(tree, version = lib_versions_1.VERSION) {
|
|
|
29
29
|
`@typescript-eslint/eslint-plugin@~5.35.1`,
|
|
30
30
|
`@typescript-eslint/parser@~5.35.1`,
|
|
31
31
|
`eslint@^8.23.0`,
|
|
32
|
-
`eslint-config-prettier
|
|
32
|
+
`eslint-config-prettier@~8.5.0`,
|
|
33
33
|
`eslint-plugin-import@~2.26.0`,
|
|
34
34
|
`eslint-plugin-jsdoc@~39.3.6`,
|
|
35
35
|
`eslint-plugin-prefer-arrow@~1.2.3`,
|
|
36
|
-
`eslint-plugin-prettier
|
|
36
|
+
`eslint-plugin-prettier@~4.2.1`,
|
|
37
37
|
`eslint-plugin-deprecation@~1.3.2`,
|
|
38
38
|
`prettier@^2.7.1`,
|
|
39
39
|
`husky@^7.0.4`,
|
|
@@ -41,10 +41,9 @@ function UpgradeMainVersions(tree, version = lib_versions_1.VERSION) {
|
|
|
41
41
|
`ng-alain-plugin-theme@^13.0.3`,
|
|
42
42
|
`source-map-explorer@^2.5.2`,
|
|
43
43
|
`@angular/language-service@^14.2.0`,
|
|
44
|
-
`rxjs@~7.5.0`,
|
|
45
44
|
`@delon/testing@${version}`
|
|
46
45
|
], 'devDependencies');
|
|
47
|
-
(0, package_1.addPackage)(tree, [`ng-zorro-antd@^14.0.0`]);
|
|
46
|
+
(0, package_1.addPackage)(tree, [`rxjs@~7.5.0`, `ng-zorro-antd@^14.0.0`]);
|
|
48
47
|
}
|
|
49
48
|
exports.UpgradeMainVersions = UpgradeMainVersions;
|
|
50
49
|
function addESLintRule(context, showLog = true) {
|
package/utils/versions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../schematics/utils/versions.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qEAAwE;AAExE,iDAAyC;AACzC,+BAAgC;AAChC,uCAAuC;AACvC,2CAAgD;AAEhD;;GAEG;AACH,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D;QACxD,iDAAiD;QACjD,8BAA8B;QAC9B,8CAA8C;QAC9C,4CAA4C;QAC5C,2CAA2C;QAC3C,kDAAkD;QAClD,8CAA8C;QAC9C,iDAAiD;QACjD,gCAAgC;QAChC,6BAA6B;QAC7B,YAAY,OAAO,EAAE;QACrB,6CAA6C;QAC7C,2CAA2C;QAC3C,iDAAiD;QACjD,kBAAkB,OAAO,EAAE;KAC5B,EACD,iBAAiB,CAClB,CAAC;IACF,IAAA,oBAAU,EAAC,IAAI,EAAE,CAAC,4BAA4B,EAAE,qCAAqC,CAAC,CAAC,CAAC;AAC1F,CAAC;AAjCD,kDAiCC;AAED,SAAgB,aAAa,CAAC,OAAyB,EAAE,UAAmB,IAAI;IAC9E,OAAO,IAAA,2BAAe,EAAC,CAAM,SAAS,EAAC,EAAE;QACvC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACnC,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,6BAAiB,CAAC,EAAE;gBAC1C,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,6BAAiB,CAAC,CAAC;aAC3C;YACD,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,6BAAiB,EAAE;gBACrC,OAAO,EAAE,8BAA8B;gBACvC,OAAO,EAAE;oBACP,gBAAgB,EAAE,CAAC,aAAa,EAAE,eAAe,CAAC;iBACnD;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,IAAI,OAAO,EAAE;YACX,IAAA,aAAO,EAAC,OAAO,EAAE,oCAAoC,CAAC,CAAC;SACxD;IACH,CAAC,CAAA,CAAC,CAAC;AACL,CAAC;AAjBD,sCAiBC"}
|
package/utils/versions.ts
CHANGED
|
@@ -25,11 +25,11 @@ export function UpgradeMainVersions(tree: Tree, version: string = VERSION): void
|
|
|
25
25
|
`@typescript-eslint/eslint-plugin@~5.35.1`,
|
|
26
26
|
`@typescript-eslint/parser@~5.35.1`,
|
|
27
27
|
`eslint@^8.23.0`,
|
|
28
|
-
`eslint-config-prettier
|
|
28
|
+
`eslint-config-prettier@~8.5.0`,
|
|
29
29
|
`eslint-plugin-import@~2.26.0`,
|
|
30
30
|
`eslint-plugin-jsdoc@~39.3.6`,
|
|
31
31
|
`eslint-plugin-prefer-arrow@~1.2.3`,
|
|
32
|
-
`eslint-plugin-prettier
|
|
32
|
+
`eslint-plugin-prettier@~4.2.1`,
|
|
33
33
|
`eslint-plugin-deprecation@~1.3.2`,
|
|
34
34
|
`prettier@^2.7.1`,
|
|
35
35
|
`husky@^7.0.4`,
|
|
@@ -37,12 +37,11 @@ export function UpgradeMainVersions(tree: Tree, version: string = VERSION): void
|
|
|
37
37
|
`ng-alain-plugin-theme@^13.0.3`,
|
|
38
38
|
`source-map-explorer@^2.5.2`,
|
|
39
39
|
`@angular/language-service@^14.2.0`,
|
|
40
|
-
`rxjs@~7.5.0`,
|
|
41
40
|
`@delon/testing@${version}`
|
|
42
41
|
],
|
|
43
42
|
'devDependencies'
|
|
44
43
|
);
|
|
45
|
-
addPackage(tree, [`ng-zorro-antd@^14.0.0`]);
|
|
44
|
+
addPackage(tree, [`rxjs@~7.5.0`, `ng-zorro-antd@^14.0.0`]);
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
export function addESLintRule(context: SchematicContext, showLog: Boolean = true): Rule {
|