Skip to content

Commit

Permalink
update angular 17 create http request
Browse files Browse the repository at this point in the history
  • Loading branch information
vnobo committed Feb 27, 2024
1 parent 18cbd8d commit 07b6f28
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ui/projects/web/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {AsyncPipe, CommonModule} from '@angular/common';
import {RouterOutlet} from '@angular/router';
import {NzBackTopModule} from "ng-zorro-antd/back-top";
Expand All @@ -13,7 +13,7 @@ import {LoadingService} from "./core/loading.service";
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
export class AppComponent implements OnInit {
loadingShow$: Observable<boolean> | undefined;

constructor(private loading: LoadingService) {
Expand Down
5 changes: 3 additions & 2 deletions ui/projects/web/src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ export function defaultInterceptor(req: HttpRequest<unknown>, next: HttpHandlerF
headers: req.headers.append('X-Requested-With', 'XMLHttpRequest'),
url: originalUrl
});
return next(xRequestedReq).pipe(timeout({first: 50_000, each: 100_000}),
return next(xRequestedReq).pipe(timeout({first: 5_000, each: 10_000}),
catchError(errorResponse => {
if (errorResponse.error.message) {
_message.error(errorResponse.error.message);
return throwError(() => errorResponse.error.message);
}
console.error($localize`:@@errorMessage:Backend returned code ${errorResponse.status}, body was: `, errorResponse.error);
console.error($localize`:@@errorMessage:Backend returned code ${errorResponse.status},
body was: ${errorResponse.message}`);
return throwError(() => errorResponse);
}), finalize(() => _loading.hide()));
}
Expand Down
4 changes: 1 addition & 3 deletions ui/projects/web/src/app/pages/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
<nz-layout>
<nz-sider [nzCollapsedWidth]="0" nzBreakpoint="md" nzCollapsible nzWidth="14.6rem">
<ul class="sider-menu" nz-menu nzMode="inline" nzTheme="dark">
<li nz-menu-item><i class="bi bi-p-circle-fill mx-2"></i><a routerLink="/home">首页</a></li>
<li *ngFor="let menu of menus$|async; index as i" nz-submenu nzIcon="user" nzOpen
nzTitle="{{menu.name}}">
<ul>
<li *ngFor="let child of menu.children; index as i" nz-menu-item>
<a [state]="child" routerLink=".{{child.path}}" routerLinkActive="active">{{child.name}}</a>
</li>
<li nz-menu-item><a routerLink="/home">首页</a></li>
<li nz-menu-item>option3</li>
<li nz-menu-item>option4</li>
</ul>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion ui/projects/web/src/app/pages/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Menu, MenusService} from "../system/menus/menus.service";
import {ActivatedRoute, NavigationEnd, Params, PRIMARY_OUTLET, Resolve, ResolveFn, Router} from "@angular/router";

export interface Breadcrumb {
label: string | Type<Resolve<string>> | ResolveFn<string>;
label: string | ResolveFn<string> | Type<Resolve<string>>;
params: Params;
url: string;
}
Expand Down

0 comments on commit 07b6f28

Please sign in to comment.