diff --git a/src/app/api/http/http.service.ts b/src/app/api/http/http.service.ts index f08f30d..8d85933 100644 --- a/src/app/api/http/http.service.ts +++ b/src/app/api/http/http.service.ts @@ -1,6 +1,6 @@ import {Injectable} from '@angular/core'; import {RequestObj} from '../../class/HttpReqAndResp'; -import {HttpClient} from '@angular/common/http'; +import {HttpClient, HttpResponse} from '@angular/common/http'; import {environment} from '../../../environments/environment'; import {LocalStorageService} from '../../services/local-storage.service'; import {Response} from '../../class/HttpReqAndResp'; @@ -34,7 +34,7 @@ export class HttpService { } request.path = this.checkUrl(request); - let observable: Observable>; + let observable: Observable>>; switch (request.method) { case 'GET': observable = this.get>(request); @@ -55,13 +55,17 @@ export class HttpService { const oob = new Observable>(o => observer = o); observable.subscribe(o => { - if (o.code) { + const tokenFromReps = o.headers.get('Authorization'); + if (tokenFromReps) { + this.localStorageService.setToken(tokenFromReps); + } + if (o.body.code) { observer.error(o); if (this.errorDispatch) { - this.errorDispatch.errHandler(o.code, o.msg, request); + this.errorDispatch.errHandler(o.body.code, o.body.msg, request); } } else { - observer.next(o); + observer.next(o.body); } observer.complete(); }); @@ -72,7 +76,8 @@ export class HttpService { return this.httpClient.get(request.path, { headers: request.header, - withCredentials: true + withCredentials: true, + observe: 'response' }); } @@ -80,7 +85,8 @@ export class HttpService { return this.httpClient.post(request.path, request.data, { headers: request.header, - withCredentials: true + withCredentials: true, + observe: 'response' }); } @@ -88,7 +94,8 @@ export class HttpService { return this.httpClient.put(request.path, request.data, { headers: request.header, - withCredentials: true + withCredentials: true, + observe: 'response' }); } @@ -96,7 +103,8 @@ export class HttpService { return this.httpClient.delete(request.path, { headers: request.header, - withCredentials: true + withCredentials: true, + observe: 'response' }); } diff --git a/src/app/services/global-user.service.ts b/src/app/services/global-user.service.ts index d6c3758..f018438 100644 --- a/src/app/services/global-user.service.ts +++ b/src/app/services/global-user.service.ts @@ -115,7 +115,7 @@ export class GlobalUserService { } this.localStorageService.removeToken(); this.userObserverArray.forEach(ob => ob.next(new Response(null))); - this.userObserverArray.forEach(ob => ob.error(err)); + this.userObserverArray.forEach(ob => ob.error && ob.error(err)); } }); } diff --git a/src/app/view/admin/admin-article/admin-article.component.html b/src/app/view/admin/admin-article/admin-article.component.html index ef9c6c9..01983b6 100644 --- a/src/app/view/admin/admin-article/admin-article.component.html +++ b/src/app/view/admin/admin-article/admin-article.component.html @@ -1,7 +1,7 @@
标题 diff --git a/src/app/view/admin/admin-comment/admin-comment.component.html b/src/app/view/admin/admin-comment/admin-comment.component.html index 5d1e959..1c6fe8d 100644 --- a/src/app/view/admin/admin-comment/admin-comment.component.html +++ b/src/app/view/admin/admin-comment/admin-comment.component.html @@ -1,7 +1,7 @@
文章标题 diff --git a/src/app/view/admin/admin-dashboard/admin-dashboard.component.html b/src/app/view/admin/admin-dashboard/admin-dashboard.component.html index 90fd9d9..0eadbc5 100644 --- a/src/app/view/admin/admin-dashboard/admin-dashboard.component.html +++ b/src/app/view/admin/admin-dashboard/admin-dashboard.component.html @@ -1,6 +1,6 @@
- + @@ -16,7 +16,7 @@ - + @@ -31,8 +31,8 @@
-
- +
+ @@ -44,11 +44,11 @@
- + - +

此博客由 禾几海(郑海) 设计并实现的

博客自2019年3月开始开发编写 5月开始正式运行至今

博客所有代码都是开源的,你可以随意修改,运行和发布

@@ -59,7 +59,7 @@

如果觉得博客还不错,请前往Github支持我,给我点一个star吧

- +

坚强的信心,能使平凡的人做出惊人的事业。

——马尔顿

diff --git a/src/app/view/admin/admin-dashboard/admin-dashboard.component.less b/src/app/view/admin/admin-dashboard/admin-dashboard.component.less index e69de29..584827f 100644 --- a/src/app/view/admin/admin-dashboard/admin-dashboard.component.less +++ b/src/app/view/admin/admin-dashboard/admin-dashboard.component.less @@ -0,0 +1,3 @@ +nz-card { + margin-bottom: 30px +} diff --git a/src/app/view/admin/admin-link/admin-link.component.html b/src/app/view/admin/admin-link/admin-link.component.html index 8ce023f..08eef0c 100644 --- a/src/app/view/admin/admin-link/admin-link.component.html +++ b/src/app/view/admin/admin-link/admin-link.component.html @@ -2,7 +2,7 @@ 友链名称 diff --git a/src/app/view/admin/admin-tag/admin-tag.component.html b/src/app/view/admin/admin-tag/admin-tag.component.html index aab61b7..5291bf6 100644 --- a/src/app/view/admin/admin-tag/admin-tag.component.html +++ b/src/app/view/admin/admin-tag/admin-tag.component.html @@ -14,7 +14,7 @@
分类名 @@ -51,7 +51,7 @@ 标签名 diff --git a/src/app/view/admin/admin-update/admin-update.component.html b/src/app/view/admin/admin-update/admin-update.component.html index 4dbfa90..f73c2be 100644 --- a/src/app/view/admin/admin-update/admin-update.component.html +++ b/src/app/view/admin/admin-update/admin-update.component.html @@ -2,7 +2,7 @@ 更新内容 diff --git a/src/app/view/admin/admin-user/admin-user.component.html b/src/app/view/admin/admin-user/admin-user.component.html index f06b013..c9694ec 100644 --- a/src/app/view/admin/admin-user/admin-user.component.html +++ b/src/app/view/admin/admin-user/admin-user.component.html @@ -1,7 +1,7 @@
邮箱 diff --git a/src/app/view/admin/admin-visitor/admin-visitor.component.html b/src/app/view/admin/admin-visitor/admin-visitor.component.html index d5cf0c7..9808b3f 100644 --- a/src/app/view/admin/admin-visitor/admin-visitor.component.html +++ b/src/app/view/admin/admin-visitor/admin-visitor.component.html @@ -1,7 +1,7 @@
ip地址