From 6a5322e33b8f4cc22d0a6f12cf64da7aeaaea56c Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Thu, 5 Mar 2020 08:36:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E4=BF=AE=E6=AD=A3]=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E9=A1=B9=E7=9B=AE=E5=90=AF=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3,=E4=BF=AE=E6=AD=A3=E8=B7=AF=E7=94=B1=E5=AE=88?= =?UTF-8?q?=E5=8D=AB=E9=AA=8C=E8=AF=81=E6=B3=A8=E5=86=8C=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/app/app-routing.module.ts | 14 +++++++------- src/app/pages/login/login.component.html | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index dd17b05..b331317 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "scripts": { "ng": "ng", - "start": "ng serve --proxy-config proxy.config.json --open ", + "start": "ng serve --proxy-config proxy.config.json --open --port 4000 ", "build": "ng build", "test": "ng test", "lint": "ng lint", diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 7b7a230..10ba6b9 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -9,6 +9,7 @@ import { LockscreenComponent } from './pages/lockscreen/lockscreen.component'; import {AuthGuard} from './auth.guard' + const routes: Routes = [ {path:'',redirectTo:'login',pathMatch:'full'}, { @@ -18,17 +19,16 @@ const routes: Routes = [ children:[ {path:'datacollection',loadChildren:() => import('./ui/ui.module').then(m => m.UiModule)} ]}, - + {path:'login', - component:LoginComponent}, + component:LoginComponent}, //登录页 {path:'register', - component:RegisterComponent, - canActivate: [AuthGuard],},//守卫验证 + component:RegisterComponent,}, //注册页 - {path:'lockscreen', - component:LockscreenComponent, - canActivate: [AuthGuard],}//守卫验证 + // {path:'lockscreen', + // component:LockscreenComponent, + // canActivate: [AuthGuard],}//守卫验证 ]; @NgModule({ diff --git a/src/app/pages/login/login.component.html b/src/app/pages/login/login.component.html index 2fdcc60..bd480ac 100644 --- a/src/app/pages/login/login.component.html +++ b/src/app/pages/login/login.component.html @@ -2,7 +2,7 @@
-

用户信息采集平台

+

数据采集管理平台

From 383d65337b5eddfdd90c361c9ac737c396adb2be Mon Sep 17 00:00:00 2001 From: cpf <1105965053@qq.com> Date: Sun, 8 Mar 2020 15:53:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E5=AE=8C=E5=96=84]=E9=87=87=E9=9B=86?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=B9=B3=E5=8F=B0=E7=99=BB=E5=BD=95,?= =?UTF-8?q?=E7=99=BB=E5=87=BA,=E6=B3=A8=E5=86=8C,=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=AF=86=E7=A0=81,=E8=8E=B7=E5=8F=96=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF,=E5=88=B7=E6=96=B0token?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.component.ts | 37 +---- src/app/http-interceptors/base-interceptor.ts | 12 +- .../http-interceptors/cache-token.service.ts | 8 +- src/app/pages/login/login.component.html | 67 ++++---- src/app/pages/login/login.component.scss | 146 +++++++----------- src/app/pages/login/login.component.ts | 52 +++---- .../pages/register/register.component.html | 129 ++++++++-------- .../pages/register/register.component.scss | 128 +++++++-------- src/app/pages/register/register.component.ts | 39 ++++- src/app/tabbar/tabbar.component.html | 4 +- src/app/tabbar/tabbar.component.ts | 23 ++- .../changepassword.component.ts | 2 +- src/app/ui/ui-routing.module.ts | 1 + .../ui/userdata/edituserdata.component.html | 51 ++++-- src/app/ui/userdata/userdata.component.html | 34 ++-- src/app/ui/userdata/userdata.component.scss | 32 ++-- src/app/ui/userdata/userdata.component.ts | 116 +++++++------- src/index.html | 2 +- 18 files changed, 440 insertions(+), 443 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d12bf0c..801fb2e 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -3,44 +3,25 @@ import { HttpClient } from '@angular/common/http' import { Data } from './interface' import { Router,ActivatedRoute } from '@angular/router' import {CacheTokenService} from './http-interceptors/cache-token.service'//引入服务 + + + @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { - title = '数字化预案编制管理平台'; + title = '数据采集管理平台'; constructor(private http:HttpClient,private router:Router,public token:CacheTokenService) { } - ngOnInit(): void { - var isnologin = localStorage.getItem("isnologin") - //七天免登录 - if(isnologin){ - var token = localStorage.getItem("token"); - var refreshToken = localStorage.getItem("refreshToken"); - this.http.post( - '/api/Account/RefreshToken', - { - token: token, - refreshToken: refreshToken - } - ).subscribe( - (data: Data) => { - sessionStorage.setItem("token",data.token); - sessionStorage.setItem("refreshToken",data.refreshToken); - this.token.getmenus() - this.token.startUp() - this.router.navigate(['/ui/person']) - console.log('已自动登录') - } - ) - }else{ + ngOnInit(): void { var token = sessionStorage.getItem("token"); var refreshToken = sessionStorage.getItem("refreshToken"); if(token && refreshToken) { this.http.post( - '/api/Account/RefreshToken', + '/api/CompanyAccount/RefreshToken', { token: token, refreshToken: refreshToken @@ -49,15 +30,13 @@ export class AppComponent { (data: Data) => { sessionStorage.setItem("token",data.token); sessionStorage.setItem("refreshToken",data.refreshToken); - this.token.getmenus() this.token.startUp() console.log('已重启定时器') } - ) - } + ) } - } + } diff --git a/src/app/http-interceptors/base-interceptor.ts b/src/app/http-interceptors/base-interceptor.ts index 9515a59..91bb81f 100644 --- a/src/app/http-interceptors/base-interceptor.ts +++ b/src/app/http-interceptors/base-interceptor.ts @@ -8,6 +8,7 @@ import { catchError, retry } from 'rxjs/operators'; import { Router,ActivatedRoute } from '@angular/router' import {CacheTokenService} from './cache-token.service' +import { MatSnackBar } from '@angular/material/snack-bar'; //baseurl // const baseurl = 'http://39.106.78.171:8008'; @@ -15,7 +16,8 @@ import {CacheTokenService} from './cache-token.service' @Injectable() export class BaseInterceptor implements HttpInterceptor { - constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService) {} + constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService, + public snackBar: MatSnackBar) {} intercept(req, next: HttpHandler) { @@ -47,11 +49,15 @@ export class BaseInterceptor implements HttpInterceptor { this.token.delete() sessionStorage.clear() window.localStorage.clear() - alert('用户认证信息过期,请重新登录') + this.snackBar.open('用户认证信息过期,请重新登录', '确定', { + duration: 3000 + }); this.router.navigate(['/login']) } if (error.status === 403) { - alert('对不起,您无此权限') + this.snackBar.open('对不起,您无此权限!', '确定', { + duration: 3000 + }); } if (error.error instanceof ErrorEvent) { diff --git a/src/app/http-interceptors/cache-token.service.ts b/src/app/http-interceptors/cache-token.service.ts index 938dee8..cf2b151 100644 --- a/src/app/http-interceptors/cache-token.service.ts +++ b/src/app/http-interceptors/cache-token.service.ts @@ -15,13 +15,12 @@ export class CacheTokenService { startUp = ():void=>{ // this.getmenus(); this.timer = window.setInterval( - ()=>{ window.clearInterval(this.settime) var token = sessionStorage.getItem("token"); var refreshToken = sessionStorage.getItem("refreshToken"); this.http.post( - '/api/Account/RefreshToken', + '/api/CompanyAccount/RefreshToken', { token: token, refreshToken: refreshToken @@ -36,6 +35,7 @@ export class CacheTokenService { } ,18*60*1000) } + organization = false;//组织机构管理 un = false;//单位类型管理 unit = false;//单位类型 @@ -94,14 +94,12 @@ export class CacheTokenService { this.matlibrary = true } }); - // console.log(777,this.user,this.organization,this.power) }) } - - + //删除定时器 delete = ():void=> { diff --git a/src/app/pages/login/login.component.html b/src/app/pages/login/login.component.html index bd480ac..bd3de21 100644 --- a/src/app/pages/login/login.component.html +++ b/src/app/pages/login/login.component.html @@ -1,51 +1,42 @@