袁野 6 months ago
parent 5493d07a16
commit 95eded49bf
  1. 10
      src/app/app.routes.ts
  2. 12
      src/app/pages/error/error.module.ts
  3. 8
      src/app/pages/error/error.routes.ts
  4. 5
      src/app/pages/error/error401/error401.component.html
  5. 0
      src/app/pages/error/error401/error401.component.less
  6. 44
      src/app/pages/error/error401/error401.component.ts
  7. 1
      src/app/pages/error/error403/error403.component.html
  8. 0
      src/app/pages/error/error403/error403.component.less
  9. 23
      src/app/pages/error/error403/error403.component.spec.ts
  10. 12
      src/app/pages/error/error403/error403.component.ts
  11. 1
      src/app/pages/error/error404/error404.component.html
  12. 0
      src/app/pages/error/error404/error404.component.less
  13. 23
      src/app/pages/error/error404/error404.component.spec.ts
  14. 12
      src/app/pages/error/error404/error404.component.ts
  15. 1
      src/app/pages/error/error500/error500.component.html
  16. 0
      src/app/pages/error/error500/error500.component.less
  17. 23
      src/app/pages/error/error500/error500.component.spec.ts
  18. 12
      src/app/pages/error/error500/error500.component.ts
  19. 1
      src/app/utils/Interceptor.service.ts
  20. 2
      src/environments/environment.dev.ts

@ -1,6 +1,7 @@
import { Routes } from '@angular/router'; import { Routes } from '@angular/router';
import {IndexComponent} from "./pages/body/index/index.component"; import {IndexComponent} from "./pages/body/index/index.component";
import {InitGuardService} from "./utils/initGuard.service"; import {InitGuardService} from "./utils/initGuard.service";
import {ERROR_ROUTES} from "./pages/error/error.routes";
export const routes: Routes = [ export const routes: Routes = [
{path: '', pathMatch: 'full', redirectTo: 'admin/index'}, {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), loadChildren: () => import('./pages/audit/audit.routes').then(m => m.AUDIT_ROUTES),
canActivate: [InitGuardService] canActivate: [InitGuardService]
}, },
{
path: 'error',
children: [
{path: '', loadChildren: () => import('./pages/error/error.routes').then(m => m.ERROR_ROUTES)},
]
},
{
// path: '**', component: Error404Component
},
] ]
} }
]; ];

@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
@NgModule({
declarations: [],
imports: [
CommonModule
]
})
export class ErrorModule { }

@ -0,0 +1,8 @@
import { Routes } from '@angular/router';
export const ERROR_ROUTES: Routes = [
];

@ -0,0 +1,5 @@
<nz-result nzStatus="warning" nzTitle="当前登录信息已过期,请重新登录!">
<div nz-result-extra>
<button nz-button nzType="primary" (click)="loginOut()">重新登录</button>
</div>
</nz-result>

@ -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']);
}
});
}
}

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Error403Component } from './error403.component';
describe('Error403Component', () => {
let component: Error403Component;
let fixture: ComponentFixture<Error403Component>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Error403Component]
})
.compileComponents();
fixture = TestBed.createComponent(Error403Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -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 {
}

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Error404Component } from './error404.component';
describe('Error404Component', () => {
let component: Error404Component;
let fixture: ComponentFixture<Error404Component>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Error404Component]
})
.compileComponents();
fixture = TestBed.createComponent(Error404Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -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 {
}

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Error500Component } from './error500.component';
describe('Error500Component', () => {
let component: Error500Component;
let fixture: ComponentFixture<Error500Component>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Error500Component]
})
.compileComponents();
fixture = TestBed.createComponent(Error500Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -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 {
}

@ -69,6 +69,7 @@ export class InterceptorService implements HttpInterceptor {
} }
jumpError(message: string , status: number) { jumpError(message: string , status: number) {
console.log("status" , status);
// this.router.navigateByUrl('/error/500'); // this.router.navigateByUrl('/error/500');
} }

@ -3,5 +3,5 @@ export const environment = {
baseUrl: 'https://phgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址) baseUrl: 'https://phgcs.dctpay.com/brest/', // 测试环境服务器地址(请求数据地址)
orderUrl: 'https://phgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址) orderUrl: 'https://phgcs.dctpay.com/order/', // 测试环境服务器地址(请求数据地址)
userUrl: 'https://phgcs.dctpay.com/user/', // 测试环境服务器地址(请求数据地址) userUrl: 'https://phgcs.dctpay.com/user/', // 测试环境服务器地址(请求数据地址)
imageUrl: 'https://phgcs.dctpay.com/filesystem/', imageUrl: 'https://phg-test.obs.cn-southwest-2.myhuaweicloud.com/',
}; };

Loading…
Cancel
Save