@dqv5/ng-alain-soccer 0.0.1
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/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# NgAlainSoccer
|
|
2
|
+
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.2.0.
|
|
4
|
+
|
|
5
|
+
## Code scaffolding
|
|
6
|
+
|
|
7
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ng generate component component-name
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
ng generate --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Building
|
|
20
|
+
|
|
21
|
+
To build the library, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
ng build ng-alain-soccer
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
28
|
+
|
|
29
|
+
### Publishing the Library
|
|
30
|
+
|
|
31
|
+
Once the project is built, you can publish your library by following these steps:
|
|
32
|
+
|
|
33
|
+
1. Navigate to the `dist` directory:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cd dist/ng-alain-soccer
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. Run the `npm publish` command to publish your library to the npm registry:
|
|
40
|
+
```bash
|
|
41
|
+
npm publish
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Running unit tests
|
|
45
|
+
|
|
46
|
+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
ng test
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Running end-to-end tests
|
|
53
|
+
|
|
54
|
+
For end-to-end (e2e) testing, run:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
ng e2e
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
61
|
+
|
|
62
|
+
## Additional Resources
|
|
63
|
+
|
|
64
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { HttpErrorResponse, HttpResponseBase, HttpClient } from '@angular/common/http';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, Injector, provideAppInitializer, Injectable } from '@angular/core';
|
|
4
|
+
import { ALAIN_I18N_TOKEN, IGNORE_BASE_URL, MenuService, SettingsService, TitleService } from '@delon/theme';
|
|
5
|
+
import { throwError, of, mergeMap, catchError, map } from 'rxjs';
|
|
6
|
+
import { Router } from '@angular/router';
|
|
7
|
+
import { DA_SERVICE_TOKEN } from '@delon/auth';
|
|
8
|
+
import { NzNotificationService } from 'ng-zorro-antd/notification';
|
|
9
|
+
import { ACLService } from '@delon/acl';
|
|
10
|
+
|
|
11
|
+
const CODEMESSAGE = {
|
|
12
|
+
200: '服务器成功返回请求的数据。',
|
|
13
|
+
201: '新建或修改数据成功。',
|
|
14
|
+
202: '一个请求已经进入后台排队(异步任务)。',
|
|
15
|
+
204: '删除数据成功。',
|
|
16
|
+
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
|
|
17
|
+
401: '用户没有权限(令牌、用户名、密码错误)。',
|
|
18
|
+
403: '用户得到授权,但是访问是被禁止的。',
|
|
19
|
+
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
|
|
20
|
+
406: '请求的格式不可得。',
|
|
21
|
+
410: '请求的资源被永久删除,且不会再得到的。',
|
|
22
|
+
422: '当创建一个对象时,发生一个验证错误。',
|
|
23
|
+
500: '服务器发生错误,请检查服务器。',
|
|
24
|
+
502: '网关错误。',
|
|
25
|
+
503: '服务不可用,服务器暂时过载或维护。',
|
|
26
|
+
504: '网关超时。',
|
|
27
|
+
};
|
|
28
|
+
function goTo(injector, url) {
|
|
29
|
+
setTimeout(() => injector.get(Router).navigateByUrl(url));
|
|
30
|
+
}
|
|
31
|
+
function toLogin(injector) {
|
|
32
|
+
injector.get(NzNotificationService).error(`未登录或登录已过期,请重新登录。`, ``);
|
|
33
|
+
goTo(injector, injector.get(DA_SERVICE_TOKEN).login_url);
|
|
34
|
+
}
|
|
35
|
+
function getAdditionalHeaders(headers) {
|
|
36
|
+
const res = {};
|
|
37
|
+
const lang = inject(ALAIN_I18N_TOKEN).currentLang;
|
|
38
|
+
if (!headers?.has('Accept-Language') && lang) {
|
|
39
|
+
res['Accept-Language'] = lang;
|
|
40
|
+
}
|
|
41
|
+
return res;
|
|
42
|
+
}
|
|
43
|
+
function checkStatus(injector, ev) {
|
|
44
|
+
if ((ev.status >= 200 && ev.status < 300) || ev.status === 401) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const errortext = CODEMESSAGE[ev.status] || ev.status.toString();
|
|
48
|
+
injector.get(NzNotificationService).error(`请求错误 ${ev.status}: ${ev.url}`, errortext);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function handleData(injector, ev, req, next) {
|
|
52
|
+
console.log(req);
|
|
53
|
+
console.log(next);
|
|
54
|
+
checkStatus(injector, ev);
|
|
55
|
+
// 业务处理:一些通用操作
|
|
56
|
+
switch (ev.status) {
|
|
57
|
+
case 200:
|
|
58
|
+
// 业务层级错误处理,以下是假定restful有一套统一输出格式(指不管成功与否都有相应的数据格式)情况下进行处理
|
|
59
|
+
// 例如响应内容:
|
|
60
|
+
// 错误内容:{ status: 1, msg: '非法参数' }
|
|
61
|
+
// 正确内容:{ status: 0, response: { } }
|
|
62
|
+
// 则以下代码片断可直接适用
|
|
63
|
+
// if (ev instanceof HttpResponse) {
|
|
64
|
+
// const body = ev.body;
|
|
65
|
+
// if (body && body.status !== 0) {
|
|
66
|
+
// const customError = req.context.get(CUSTOM_ERROR);
|
|
67
|
+
// if (customError) injector.get(NzMessageService).error(body.msg);
|
|
68
|
+
// return customError ? throwError(() => ({ body, _throw: true }) as ReThrowHttpError) : of({});
|
|
69
|
+
// } else {
|
|
70
|
+
// // 返回原始返回体
|
|
71
|
+
// if (req.context.get(RAW_BODY) || ev.body instanceof Blob) {
|
|
72
|
+
// return of(ev);
|
|
73
|
+
// }
|
|
74
|
+
// // 重新修改 `body` 内容为 `response` 内容,对于绝大多数场景已经无须再关心业务状态码
|
|
75
|
+
// return of(new HttpResponse({ ...ev, body: body.response } as any));
|
|
76
|
+
// // 或者依然保持完整的格式
|
|
77
|
+
// return of(ev);
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
break;
|
|
81
|
+
case 401:
|
|
82
|
+
// if (
|
|
83
|
+
// environment.api.refreshTokenEnabled &&
|
|
84
|
+
// environment.api.refreshTokenType === 're-request'
|
|
85
|
+
// ) {
|
|
86
|
+
// return tryRefreshToken(injector, ev, req, next);
|
|
87
|
+
// }
|
|
88
|
+
toLogin(injector);
|
|
89
|
+
break;
|
|
90
|
+
case 403:
|
|
91
|
+
case 404:
|
|
92
|
+
case 500:
|
|
93
|
+
// goTo(injector, `/exception/${ev.status}?url=${req.urlWithParams}`);
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
if (ev instanceof HttpErrorResponse) {
|
|
97
|
+
console.warn('未可知错误,大部分是由于后端不支持跨域CORS或无效配置引起,请参考 https://ng-alain.com/docs/server 解决跨域问题', ev);
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
if (ev instanceof HttpErrorResponse) {
|
|
102
|
+
return throwError(() => ev);
|
|
103
|
+
}
|
|
104
|
+
else if (ev._throw === true) {
|
|
105
|
+
return throwError(() => ev.body);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
return of(ev);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const defaultInterceptor = (req, next) => {
|
|
112
|
+
// 统一加上服务端前缀
|
|
113
|
+
let url = req.url;
|
|
114
|
+
if (!req.context.get(IGNORE_BASE_URL) &&
|
|
115
|
+
!url.startsWith('https://') &&
|
|
116
|
+
!url.startsWith('http://')) {
|
|
117
|
+
// const { baseUrl } = environment.api;
|
|
118
|
+
// url = baseUrl + (baseUrl.endsWith('/') && url.startsWith('/') ? url.substring(1) : url);
|
|
119
|
+
}
|
|
120
|
+
const newReq = req.clone({ url, setHeaders: getAdditionalHeaders(req.headers) });
|
|
121
|
+
const injector = inject(Injector);
|
|
122
|
+
return next(newReq).pipe(mergeMap((ev) => {
|
|
123
|
+
// 允许统一对请求错误处理
|
|
124
|
+
if (ev instanceof HttpResponseBase) {
|
|
125
|
+
return handleData(injector, ev, newReq, next);
|
|
126
|
+
}
|
|
127
|
+
// 若一切都正常,则后续操作
|
|
128
|
+
return of(ev);
|
|
129
|
+
}));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Used for application startup
|
|
134
|
+
* Generally used to get the basic data of the application, like: Menu Data, User Data, etc.
|
|
135
|
+
*/
|
|
136
|
+
function provideStartup() {
|
|
137
|
+
return [
|
|
138
|
+
StartupService,
|
|
139
|
+
provideAppInitializer(() => {
|
|
140
|
+
const initializerFn = ((startupService) => () => startupService.load())(inject(StartupService));
|
|
141
|
+
return initializerFn();
|
|
142
|
+
}),
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
class StartupService {
|
|
146
|
+
menuService = inject(MenuService);
|
|
147
|
+
settingService = inject(SettingsService);
|
|
148
|
+
// private tokenService = inject(DA_SERVICE_TOKEN);
|
|
149
|
+
aclService = inject(ACLService);
|
|
150
|
+
titleService = inject(TitleService);
|
|
151
|
+
httpClient = inject(HttpClient);
|
|
152
|
+
router = inject(Router);
|
|
153
|
+
// If http request allows anonymous access, you need to add `ALLOW_ANONYMOUS`:
|
|
154
|
+
// this.httpClient.get('/app', { context: new HttpContext().set(ALLOW_ANONYMOUS, true) })
|
|
155
|
+
appData$ = this.httpClient.get('./assets/tmp/app-data.json').pipe(catchError((res) => {
|
|
156
|
+
console.warn(`StartupService.load: Network request failed`, res);
|
|
157
|
+
setTimeout(() => this.router.navigateByUrl(`/exception/500`));
|
|
158
|
+
return of({});
|
|
159
|
+
}));
|
|
160
|
+
load() {
|
|
161
|
+
// http
|
|
162
|
+
// return this.viaHttp();
|
|
163
|
+
// mock: Don’t use it in a production environment. ViaMock is just to simulate some data to make the scaffolding work normally
|
|
164
|
+
// mock:请勿在生产环境中这么使用,viaMock 单纯只是为了模拟一些数据使脚手架一开始能正常运行
|
|
165
|
+
return this.viaMock();
|
|
166
|
+
}
|
|
167
|
+
handleAppData(res) {
|
|
168
|
+
// Application information: including site name, description, year
|
|
169
|
+
this.settingService.setApp(res.app);
|
|
170
|
+
// User information: including name, avatar, email address
|
|
171
|
+
this.settingService.setUser(res.user);
|
|
172
|
+
// ACL: Set the permissions to full, https://ng-alain.com/acl/getting-started
|
|
173
|
+
this.aclService.setFull(true);
|
|
174
|
+
// Menu data, https://ng-alain.com/theme/menu
|
|
175
|
+
this.menuService.add(res.menu ?? []);
|
|
176
|
+
// Can be set page suffix title, https://ng-alain.com/theme/title
|
|
177
|
+
this.titleService.suffix = res.app?.name;
|
|
178
|
+
}
|
|
179
|
+
// @ts-ignore
|
|
180
|
+
viaHttp() {
|
|
181
|
+
return this.appData$.pipe(map((res) => this.handleAppData(res)));
|
|
182
|
+
}
|
|
183
|
+
viaMock() {
|
|
184
|
+
// const tokenData = this.tokenService.get();
|
|
185
|
+
// if (!tokenData.token) {
|
|
186
|
+
// this.router.navigateByUrl(this.tokenService.login_url!);
|
|
187
|
+
// return;
|
|
188
|
+
// }
|
|
189
|
+
// mock
|
|
190
|
+
const app = {
|
|
191
|
+
name: `NG-ALAIN`,
|
|
192
|
+
description: `NG-ZORRO admin panel front-end framework`,
|
|
193
|
+
};
|
|
194
|
+
const user = {
|
|
195
|
+
name: 'Admin',
|
|
196
|
+
avatar: './assets/tmp/img/avatar.jpg',
|
|
197
|
+
email: 'cipchk@qq.com',
|
|
198
|
+
token: '123456789',
|
|
199
|
+
};
|
|
200
|
+
// Application information: including site name, description, year
|
|
201
|
+
this.settingService.setApp(app);
|
|
202
|
+
// User information: including name, avatar, email address
|
|
203
|
+
this.settingService.setUser(user);
|
|
204
|
+
// ACL: Set the permissions to full, https://ng-alain.com/acl/getting-started
|
|
205
|
+
this.aclService.setFull(true);
|
|
206
|
+
// Menu data, https://ng-alain.com/theme/menu
|
|
207
|
+
this.menuService.add([
|
|
208
|
+
{
|
|
209
|
+
text: 'Main',
|
|
210
|
+
group: true,
|
|
211
|
+
children: [
|
|
212
|
+
{
|
|
213
|
+
text: 'Dashboard',
|
|
214
|
+
link: '/dashboard',
|
|
215
|
+
icon: { type: 'icon', value: 'appstore' },
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
]);
|
|
220
|
+
// Can be set page suffix title, https://ng-alain.com/theme/title
|
|
221
|
+
this.titleService.suffix = app.name;
|
|
222
|
+
return of(void 0);
|
|
223
|
+
}
|
|
224
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StartupService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
225
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StartupService });
|
|
226
|
+
}
|
|
227
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: StartupService, decorators: [{
|
|
228
|
+
type: Injectable
|
|
229
|
+
}] });
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Dynamically load the start page
|
|
233
|
+
*
|
|
234
|
+
* 动态加载启动页
|
|
235
|
+
*/
|
|
236
|
+
const startPageGuard = () => {
|
|
237
|
+
// Re-jump according to the first item of the menu, you can re-customize the logic
|
|
238
|
+
// 以下代码是根据菜单的第一项进行重新跳转,你可以重新定制逻辑
|
|
239
|
+
// const menuSrv = inject(MenuService);
|
|
240
|
+
// if (menuSrv.find({ url: state.url }) == null) {
|
|
241
|
+
// inject(Router).navigateByUrl(menuSrv.menus[0].link!);
|
|
242
|
+
// return false;
|
|
243
|
+
// }
|
|
244
|
+
return true;
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/*
|
|
248
|
+
* Public API Surface of ng-alain-soccer
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Generated bundle index. Do not edit.
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
export { StartupService, defaultInterceptor, provideStartup, startPageGuard };
|
|
256
|
+
//# sourceMappingURL=dqv5-ng-alain-soccer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dqv5-ng-alain-soccer.mjs","sources":["../../../packages/ng-alain-soccer/core/net/helper.ts","../../../packages/ng-alain-soccer/core/net/default.interceptor.ts","../../../packages/ng-alain-soccer/core/startup/startup.service.ts","../../../packages/ng-alain-soccer/core/start-page.guard.ts","../../../packages/ng-alain-soccer/public-api.ts","../../../packages/ng-alain-soccer/dqv5-ng-alain-soccer.ts"],"sourcesContent":["import { HttpHeaders, HttpResponseBase } from '@angular/common/http';\nimport { Injector, inject } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { DA_SERVICE_TOKEN } from '@delon/auth';\nimport { ALAIN_I18N_TOKEN } from '@delon/theme';\nimport { NzNotificationService } from 'ng-zorro-antd/notification';\n\nexport interface ReThrowHttpError {\n body: unknown;\n _throw: true;\n}\n\nexport const CODEMESSAGE: Record<number, string> = {\n 200: '服务器成功返回请求的数据。',\n 201: '新建或修改数据成功。',\n 202: '一个请求已经进入后台排队(异步任务)。',\n 204: '删除数据成功。',\n 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',\n 401: '用户没有权限(令牌、用户名、密码错误)。',\n 403: '用户得到授权,但是访问是被禁止的。',\n 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',\n 406: '请求的格式不可得。',\n 410: '请求的资源被永久删除,且不会再得到的。',\n 422: '当创建一个对象时,发生一个验证错误。',\n 500: '服务器发生错误,请检查服务器。',\n 502: '网关错误。',\n 503: '服务不可用,服务器暂时过载或维护。',\n 504: '网关超时。',\n};\n\nexport function goTo(injector: Injector, url: string): void {\n setTimeout(() => injector.get(Router).navigateByUrl(url));\n}\n\nexport function toLogin(injector: Injector): void {\n injector.get(NzNotificationService).error(`未登录或登录已过期,请重新登录。`, ``);\n goTo(injector, injector.get(DA_SERVICE_TOKEN).login_url!);\n}\n\nexport function getAdditionalHeaders(headers?: HttpHeaders): Record<string, string> {\n const res: Record<string, string> = {};\n const lang = inject(ALAIN_I18N_TOKEN).currentLang;\n if (!headers?.has('Accept-Language') && lang) {\n res['Accept-Language'] = lang;\n }\n\n return res;\n}\n\nexport function checkStatus(injector: Injector, ev: HttpResponseBase): void {\n if ((ev.status >= 200 && ev.status < 300) || ev.status === 401) {\n return;\n }\n\n const errortext = CODEMESSAGE[ev.status] || ev.status.toString();\n injector.get(NzNotificationService).error(`请求错误 ${ev.status}: ${ev.url}`, errortext);\n}\n","import {\n HttpErrorResponse,\n HttpHandlerFn,\n HttpInterceptorFn,\n HttpRequest,\n HttpResponseBase,\n} from '@angular/common/http';\nimport { Injector, inject } from '@angular/core';\nimport { IGNORE_BASE_URL } from '@delon/theme';\n// import { environment } from '@env/environment';\nimport { Observable, of, throwError, mergeMap } from 'rxjs';\n\nimport { ReThrowHttpError, checkStatus, getAdditionalHeaders, toLogin } from './helper';\nimport { tryRefreshToken } from './refresh-token';\n\nfunction handleData(\n injector: Injector,\n ev: HttpResponseBase,\n req: HttpRequest<any>,\n next: HttpHandlerFn,\n): Observable<any> {\n console.log(req)\n console.log(next)\n checkStatus(injector, ev);\n // 业务处理:一些通用操作\n switch (ev.status) {\n case 200:\n // 业务层级错误处理,以下是假定restful有一套统一输出格式(指不管成功与否都有相应的数据格式)情况下进行处理\n // 例如响应内容:\n // 错误内容:{ status: 1, msg: '非法参数' }\n // 正确内容:{ status: 0, response: { } }\n // 则以下代码片断可直接适用\n // if (ev instanceof HttpResponse) {\n // const body = ev.body;\n // if (body && body.status !== 0) {\n // const customError = req.context.get(CUSTOM_ERROR);\n // if (customError) injector.get(NzMessageService).error(body.msg);\n // return customError ? throwError(() => ({ body, _throw: true }) as ReThrowHttpError) : of({});\n // } else {\n // // 返回原始返回体\n // if (req.context.get(RAW_BODY) || ev.body instanceof Blob) {\n // return of(ev);\n // }\n // // 重新修改 `body` 内容为 `response` 内容,对于绝大多数场景已经无须再关心业务状态码\n // return of(new HttpResponse({ ...ev, body: body.response } as any));\n // // 或者依然保持完整的格式\n // return of(ev);\n // }\n // }\n break;\n case 401:\n // if (\n // environment.api.refreshTokenEnabled &&\n // environment.api.refreshTokenType === 're-request'\n // ) {\n // return tryRefreshToken(injector, ev, req, next);\n // }\n toLogin(injector);\n break;\n case 403:\n case 404:\n case 500:\n // goTo(injector, `/exception/${ev.status}?url=${req.urlWithParams}`);\n break;\n default:\n if (ev instanceof HttpErrorResponse) {\n console.warn(\n '未可知错误,大部分是由于后端不支持跨域CORS或无效配置引起,请参考 https://ng-alain.com/docs/server 解决跨域问题',\n ev,\n );\n }\n break;\n }\n if (ev instanceof HttpErrorResponse) {\n return throwError(() => ev);\n } else if ((ev as unknown as ReThrowHttpError)._throw === true) {\n return throwError(() => (ev as unknown as ReThrowHttpError).body);\n } else {\n return of(ev);\n }\n}\n\nexport const defaultInterceptor: HttpInterceptorFn = (req, next) => {\n // 统一加上服务端前缀\n let url = req.url;\n if (\n !req.context.get(IGNORE_BASE_URL) &&\n !url.startsWith('https://') &&\n !url.startsWith('http://')\n ) {\n // const { baseUrl } = environment.api;\n // url = baseUrl + (baseUrl.endsWith('/') && url.startsWith('/') ? url.substring(1) : url);\n }\n const newReq = req.clone({ url, setHeaders: getAdditionalHeaders(req.headers) });\n const injector = inject(Injector);\n\n return next(newReq).pipe(\n mergeMap((ev) => {\n // 允许统一对请求错误处理\n if (ev instanceof HttpResponseBase) {\n return handleData(injector, ev, newReq, next);\n }\n // 若一切都正常,则后续操作\n return of(ev);\n }),\n // catchError((err: HttpErrorResponse) => handleData(injector, err, newReq, next))\n );\n};\n","import {\n EnvironmentProviders,\n Injectable,\n Provider,\n inject,\n provideAppInitializer,\n} from '@angular/core';\nimport { Router } from '@angular/router';\nimport { HttpClient } from '@angular/common/http';\nimport { MenuService, SettingsService, TitleService } from '@delon/theme';\nimport { ACLService } from '@delon/acl';\nimport { Observable, of, catchError, map } from 'rxjs';\nimport type { NzSafeAny } from 'ng-zorro-antd/core/types';\n\n/**\n * Used for application startup\n * Generally used to get the basic data of the application, like: Menu Data, User Data, etc.\n */\nexport function provideStartup(): Array<Provider | EnvironmentProviders> {\n return [\n StartupService,\n provideAppInitializer(() => {\n const initializerFn = (\n (startupService: StartupService) => () =>\n startupService.load()\n )(inject(StartupService));\n return initializerFn();\n }),\n ];\n}\n\n@Injectable()\nexport class StartupService {\n private menuService = inject(MenuService);\n private settingService = inject(SettingsService);\n // private tokenService = inject(DA_SERVICE_TOKEN);\n private aclService = inject(ACLService);\n private titleService = inject(TitleService);\n private httpClient = inject(HttpClient);\n private router = inject(Router);\n // If http request allows anonymous access, you need to add `ALLOW_ANONYMOUS`:\n // this.httpClient.get('/app', { context: new HttpContext().set(ALLOW_ANONYMOUS, true) })\n private appData$ = this.httpClient.get('./assets/tmp/app-data.json').pipe(\n catchError((res: NzSafeAny) => {\n console.warn(`StartupService.load: Network request failed`, res);\n setTimeout(() => this.router.navigateByUrl(`/exception/500`));\n return of({});\n }),\n );\n\n load(): Observable<void> {\n // http\n // return this.viaHttp();\n // mock: Don’t use it in a production environment. ViaMock is just to simulate some data to make the scaffolding work normally\n // mock:请勿在生产环境中这么使用,viaMock 单纯只是为了模拟一些数据使脚手架一开始能正常运行\n return this.viaMock();\n }\n\n private handleAppData(res: NzSafeAny): void {\n // Application information: including site name, description, year\n this.settingService.setApp(res.app);\n // User information: including name, avatar, email address\n this.settingService.setUser(res.user);\n // ACL: Set the permissions to full, https://ng-alain.com/acl/getting-started\n this.aclService.setFull(true);\n // Menu data, https://ng-alain.com/theme/menu\n this.menuService.add(res.menu ?? []);\n // Can be set page suffix title, https://ng-alain.com/theme/title\n this.titleService.suffix = res.app?.name;\n }\n\n // @ts-ignore\n private viaHttp(): Observable<void> {\n return this.appData$.pipe(map((res: NzSafeAny) => this.handleAppData(res)));\n }\n\n private viaMock(): Observable<void> {\n // const tokenData = this.tokenService.get();\n // if (!tokenData.token) {\n // this.router.navigateByUrl(this.tokenService.login_url!);\n // return;\n // }\n // mock\n const app: any = {\n name: `NG-ALAIN`,\n description: `NG-ZORRO admin panel front-end framework`,\n };\n const user: any = {\n name: 'Admin',\n avatar: './assets/tmp/img/avatar.jpg',\n email: 'cipchk@qq.com',\n token: '123456789',\n };\n // Application information: including site name, description, year\n this.settingService.setApp(app);\n // User information: including name, avatar, email address\n this.settingService.setUser(user);\n // ACL: Set the permissions to full, https://ng-alain.com/acl/getting-started\n this.aclService.setFull(true);\n // Menu data, https://ng-alain.com/theme/menu\n this.menuService.add([\n {\n text: 'Main',\n group: true,\n children: [\n {\n text: 'Dashboard',\n link: '/dashboard',\n icon: { type: 'icon', value: 'appstore' },\n },\n ],\n },\n ]);\n // Can be set page suffix title, https://ng-alain.com/theme/title\n this.titleService.suffix = app.name;\n\n return of(void 0);\n }\n}\n","import { CanActivateFn } from '@angular/router';\nimport { Observable } from 'rxjs';\n\n/**\n * Dynamically load the start page\n *\n * 动态加载启动页\n */\nexport const startPageGuard: CanActivateFn = (): boolean | Observable<boolean> => {\n // Re-jump according to the first item of the menu, you can re-customize the logic\n // 以下代码是根据菜单的第一项进行重新跳转,你可以重新定制逻辑\n // const menuSrv = inject(MenuService);\n // if (menuSrv.find({ url: state.url }) == null) {\n // inject(Router).navigateByUrl(menuSrv.menus[0].link!);\n // return false;\n // }\n return true;\n};\n","/*\n * Public API Surface of ng-alain-soccer\n */\n\nexport * from './core';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;AAYO,MAAM,WAAW,GAA2B;AACjD,IAAA,GAAG,EAAE,eAAe;AACpB,IAAA,GAAG,EAAE,YAAY;AACjB,IAAA,GAAG,EAAE,qBAAqB;AAC1B,IAAA,GAAG,EAAE,SAAS;AACd,IAAA,GAAG,EAAE,6BAA6B;AAClC,IAAA,GAAG,EAAE,sBAAsB;AAC3B,IAAA,GAAG,EAAE,mBAAmB;AACxB,IAAA,GAAG,EAAE,4BAA4B;AACjC,IAAA,GAAG,EAAE,WAAW;AAChB,IAAA,GAAG,EAAE,qBAAqB;AAC1B,IAAA,GAAG,EAAE,oBAAoB;AACzB,IAAA,GAAG,EAAE,iBAAiB;AACtB,IAAA,GAAG,EAAE,OAAO;AACZ,IAAA,GAAG,EAAE,mBAAmB;AACxB,IAAA,GAAG,EAAE,OAAO;CACb;AAEK,SAAU,IAAI,CAAC,QAAkB,EAAE,GAAW,EAAA;AAClD,IAAA,UAAU,CAAC,MAAM,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;AAC3D;AAEM,SAAU,OAAO,CAAC,QAAkB,EAAA;AACxC,IAAA,QAAQ,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,KAAK,CAAC,CAAA,gBAAA,CAAkB,EAAE,CAAA,CAAE,CAAC;AACjE,IAAA,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,SAAU,CAAC;AAC3D;AAEM,SAAU,oBAAoB,CAAC,OAAqB,EAAA;IACxD,MAAM,GAAG,GAA2B,EAAE;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC,WAAW;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A;kBAD1B;;;AC5BD;;;;AAIG;AACI,MAAM,cAAc,GAAkB,MAAoC;;;;;;;;AAQ/E,IAAA,OAAO,IAAI;AACb;;ACjBA;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dqv5/ng-alain-soccer",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"peerDependencies": {
|
|
5
|
+
"@angular/common": "^21.2.0",
|
|
6
|
+
"@angular/core": "^21.2.0"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"tslib": "^2.3.0",
|
|
13
|
+
"ng-zorro-antd": "@LIB-PLACEHOLDER",
|
|
14
|
+
"@delon/acl": "@LIB-PLACEHOLDER",
|
|
15
|
+
"@delon/abc": "@LIB-PLACEHOLDER",
|
|
16
|
+
"@delon/auth": "@LIB-PLACEHOLDER",
|
|
17
|
+
"@delon/theme": "@LIB-PLACEHOLDER",
|
|
18
|
+
"@delon/mock": "@LIB-PLACEHOLDER",
|
|
19
|
+
"@delon/cache": "@LIB-PLACEHOLDER",
|
|
20
|
+
"@delon/chart": "@LIB-PLACEHOLDER",
|
|
21
|
+
"@delon/form": "@LIB-PLACEHOLDER",
|
|
22
|
+
"@delon/testing": "@LIB-PLACEHOLDER",
|
|
23
|
+
"@delon/util": "@LIB-PLACEHOLDER"
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"module": "fesm2022/dqv5-ng-alain-soccer.mjs",
|
|
27
|
+
"typings": "types/dqv5-ng-alain-soccer.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
"./package.json": {
|
|
30
|
+
"default": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./types/dqv5-ng-alain-soccer.d.ts",
|
|
34
|
+
"default": "./fesm2022/dqv5-ng-alain-soccer.mjs"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"type": "module"
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { HttpInterceptorFn } from '@angular/common/http';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { Provider, EnvironmentProviders } from '@angular/core';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { CanActivateFn } from '@angular/router';
|
|
6
|
+
|
|
7
|
+
declare const defaultInterceptor: HttpInterceptorFn;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Used for application startup
|
|
11
|
+
* Generally used to get the basic data of the application, like: Menu Data, User Data, etc.
|
|
12
|
+
*/
|
|
13
|
+
declare function provideStartup(): Array<Provider | EnvironmentProviders>;
|
|
14
|
+
declare class StartupService {
|
|
15
|
+
private menuService;
|
|
16
|
+
private settingService;
|
|
17
|
+
private aclService;
|
|
18
|
+
private titleService;
|
|
19
|
+
private httpClient;
|
|
20
|
+
private router;
|
|
21
|
+
private appData$;
|
|
22
|
+
load(): Observable<void>;
|
|
23
|
+
private handleAppData;
|
|
24
|
+
private viaHttp;
|
|
25
|
+
private viaMock;
|
|
26
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<StartupService, never>;
|
|
27
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<StartupService>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Dynamically load the start page
|
|
32
|
+
*
|
|
33
|
+
* 动态加载启动页
|
|
34
|
+
*/
|
|
35
|
+
declare const startPageGuard: CanActivateFn;
|
|
36
|
+
|
|
37
|
+
export { StartupService, defaultInterceptor, provideStartup, startPageGuard };
|