From 95eded49bf049aa290a76ec2da2a682910c6a812 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Wed, 22 May 2024 11:53:46 +0800 Subject: [PATCH] 1 --- src/app/app.routes.ts | 10 +++++ src/app/pages/error/error.module.ts | 12 +++++ src/app/pages/error/error.routes.ts | 8 ++++ .../error/error401/error401.component.html | 5 +++ .../error/error401/error401.component.less | 0 .../error/error401/error401.component.ts | 44 +++++++++++++++++++ .../error/error403/error403.component.html | 1 + .../error/error403/error403.component.less | 0 .../error/error403/error403.component.spec.ts | 23 ++++++++++ .../error/error403/error403.component.ts | 12 +++++ .../error/error404/error404.component.html | 1 + .../error/error404/error404.component.less | 0 .../error/error404/error404.component.spec.ts | 23 ++++++++++ .../error/error404/error404.component.ts | 12 +++++ .../error/error500/error500.component.html | 1 + .../error/error500/error500.component.less | 0 .../error/error500/error500.component.spec.ts | 23 ++++++++++ .../error/error500/error500.component.ts | 12 +++++ src/app/utils/Interceptor.service.ts | 1 + src/environments/environment.dev.ts | 2 +- 20 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 src/app/pages/error/error.module.ts create mode 100644 src/app/pages/error/error.routes.ts create mode 100644 src/app/pages/error/error401/error401.component.html create mode 100644 src/app/pages/error/error401/error401.component.less create mode 100644 src/app/pages/error/error401/error401.component.ts create mode 100644 src/app/pages/error/error403/error403.component.html create mode 100644 src/app/pages/error/error403/error403.component.less create mode 100644 src/app/pages/error/error403/error403.component.spec.ts create mode 100644 src/app/pages/error/error403/error403.component.ts create mode 100644 src/app/pages/error/error404/error404.component.html create mode 100644 src/app/pages/error/error404/error404.component.less create mode 100644 src/app/pages/error/error404/error404.component.spec.ts create mode 100644 src/app/pages/error/error404/error404.component.ts create mode 100644 src/app/pages/error/error500/error500.component.html create mode 100644 src/app/pages/error/error500/error500.component.less create mode 100644 src/app/pages/error/error500/error500.component.spec.ts create mode 100644 src/app/pages/error/error500/error500.component.ts diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 74f2315..d692fd2 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,6 +1,7 @@ import { Routes } from '@angular/router'; import {IndexComponent} from "./pages/body/index/index.component"; import {InitGuardService} from "./utils/initGuard.service"; +import {ERROR_ROUTES} from "./pages/error/error.routes"; export const routes: Routes = [ {path: '', pathMatch: 'full', redirectTo: 'admin/index'}, { @@ -54,6 +55,15 @@ export const routes: Routes = [ loadChildren: () => import('./pages/audit/audit.routes').then(m => m.AUDIT_ROUTES), canActivate: [InitGuardService] }, + { + path: 'error', + children: [ + {path: '', loadChildren: () => import('./pages/error/error.routes').then(m => m.ERROR_ROUTES)}, + ] + }, + { + // path: '**', component: Error404Component + }, ] } ]; diff --git a/src/app/pages/error/error.module.ts b/src/app/pages/error/error.module.ts new file mode 100644 index 0000000..d4b3183 --- /dev/null +++ b/src/app/pages/error/error.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + + + +@NgModule({ + declarations: [], + imports: [ + CommonModule + ] +}) +export class ErrorModule { } diff --git a/src/app/pages/error/error.routes.ts b/src/app/pages/error/error.routes.ts new file mode 100644 index 0000000..f440676 --- /dev/null +++ b/src/app/pages/error/error.routes.ts @@ -0,0 +1,8 @@ +import { Routes } from '@angular/router'; + + + +export const ERROR_ROUTES: Routes = [ + + +]; diff --git a/src/app/pages/error/error401/error401.component.html b/src/app/pages/error/error401/error401.component.html new file mode 100644 index 0000000..727e860 --- /dev/null +++ b/src/app/pages/error/error401/error401.component.html @@ -0,0 +1,5 @@ + +
+ +
+
diff --git a/src/app/pages/error/error401/error401.component.less b/src/app/pages/error/error401/error401.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/error/error401/error401.component.ts b/src/app/pages/error/error401/error401.component.ts new file mode 100644 index 0000000..deb3ba9 --- /dev/null +++ b/src/app/pages/error/error401/error401.component.ts @@ -0,0 +1,44 @@ +import { Component } from '@angular/core'; +import {NzResultModule} from "ng-zorro-antd/result"; +import {NzButtonComponent} from "ng-zorro-antd/button"; +import {BrowserStorageService} from "../../../utils/localStorage.service"; +import {NzMessageService} from "ng-zorro-antd/message"; +import {Router} from "@angular/router"; +import {LoginService} from "../../../services/login/login.service"; +import {DATA, INIT_FLAG, LOGIN_DATA, USER_TOKEN} from "../../../data/login/localStorage.namespace"; + + +@Component({ + selector: 'app-error401', + standalone: true, + imports: [ + NzResultModule, + NzButtonComponent + ], + templateUrl: './error401.component.html', + styleUrl: './error401.component.less' +}) +export class Error401Component { + constructor( + private storage: BrowserStorageService, + private message: NzMessageService, + private router: Router, // 路由 + private login: LoginService + ) {} + + + // 退出登录 + public loginOut(): void { + this.login.loginOut( (data: any) => { + if (data['return_code'] === '000000') { + this.storage.remove(LOGIN_DATA); + this.storage.remove(DATA); + this.storage.remove(USER_TOKEN); + this.storage.remove(INIT_FLAG); + this.router.navigateByUrl('/login').then(); + } else { + this.message.error(data['return_msg']); + } + }); + } +} diff --git a/src/app/pages/error/error403/error403.component.html b/src/app/pages/error/error403/error403.component.html new file mode 100644 index 0000000..26983dd --- /dev/null +++ b/src/app/pages/error/error403/error403.component.html @@ -0,0 +1 @@ +

error403 works!

diff --git a/src/app/pages/error/error403/error403.component.less b/src/app/pages/error/error403/error403.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/error/error403/error403.component.spec.ts b/src/app/pages/error/error403/error403.component.spec.ts new file mode 100644 index 0000000..b89455c --- /dev/null +++ b/src/app/pages/error/error403/error403.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { Error403Component } from './error403.component'; + +describe('Error403Component', () => { + let component: Error403Component; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [Error403Component] + }) + .compileComponents(); + + fixture = TestBed.createComponent(Error403Component); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/error/error403/error403.component.ts b/src/app/pages/error/error403/error403.component.ts new file mode 100644 index 0000000..94fb5fb --- /dev/null +++ b/src/app/pages/error/error403/error403.component.ts @@ -0,0 +1,12 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-error403', + standalone: true, + imports: [], + templateUrl: './error403.component.html', + styleUrl: './error403.component.less' +}) +export class Error403Component { + +} diff --git a/src/app/pages/error/error404/error404.component.html b/src/app/pages/error/error404/error404.component.html new file mode 100644 index 0000000..dda0456 --- /dev/null +++ b/src/app/pages/error/error404/error404.component.html @@ -0,0 +1 @@ +

error404 works!

diff --git a/src/app/pages/error/error404/error404.component.less b/src/app/pages/error/error404/error404.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/error/error404/error404.component.spec.ts b/src/app/pages/error/error404/error404.component.spec.ts new file mode 100644 index 0000000..3cf2c6b --- /dev/null +++ b/src/app/pages/error/error404/error404.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { Error404Component } from './error404.component'; + +describe('Error404Component', () => { + let component: Error404Component; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [Error404Component] + }) + .compileComponents(); + + fixture = TestBed.createComponent(Error404Component); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/error/error404/error404.component.ts b/src/app/pages/error/error404/error404.component.ts new file mode 100644 index 0000000..dae7302 --- /dev/null +++ b/src/app/pages/error/error404/error404.component.ts @@ -0,0 +1,12 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-error404', + standalone: true, + imports: [], + templateUrl: './error404.component.html', + styleUrl: './error404.component.less' +}) +export class Error404Component { + +} diff --git a/src/app/pages/error/error500/error500.component.html b/src/app/pages/error/error500/error500.component.html new file mode 100644 index 0000000..cebb37a --- /dev/null +++ b/src/app/pages/error/error500/error500.component.html @@ -0,0 +1 @@ +

error500 works!

diff --git a/src/app/pages/error/error500/error500.component.less b/src/app/pages/error/error500/error500.component.less new file mode 100644 index 0000000..e69de29 diff --git a/src/app/pages/error/error500/error500.component.spec.ts b/src/app/pages/error/error500/error500.component.spec.ts new file mode 100644 index 0000000..c206cc3 --- /dev/null +++ b/src/app/pages/error/error500/error500.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { Error500Component } from './error500.component'; + +describe('Error500Component', () => { + let component: Error500Component; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [Error500Component] + }) + .compileComponents(); + + fixture = TestBed.createComponent(Error500Component); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/error/error500/error500.component.ts b/src/app/pages/error/error500/error500.component.ts new file mode 100644 index 0000000..2e485f1 --- /dev/null +++ b/src/app/pages/error/error500/error500.component.ts @@ -0,0 +1,12 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-error500', + standalone: true, + imports: [], + templateUrl: './error500.component.html', + styleUrl: './error500.component.less' +}) +export class Error500Component { + +} diff --git a/src/app/utils/Interceptor.service.ts b/src/app/utils/Interceptor.service.ts index cb664a6..382abfb 100644 --- a/src/app/utils/Interceptor.service.ts +++ b/src/app/utils/Interceptor.service.ts @@ -69,6 +69,7 @@ export class InterceptorService implements HttpInterceptor { } jumpError(message: string , status: number) { + console.log("status" , status); // this.router.navigateByUrl('/error/500'); } diff --git a/src/environments/environment.dev.ts b/src/environments/environment.dev.ts index 088432e..71468d7 100644 --- a/src/environments/environment.dev.ts +++ b/src/environments/environment.dev.ts @@ -3,5 +3,5 @@ export const environment = { baseUrl: 'https://phgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) orderUrl: 'https://phgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址) userUrl: 'https://phgcs.dctpay.com/user/', // 测试环境服务器地址(请求数据地址) - imageUrl: 'https://phgcs.dctpay.com/filesystem/', + imageUrl: 'https://phg-test.obs.cn-southwest-2.myhuaweicloud.com/', };