添加维护页面,修复bug
This commit is contained in:
@@ -1,10 +1,7 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {forwardRef, Inject, Injectable} from '@angular/core';
|
||||||
import {HttpClient} from '@angular/common/http';
|
|
||||||
|
|
||||||
import {Article} from '../class/Article';
|
import {Article} from '../class/Article';
|
||||||
import {HttpService} from './http/http.service';
|
import {HttpService} from './http/http.service';
|
||||||
import {PageList} from '../class/HttpReqAndResp';
|
import {PageList} from '../class/HttpReqAndResp';
|
||||||
import {ErrDispatch} from '../class/ErrDispatch';
|
|
||||||
import {ArticleReq} from '../class/Article';
|
import {ArticleReq} from '../class/Article';
|
||||||
import {Category, Tag} from '../class/Tag';
|
import {Category, Tag} from '../class/Tag';
|
||||||
import {Comment} from '../class/Comment';
|
import {Comment} from '../class/Comment';
|
||||||
@@ -12,28 +9,21 @@ import {CommentReq} from '../class/Comment';
|
|||||||
import {ApplyLinkReq, Link} from '../class/Link';
|
import {ApplyLinkReq, Link} from '../class/Link';
|
||||||
import {User} from '../class/User';
|
import {User} from '../class/User';
|
||||||
import {LoginReq} from '../class/User';
|
import {LoginReq} from '../class/User';
|
||||||
|
|
||||||
import {LocalStorageService} from '../services/local-storage.service';
|
|
||||||
import {Visitor} from '../class/Visitor';
|
import {Visitor} from '../class/Visitor';
|
||||||
import {UpdateInfo} from '../class/UpdateInfo';
|
import {UpdateInfo} from '../class/UpdateInfo';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class ApiService extends HttpService {
|
export class ApiService {
|
||||||
|
|
||||||
constructor(httpClient: HttpClient,
|
|
||||||
localStorageService: LocalStorageService) {
|
|
||||||
super(httpClient, localStorageService);
|
|
||||||
}
|
|
||||||
|
|
||||||
setErrDispatch(errDispatch: ErrDispatch) {
|
constructor(private httpService: HttpService) {
|
||||||
super.setErrDispatch(errDispatch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
createArticle(article: ArticleReq) {
|
createArticle(article: ArticleReq) {
|
||||||
article.id = null;
|
article.id = null;
|
||||||
return super.Service<Article>({
|
return this.httpService.Service<Article>({
|
||||||
path: '/admin/article/create',
|
path: '/admin/article/create',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@@ -42,7 +32,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteArticle(id: number) {
|
deleteArticle(id: number) {
|
||||||
return super.Service<boolean>({
|
return this.httpService.Service<boolean>({
|
||||||
path: '/admin/article/del',
|
path: '/admin/article/del',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
queryParam: {articleID: id}
|
queryParam: {articleID: id}
|
||||||
@@ -50,7 +40,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
articles(pageNumber: number = 1, pageSize: number = 5) {
|
articles(pageNumber: number = 1, pageSize: number = 5) {
|
||||||
return super.Service<PageList<Article>>({
|
return this.httpService.Service<PageList<Article>>({
|
||||||
path: '/articles',
|
path: '/articles',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -61,7 +51,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adminArticles(pageNumber: number = 1, pageSize: number = 10) {
|
adminArticles(pageNumber: number = 1, pageSize: number = 10) {
|
||||||
return super.Service<PageList<Article>>({
|
return this.httpService.Service<PageList<Article>>({
|
||||||
path: '/admin/articles',
|
path: '/admin/articles',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -72,7 +62,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateArticle(article: ArticleReq) {
|
updateArticle(article: ArticleReq) {
|
||||||
return super.Service<Article>({
|
return this.httpService.Service<Article>({
|
||||||
path: '/admin/article/update',
|
path: '/admin/article/update',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
@@ -81,7 +71,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getArticle(articleId: number, is4Update: boolean = false) {
|
getArticle(articleId: number, is4Update: boolean = false) {
|
||||||
return super.Service<Article>({
|
return this.httpService.Service<Article>({
|
||||||
path: `/article/articleID/${articleId}`,
|
path: `/article/articleID/${articleId}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {update: is4Update},
|
queryParam: {update: is4Update},
|
||||||
@@ -89,7 +79,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
articlesByCategory(category: string, pageNumber: number = 1, pageSize: number = 10) {
|
articlesByCategory(category: string, pageNumber: number = 1, pageSize: number = 10) {
|
||||||
return super.Service<PageList<Article>>({
|
return this.httpService.Service<PageList<Article>>({
|
||||||
path: `/articles/category/${category}`,
|
path: `/articles/category/${category}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -100,7 +90,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
articlesByTag(tag: string, pageNumber: number = 1, pageSize: number = 10) {
|
articlesByTag(tag: string, pageNumber: number = 1, pageSize: number = 10) {
|
||||||
return super.Service<PageList<Article>>({
|
return this.httpService.Service<PageList<Article>>({
|
||||||
path: `/articles/tag/${tag}`,
|
path: `/articles/tag/${tag}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -111,14 +101,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
categories() {
|
categories() {
|
||||||
return super.Service<PageList<Category>>({
|
return this.httpService.Service<PageList<Category>>({
|
||||||
path: '/categories',
|
path: '/categories',
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createCategory(nameStr: string) {
|
createCategory(nameStr: string) {
|
||||||
return super.Service<Category>({
|
return this.httpService.Service<Category>({
|
||||||
path: '/admin/category/create',
|
path: '/admin/category/create',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {name: nameStr}
|
queryParam: {name: nameStr}
|
||||||
@@ -126,7 +116,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteCategory(categoryId: number) {
|
deleteCategory(categoryId: number) {
|
||||||
return super.Service<boolean>({
|
return this.httpService.Service<boolean>({
|
||||||
path: '/admin/category/del',
|
path: '/admin/category/del',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
queryParam: {id: categoryId}
|
queryParam: {id: categoryId}
|
||||||
@@ -134,7 +124,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateCategory(categoryId: number, nameStr: string) {
|
updateCategory(categoryId: number, nameStr: string) {
|
||||||
return super.Service<Category>({
|
return this.httpService.Service<Category>({
|
||||||
path: '/admin/category/update',
|
path: '/admin/category/update',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
queryParam: {id: categoryId, name: nameStr}
|
queryParam: {id: categoryId, name: nameStr}
|
||||||
@@ -142,7 +132,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tags(pageNumber: number = 1, pageSize: number = 10) {
|
tags(pageNumber: number = 1, pageSize: number = 10) {
|
||||||
return super.Service<PageList<Tag>>({
|
return this.httpService.Service<PageList<Tag>>({
|
||||||
path: '/tags',
|
path: '/tags',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -153,14 +143,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tagsNac() {
|
tagsNac() {
|
||||||
return super.Service<{ name: string, size: number }[]>({
|
return this.httpService.Service<{ name: string, size: number }[]>({
|
||||||
path: '/tags/nac',
|
path: '/tags/nac',
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createTag(nameStr: string) {
|
createTag(nameStr: string) {
|
||||||
return super.Service<Tag>({
|
return this.httpService.Service<Tag>({
|
||||||
path: '/admin/tag/create',
|
path: '/admin/tag/create',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {name: nameStr}
|
queryParam: {name: nameStr}
|
||||||
@@ -168,7 +158,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteTag(TagId: number) {
|
deleteTag(TagId: number) {
|
||||||
return super.Service<boolean>({
|
return this.httpService.Service<boolean>({
|
||||||
path: '/admin/tag/del',
|
path: '/admin/tag/del',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
queryParam: {id: TagId}
|
queryParam: {id: TagId}
|
||||||
@@ -176,7 +166,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateTag(TagId: number, nameStr: string) {
|
updateTag(TagId: number, nameStr: string) {
|
||||||
return super.Service<Tag>({
|
return this.httpService.Service<Tag>({
|
||||||
path: '/admin/tag/update',
|
path: '/admin/tag/update',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
queryParam: {id: TagId, name: nameStr}
|
queryParam: {id: TagId, name: nameStr}
|
||||||
@@ -184,7 +174,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCommentByTypeForAdmin(pagePath: string, pageNumber: number = 1, pageSize: number = 10) {
|
getCommentByTypeForAdmin(pagePath: string, pageNumber: number = 1, pageSize: number = 10) {
|
||||||
return super.Service<PageList<Comment>>({
|
return this.httpService.Service<PageList<Comment>>({
|
||||||
path: `/admin/comment/pagePath/${pagePath}`,
|
path: `/admin/comment/pagePath/${pagePath}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -195,7 +185,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCommentByTypeForUser(pagePath: string, pageNumber: number = 1, pageSize: number = 10) {
|
getCommentByTypeForUser(pagePath: string, pageNumber: number = 1, pageSize: number = 10) {
|
||||||
return super.Service<PageList<Comment>>({
|
return this.httpService.Service<PageList<Comment>>({
|
||||||
path: `/user/comment/pagePath/${pagePath}`,
|
path: `/user/comment/pagePath/${pagePath}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -206,7 +196,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteComment(idNumer: number) {
|
deleteComment(idNumer: number) {
|
||||||
return super.Service<boolean>({
|
return this.httpService.Service<boolean>({
|
||||||
path: `/user/comment/del`,
|
path: `/user/comment/del`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
queryParam: {id: idNumer}
|
queryParam: {id: idNumer}
|
||||||
@@ -214,7 +204,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateComment(commentReq: CommentReq) {
|
updateComment(commentReq: CommentReq) {
|
||||||
return super.Service<Comment>({
|
return this.httpService.Service<Comment>({
|
||||||
path: `/user/comment/update`,
|
path: `/user/comment/update`,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
data: commentReq,
|
data: commentReq,
|
||||||
@@ -223,7 +213,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
comments(pagePath: string, pageSize: number = 10, pageNumber: number = 1) {
|
comments(pagePath: string, pageSize: number = 10, pageNumber: number = 1) {
|
||||||
return super.Service<PageList<Comment>>({
|
return this.httpService.Service<PageList<Comment>>({
|
||||||
path: `/comment/pagePath/${pagePath}`,
|
path: `/comment/pagePath/${pagePath}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -234,7 +224,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createComment(commentReq: CommentReq) {
|
createComment(commentReq: CommentReq) {
|
||||||
return super.Service<Comment>({
|
return this.httpService.Service<Comment>({
|
||||||
path: '/user/comment/create',
|
path: '/user/comment/create',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
@@ -244,7 +234,7 @@ export class ApiService extends HttpService {
|
|||||||
|
|
||||||
|
|
||||||
counts() {
|
counts() {
|
||||||
return super.Service<{
|
return this.httpService.Service<{
|
||||||
articleCount: number,
|
articleCount: number,
|
||||||
visitorCount: number,
|
visitorCount: number,
|
||||||
categoryCount: number,
|
categoryCount: number,
|
||||||
@@ -257,7 +247,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adminLinks(pageSize: number = 10, pageNumber: number = 1) {
|
adminLinks(pageSize: number = 10, pageNumber: number = 1) {
|
||||||
return super.Service<PageList<Link>>({
|
return this.httpService.Service<PageList<Link>>({
|
||||||
path: '/admin/links',
|
path: '/admin/links',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -268,7 +258,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createLink(linkReq: Link) {
|
createLink(linkReq: Link) {
|
||||||
return super.Service<Link>({
|
return this.httpService.Service<Link>({
|
||||||
path: '/admin/links/create',
|
path: '/admin/links/create',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: linkReq,
|
data: linkReq,
|
||||||
@@ -277,14 +267,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteLink(idNumber: number) {
|
deleteLink(idNumber: number) {
|
||||||
return super.Service<boolean>({
|
return this.httpService.Service<boolean>({
|
||||||
path: `/admin/links/del/${idNumber}`,
|
path: `/admin/links/del/${idNumber}`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLink(linkReq: Link) {
|
updateLink(linkReq: Link) {
|
||||||
return super.Service<Link>({
|
return this.httpService.Service<Link>({
|
||||||
path: '/admin/links/update',
|
path: '/admin/links/update',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
data: linkReq,
|
data: linkReq,
|
||||||
@@ -293,7 +283,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
applyLink(link: ApplyLinkReq) {
|
applyLink(link: ApplyLinkReq) {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/apply',
|
path: '/apply',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: link,
|
data: link,
|
||||||
@@ -302,7 +292,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reapplyLink(keyStr: string) {
|
reapplyLink(keyStr: string) {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/reapply',
|
path: '/reapply',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -312,14 +302,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
links() {
|
links() {
|
||||||
return super.Service<Link[]>({
|
return this.httpService.Service<Link[]>({
|
||||||
path: '/links',
|
path: '/links',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyImgCode(codeStr: string) {
|
verifyImgCode(codeStr: string) {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/verCode',
|
path: '/verCode',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {code: codeStr}
|
queryParam: {code: codeStr}
|
||||||
@@ -328,7 +318,7 @@ export class ApiService extends HttpService {
|
|||||||
|
|
||||||
|
|
||||||
login(loginReq: LoginReq) {
|
login(loginReq: LoginReq) {
|
||||||
return super.Service<User>({
|
return this.httpService.Service<User>({
|
||||||
path: '/login',
|
path: '/login',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
@@ -337,14 +327,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/logout',
|
path: '/logout',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
registration(emailStr: string, pwd: string) {
|
registration(emailStr: string, pwd: string) {
|
||||||
return super.Service<boolean>({
|
return this.httpService.Service<boolean>({
|
||||||
path: '/registration',
|
path: '/registration',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -355,7 +345,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resetPwd(idStr: string, emailStr: string, pwdStr: string) {
|
resetPwd(idStr: string, emailStr: string, pwdStr: string) {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/resetPwd',
|
path: '/resetPwd',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -367,7 +357,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emailVerify(idStr: string, emailStr: string) {
|
emailVerify(idStr: string, emailStr: string) {
|
||||||
return super.Service<void>({
|
return this.httpService.Service<void>({
|
||||||
path: '/emailVerify',
|
path: '/emailVerify',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -379,7 +369,7 @@ export class ApiService extends HttpService {
|
|||||||
|
|
||||||
|
|
||||||
sendResetPwdEmail(emailStr: string) {
|
sendResetPwdEmail(emailStr: string) {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/sendResetPwdEmail',
|
path: '/sendResetPwdEmail',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {email: emailStr}
|
queryParam: {email: emailStr}
|
||||||
@@ -387,7 +377,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendVerifyEmail(emailStr: string) {
|
sendVerifyEmail(emailStr: string) {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/sendVerifyEmail',
|
path: '/sendVerifyEmail',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {email: emailStr}
|
queryParam: {email: emailStr}
|
||||||
@@ -395,14 +385,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userInfo() {
|
userInfo() {
|
||||||
return super.Service<User>({
|
return this.httpService.Service<User>({
|
||||||
path: '/user/userInfo',
|
path: '/user/userInfo',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
adminUpdateUser(user: User) {
|
adminUpdateUser(user: User) {
|
||||||
return super.Service<User>({
|
return this.httpService.Service<User>({
|
||||||
path: '/admin/user',
|
path: '/admin/user',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
data: user,
|
data: user,
|
||||||
@@ -411,14 +401,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteUser(id: number) {
|
deleteUser(id: number) {
|
||||||
return super.Service<boolean>({
|
return this.httpService.Service<boolean>({
|
||||||
path: `/admin/user/delete/${id}`,
|
path: `/admin/user/delete/${id}`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
multipleDeleteUser(idArray: number[]) {
|
multipleDeleteUser(idArray: number[]) {
|
||||||
return super.Service<{ id: number; msg: string; status: boolean }[]>({
|
return this.httpService.Service<{ id: number; msg: string; status: boolean }[]>({
|
||||||
path: `/admin/user/delete`,
|
path: `/admin/user/delete`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
data: idArray,
|
data: idArray,
|
||||||
@@ -428,14 +418,14 @@ export class ApiService extends HttpService {
|
|||||||
|
|
||||||
// 获取邮件是否已注册
|
// 获取邮件是否已注册
|
||||||
emailStatus(email: string) {
|
emailStatus(email: string) {
|
||||||
return super.Service<boolean>({
|
return this.httpService.Service<boolean>({
|
||||||
path: `/emailStatus/${email}`,
|
path: `/emailStatus/${email}`,
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUserInfo(descStr: string, disPlayNameStr: string) {
|
updateUserInfo(descStr: string, disPlayNameStr: string) {
|
||||||
return super.Service<User>({
|
return this.httpService.Service<User>({
|
||||||
path: '/user/userInfo/update',
|
path: '/user/userInfo/update',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -446,7 +436,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
adminUsers(pageSize: number = 10, pageNumber: number = 1) {
|
adminUsers(pageSize: number = 10, pageNumber: number = 1) {
|
||||||
return super.Service<PageList<User>>({
|
return this.httpService.Service<PageList<User>>({
|
||||||
path: '/admin/users',
|
path: '/admin/users',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -457,14 +447,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
visit() {
|
visit() {
|
||||||
return super.Service<Visitor>({
|
return this.httpService.Service<Visitor>({
|
||||||
path: '/visit',
|
path: '/visit',
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
adminVisitors(location: boolean = false, pageSize: number = 10, pageNumber: number = 1) {
|
adminVisitors(location: boolean = false, pageSize: number = 10, pageNumber: number = 1) {
|
||||||
return super.Service<PageList<Visitor>>({
|
return this.httpService.Service<PageList<Visitor>>({
|
||||||
path: '/admin/visitor/page',
|
path: '/admin/visitor/page',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -476,42 +466,42 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dayVisitCount() {
|
dayVisitCount() {
|
||||||
return super.Service<number>({
|
return this.httpService.Service<number>({
|
||||||
path: '/dayVisitCount',
|
path: '/dayVisitCount',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getLocalIp() {
|
getLocalIp() {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/ip',
|
path: '/ip',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getIpLocation(ip: string) {
|
getIpLocation(ip: string) {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: `/ip/${ip}`,
|
path: `/ip/${ip}`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
visitorCount() {
|
visitorCount() {
|
||||||
return super.Service<number>({
|
return this.httpService.Service<number>({
|
||||||
path: `/visitor/count`,
|
path: `/visitor/count`,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
webUpdate() {
|
webUpdate() {
|
||||||
return super.Service<{ id: number, info: string, time: string }[]>({
|
return this.httpService.Service<{ id: number, info: string, time: string }[]>({
|
||||||
path: '/webUpdate',
|
path: '/webUpdate',
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
webUpdatePage(pageSize: number = 10, pageNumber: number = 1) {
|
webUpdatePage(pageSize: number = 10, pageNumber: number = 1) {
|
||||||
return super.Service<PageList<{ id: number, info: string, time: string }>>({
|
return this.httpService.Service<PageList<{ id: number, info: string, time: string }>>({
|
||||||
path: '/webUpdate/pages',
|
path: '/webUpdate/pages',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
@@ -522,7 +512,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastestUpdate() {
|
lastestUpdate() {
|
||||||
return super.Service<{
|
return this.httpService.Service<{
|
||||||
lastUpdateTime: string;
|
lastUpdateTime: string;
|
||||||
lastUpdateInfo: string;
|
lastUpdateInfo: string;
|
||||||
lastCommit: string;
|
lastCommit: string;
|
||||||
@@ -536,7 +526,7 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createWebUpdateInfo(infoStr: string) {
|
createWebUpdateInfo(infoStr: string) {
|
||||||
return super.Service<UpdateInfo>({
|
return this.httpService.Service<UpdateInfo>({
|
||||||
path: '/admin/webUpdate/create',
|
path: '/admin/webUpdate/create',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {info: infoStr}
|
queryParam: {info: infoStr}
|
||||||
@@ -544,14 +534,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteWebUpdateInfo(idNumber: number) {
|
deleteWebUpdateInfo(idNumber: number) {
|
||||||
return super.Service<boolean>({
|
return this.httpService.Service<boolean>({
|
||||||
path: `/admin/webUpdate/del/${idNumber}`,
|
path: `/admin/webUpdate/del/${idNumber}`,
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateWebUpdateInfo(idNumber: number, infoStr: string) {
|
updateWebUpdateInfo(idNumber: number, infoStr: string) {
|
||||||
return super.Service<UpdateInfo>({
|
return this.httpService.Service<UpdateInfo>({
|
||||||
path: '/admin/webUpdate/update',
|
path: '/admin/webUpdate/update',
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
queryParam: {id: idNumber, info: infoStr}
|
queryParam: {id: idNumber, info: infoStr}
|
||||||
@@ -559,14 +549,14 @@ export class ApiService extends HttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bingPic() {
|
bingPic() {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/bingPic',
|
path: '/bingPic',
|
||||||
method: 'GET'
|
method: 'GET'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setPwd(pwdStr: string, newPwdStr: string, confirmPwdStr: string,) {
|
setPwd(pwdStr: string, newPwdStr: string, confirmPwdStr: string,) {
|
||||||
return super.Service<string>({
|
return this.httpService.Service<string>({
|
||||||
path: '/user/setPwd',
|
path: '/user/setPwd',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
queryParam: {
|
queryParam: {
|
||||||
|
|||||||
@@ -1,28 +1,27 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import {Injectable, Injector} from '@angular/core';
|
||||||
import {RequestObj} from '../../class/HttpReqAndResp';
|
import {RequestObj, Response} from '../../class/HttpReqAndResp';
|
||||||
import {HttpClient, HttpResponse} from '@angular/common/http';
|
import {HttpClient, HttpResponse} from '@angular/common/http';
|
||||||
import {environment} from '../../../environments/environment';
|
import {environment} from '../../../environments/environment';
|
||||||
import {LocalStorageService} from '../../services/local-storage.service';
|
import {LocalStorageService} from '../../services/local-storage.service';
|
||||||
import {Response} from '../../class/HttpReqAndResp';
|
import {Observable, Observer, Subscription} from 'rxjs';
|
||||||
import {Observable, Observer, Subject} from 'rxjs';
|
import {ErrorService} from '../../services/error.service';
|
||||||
import {ErrDispatch} from '../../class/ErrDispatch';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class HttpService {
|
export class HttpService {
|
||||||
|
|
||||||
constructor(private httpClient: HttpClient,
|
constructor(private httpClient: HttpClient,
|
||||||
protected localStorageService: LocalStorageService) {
|
private localStorageService: LocalStorageService,
|
||||||
|
private injector: Injector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private errorDispatch: ErrDispatch;
|
private subscriptionQueue: Subscription[] = [];
|
||||||
|
|
||||||
setErrDispatch(errDispatch: ErrDispatch) {
|
public getSubscriptionQueue = () => this.subscriptionQueue;
|
||||||
this.errorDispatch = errDispatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
Service<T>(request: RequestObj) {
|
Service<T>(request: RequestObj) {
|
||||||
|
const errorService = this.injector.get(ErrorService);
|
||||||
request.url = null;
|
request.url = null;
|
||||||
// 设置默认值
|
// 设置默认值
|
||||||
request.contentType = request.contentType == null ? 'application/x-www-form-urlencoded' : request.contentType;
|
request.contentType = request.contentType == null ? 'application/x-www-form-urlencoded' : request.contentType;
|
||||||
@@ -55,25 +54,32 @@ export class HttpService {
|
|||||||
|
|
||||||
const oob = new Observable<Response<T>>(o => observer = o);
|
const oob = new Observable<Response<T>>(o => observer = o);
|
||||||
|
|
||||||
observable.subscribe(o => {
|
const subscription = observable.subscribe({
|
||||||
|
next: o => {
|
||||||
const tokenFromReps = o.headers.get('Authorization');
|
const tokenFromReps = o.headers.get('Authorization');
|
||||||
if (tokenFromReps) {
|
if (tokenFromReps) {
|
||||||
this.localStorageService.setToken(tokenFromReps);
|
this.localStorageService.setToken(tokenFromReps);
|
||||||
}
|
}
|
||||||
if (o.body.code !== 0) {
|
if (o.body.code !== 0) {
|
||||||
observer.error(o.body);
|
observer.error(o.body);
|
||||||
if (this.errorDispatch) {
|
errorService.httpException(o.body)
|
||||||
this.errorDispatch.errHandler(o.body.code, o.body.msg, request);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
observer.next(o.body);
|
observer.next(o.body);
|
||||||
}
|
}
|
||||||
observer.complete();
|
observer.complete();
|
||||||
|
},
|
||||||
|
error: err => {
|
||||||
|
errorService.httpError(err);
|
||||||
|
errorService.checkConnection();
|
||||||
|
this.subscriptionQueue.splice(this.subscriptionQueue.indexOf(subscription), 1)
|
||||||
|
},
|
||||||
|
complete: () => this.subscriptionQueue.splice(this.subscriptionQueue.indexOf(subscription), 1)
|
||||||
});
|
});
|
||||||
|
this.subscriptionQueue.push(subscription);
|
||||||
return oob;
|
return oob;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get<T>(request: RequestObj) {
|
get<T>(request: RequestObj) {
|
||||||
return this.httpClient.get<T>(request.url,
|
return this.httpClient.get<T>(request.url,
|
||||||
{
|
{
|
||||||
headers: request.header,
|
headers: request.header,
|
||||||
@@ -82,7 +88,7 @@ export class HttpService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private post<T>(request: RequestObj) {
|
post<T>(request: RequestObj) {
|
||||||
return this.httpClient.post<T>(request.url, request.data,
|
return this.httpClient.post<T>(request.url, request.data,
|
||||||
{
|
{
|
||||||
headers: request.header,
|
headers: request.header,
|
||||||
@@ -91,7 +97,7 @@ export class HttpService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private put<T>(request: RequestObj) {
|
put<T>(request: RequestObj) {
|
||||||
return this.httpClient.put<T>(request.url, request.data,
|
return this.httpClient.put<T>(request.url, request.data,
|
||||||
{
|
{
|
||||||
headers: request.header,
|
headers: request.header,
|
||||||
@@ -100,7 +106,7 @@ export class HttpService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private delete<T>(request: RequestObj) {
|
delete<T>(request: RequestObj) {
|
||||||
return this.httpClient.delete<T>(request.url,
|
return this.httpClient.delete<T>(request.url,
|
||||||
{
|
{
|
||||||
headers: request.header,
|
headers: request.header,
|
||||||
|
|||||||
@@ -11,17 +11,15 @@ const routes: Routes = [
|
|||||||
{path: 'resetPwd', loadChildren: () => import('./view/reset-pwd/reset-pwd.module').then(mod => mod.ResetPwdModule)},
|
{path: 'resetPwd', loadChildren: () => import('./view/reset-pwd/reset-pwd.module').then(mod => mod.ResetPwdModule)},
|
||||||
{path: 'write', loadChildren: () => import('./view/write/write.module').then(mod => mod.WriteModule)},
|
{path: 'write', loadChildren: () => import('./view/write/write.module').then(mod => mod.WriteModule)},
|
||||||
{path: 'links', loadChildren: () => import('./view/link/link.module').then(mod => mod.LinkModule)},
|
{path: 'links', loadChildren: () => import('./view/link/link.module').then(mod => mod.LinkModule)},
|
||||||
|
{path: 'admin', loadChildren: () => import('./view/admin/admin.module').then(mod => mod.AdminModule)},
|
||||||
|
{path: 'maintain', loadChildren: () => import('./view/maintain/maintain.module').then(mod => mod.MaintainModule)},
|
||||||
{
|
{
|
||||||
path: 'emailVerify',
|
path: 'emailVerify',
|
||||||
loadChildren: () => import('./view/email-verify/email-verify.module').then(mod => mod.EmailVerifyModule)
|
loadChildren: () => import('./view/email-verify/email-verify.module').then(mod => mod.EmailVerifyModule)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'user', loadChildren: () => import('./view/login-registration/login-registration.module')
|
path: 'user',
|
||||||
.then(mod => mod.LoginRegistrationModule)
|
loadChildren: () => import('./view/login-registration/login-registration.module').then(mod => mod.LoginRegistrationModule)
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'admin',
|
|
||||||
loadChildren: () => import('./view/admin/admin.module').then(mod => mod.AdminModule),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '**',
|
path: '**',
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {NgModule} from '@angular/core';
|
import {forwardRef, NgModule} from '@angular/core';
|
||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
import {NgZorroAntdModule, NZ_I18N, zh_CN} from 'ng-zorro-antd';
|
import {NgZorroAntdModule, NZ_I18N, zh_CN} from 'ng-zorro-antd';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
@@ -14,6 +14,12 @@ import {LoginRegistrationModule} from './view/login-registration/login-registrat
|
|||||||
import {AdminModule} from './view/admin/admin.module';
|
import {AdminModule} from './view/admin/admin.module';
|
||||||
import {ServiceWorkerModule} from '@angular/service-worker';
|
import {ServiceWorkerModule} from '@angular/service-worker';
|
||||||
import {environment} from '../environments/environment';
|
import {environment} from '../environments/environment';
|
||||||
|
import {HttpService} from './api/http/http.service';
|
||||||
|
import {ErrorService} from './services/error.service';
|
||||||
|
import {ComponentStateService} from './services/component-state.service';
|
||||||
|
import {GlobalUserService} from './services/global-user.service';
|
||||||
|
import {LocalStorageService} from './services/local-storage.service';
|
||||||
|
import {ApiService} from './api/api.service';
|
||||||
|
|
||||||
|
|
||||||
registerLocaleData(zh);
|
registerLocaleData(zh);
|
||||||
@@ -35,7 +41,15 @@ registerLocaleData(zh);
|
|||||||
AdminModule,
|
AdminModule,
|
||||||
ServiceWorkerModule.register('ngsw-worker.js', {enabled: environment.production})
|
ServiceWorkerModule.register('ngsw-worker.js', {enabled: environment.production})
|
||||||
],
|
],
|
||||||
providers: [{provide: NZ_I18N, useValue: zh_CN}],
|
providers: [
|
||||||
|
ComponentStateService,
|
||||||
|
GlobalUserService,
|
||||||
|
LocalStorageService,
|
||||||
|
HttpService,
|
||||||
|
ApiService,
|
||||||
|
ErrorService,
|
||||||
|
{provide: NZ_I18N, useValue: zh_CN},
|
||||||
|
],
|
||||||
exports: [],
|
exports: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
import {RequestObj} from './HttpReqAndResp';
|
|
||||||
|
|
||||||
export interface ErrDispatch {
|
|
||||||
errHandler(code: number, msg: string, request?: RequestObj): void;
|
|
||||||
}
|
|
||||||
@@ -37,7 +37,8 @@ export class HeaderComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
// 订阅一级路由的变化
|
// 订阅一级路由的变化
|
||||||
componentStateService.watchRouterChange().subscribe(prefix => {
|
componentStateService.watchRouterChange().subscribe(prefix => {
|
||||||
if (prefix === '/user' || prefix === '/write' || prefix === '/update') {
|
// TODO:: 使用service来获取 size
|
||||||
|
if (prefix === '/user' || prefix === '/write' || prefix === '/update' || prefix === '/maintain') {
|
||||||
this.size = 'default';
|
this.size = 'default';
|
||||||
} else {
|
} else {
|
||||||
this.size = 'large';
|
this.size = 'large';
|
||||||
|
|||||||
59
src/app/services/error.service.ts
Normal file
59
src/app/services/error.service.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import {RequestObj, Response} from '../class/HttpReqAndResp';
|
||||||
|
import {HttpService} from '../api/http/http.service';
|
||||||
|
import {environment} from '../../environments/environment';
|
||||||
|
import {Router} from '@angular/router';
|
||||||
|
import {ComponentStateService} from './component-state.service';
|
||||||
|
import {NzNotificationService} from 'ng-zorro-antd';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ErrorService {
|
||||||
|
|
||||||
|
constructor(private httpService: HttpService, private router: Router,
|
||||||
|
private componentStateService: ComponentStateService,
|
||||||
|
private notification: NzNotificationService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HTTP_ERROR_COUNT: number = 0;
|
||||||
|
private readonly MAINTAIN_PAGE_PREFIX = '/maintain'
|
||||||
|
private readonly ADMIN_PAGE_PREFIX = '/admin'
|
||||||
|
|
||||||
|
public httpError(err: any) {
|
||||||
|
if (!environment.production) {
|
||||||
|
console.log('error=>', err)
|
||||||
|
}
|
||||||
|
ErrorService.HTTP_ERROR_COUNT++;
|
||||||
|
// this.httpService.getSubscriptionQueue().map(a => a.unsubscribe())
|
||||||
|
}
|
||||||
|
|
||||||
|
public httpException(response: Response<any>) {
|
||||||
|
if (!environment.production)
|
||||||
|
console.log('exception=>', response)
|
||||||
|
if (response.code === -1 && response.msg === '重复请求') return
|
||||||
|
if (this.componentStateService.currentPath === this.ADMIN_PAGE_PREFIX) {
|
||||||
|
this.notification.create('error', `请求失败<${response.code}>`, `${response.msg}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public checkConnection() {
|
||||||
|
// The HTTP_ERROR_COUNT is start with 1 in this function
|
||||||
|
if (ErrorService.HTTP_ERROR_COUNT === 1) {
|
||||||
|
const req: RequestObj = {
|
||||||
|
path: '/headerInfo',
|
||||||
|
method: 'GET',
|
||||||
|
url: environment.host + '/headerInfo'
|
||||||
|
}
|
||||||
|
this.httpService.get(req).subscribe({
|
||||||
|
next: () => null,
|
||||||
|
error: () => {
|
||||||
|
if (this.componentStateService.currentPath !== this.MAINTAIN_PAGE_PREFIX) {
|
||||||
|
this.router.navigateByUrl(this.MAINTAIN_PAGE_PREFIX)
|
||||||
|
}
|
||||||
|
ErrorService.HTTP_ERROR_COUNT = 0;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
[headData]="headData"
|
[headData]="headData"
|
||||||
[template]="{open:{temp:open,param:{true:'可见',false:'不可见'}},delete:{temp:deleteTemp,param:{true:'已删除',false:'未删除'}}}"
|
[template]="{open:{temp:open,param:{true:'可见',false:'不可见'}},delete:{temp:deleteTemp,param:{true:'已删除',false:'未删除'}}}"
|
||||||
>
|
>
|
||||||
|
<button nz-button (click)="addLink()">添加</button>
|
||||||
</common-table>
|
</common-table>
|
||||||
|
|
||||||
<ng-template #open let-value="value">
|
<ng-template #open let-value="value">
|
||||||
|
|||||||
@@ -3,7 +3,15 @@ import {CommonModule} from '@angular/common';
|
|||||||
import {RouterModule} from '@angular/router';
|
import {RouterModule} from '@angular/router';
|
||||||
import {AdminLinkComponent} from './admin-link.component';
|
import {AdminLinkComponent} from './admin-link.component';
|
||||||
import {CommonTableModule} from '../components/common-table/common-table.module';
|
import {CommonTableModule} from '../components/common-table/common-table.module';
|
||||||
import {NzCheckboxModule, NzFormModule, NzInputModule, NzModalModule, NzSelectModule, NzTagModule} from 'ng-zorro-antd';
|
import {
|
||||||
|
NzButtonModule,
|
||||||
|
NzCheckboxModule,
|
||||||
|
NzFormModule,
|
||||||
|
NzInputModule,
|
||||||
|
NzModalModule,
|
||||||
|
NzSelectModule,
|
||||||
|
NzTagModule
|
||||||
|
} from 'ng-zorro-antd';
|
||||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
|
|
||||||
|
|
||||||
@@ -23,6 +31,7 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
|||||||
NzInputModule,
|
NzInputModule,
|
||||||
NzSelectModule,
|
NzSelectModule,
|
||||||
NzTagModule,
|
NzTagModule,
|
||||||
|
NzButtonModule,
|
||||||
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,11 +3,9 @@ import {ApiService} from '../../api/api.service';
|
|||||||
import {Article} from '../../class/Article';
|
import {Article} from '../../class/Article';
|
||||||
import {NzIconService, NzMessageService} from 'ng-zorro-antd';
|
import {NzIconService, NzMessageService} from 'ng-zorro-antd';
|
||||||
import {SvgIconUtil} from '../../utils/svgIconUtil';
|
import {SvgIconUtil} from '../../utils/svgIconUtil';
|
||||||
import {PageList} from '../../class/HttpReqAndResp';
|
import {PageList, RequestObj} from '../../class/HttpReqAndResp';
|
||||||
import {ErrDispatch} from '../../class/ErrDispatch';
|
|
||||||
import {RequestObj} from '../../class/HttpReqAndResp';
|
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {Category, Tag} from '../../class/Tag';
|
import {Category} from '../../class/Tag';
|
||||||
import {Title} from '@angular/platform-browser';
|
import {Title} from '@angular/platform-browser';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -16,7 +14,7 @@ import {Title} from '@angular/platform-browser';
|
|||||||
styleUrls: ['./index.component.less'],
|
styleUrls: ['./index.component.less'],
|
||||||
providers: [ApiService]
|
providers: [ApiService]
|
||||||
})
|
})
|
||||||
export class IndexComponent implements OnInit, ErrDispatch {
|
export class IndexComponent implements OnInit {
|
||||||
|
|
||||||
constructor(private apiService: ApiService,
|
constructor(private apiService: ApiService,
|
||||||
private iconService: NzIconService,
|
private iconService: NzIconService,
|
||||||
@@ -24,7 +22,6 @@ export class IndexComponent implements OnInit, ErrDispatch {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private title: Title) {
|
private title: Title) {
|
||||||
this.iconService.addIconLiteral('blog:location', SvgIconUtil.locationIcon);
|
this.iconService.addIconLiteral('blog:location', SvgIconUtil.locationIcon);
|
||||||
apiService.setErrDispatch(this);
|
|
||||||
title.setTitle('小海博客');
|
title.setTitle('小海博客');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {environment} from '../../../../../environments/environment';
|
|||||||
import {ApiService} from '../../../../api/api.service';
|
import {ApiService} from '../../../../api/api.service';
|
||||||
import {NzMessageService} from 'ng-zorro-antd';
|
import {NzMessageService} from 'ng-zorro-antd';
|
||||||
import {Router} from '@angular/router';
|
import {Router} from '@angular/router';
|
||||||
import {ErrDispatch} from '../../../../class/ErrDispatch';
|
|
||||||
import {RequestObj} from '../../../../class/HttpReqAndResp';
|
import {RequestObj} from '../../../../class/HttpReqAndResp';
|
||||||
import {LoginReq} from '../../../../class/User';
|
import {LoginReq} from '../../../../class/User';
|
||||||
import {Title} from '@angular/platform-browser';
|
import {Title} from '@angular/platform-browser';
|
||||||
@@ -14,13 +13,12 @@ import {Title} from '@angular/platform-browser';
|
|||||||
styleUrls: ['./registration.component.less'],
|
styleUrls: ['./registration.component.less'],
|
||||||
providers: [ApiService]
|
providers: [ApiService]
|
||||||
})
|
})
|
||||||
export class RegistrationComponent implements OnInit, ErrDispatch {
|
export class RegistrationComponent implements OnInit {
|
||||||
|
|
||||||
constructor(private apiService: ApiService,
|
constructor(private apiService: ApiService,
|
||||||
private nzMessageService: NzMessageService,
|
private nzMessageService: NzMessageService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private title: Title) {
|
private title: Title) {
|
||||||
apiService.setErrDispatch(this);
|
|
||||||
this.title.setTitle('小海博客 | 注册');
|
this.title.setTitle('小海博客 | 注册');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
src/app/view/maintain/maintain.component.html
Normal file
5
src/app/view/maintain/maintain.component.html
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<nz-result nzStatus="500" nzTitle="暂时无法连接到后台服务器,可能正在维护更新">
|
||||||
|
<div nz-result-extra>
|
||||||
|
<button nz-button nzType="primary" routerLink="/">返回首页</button>
|
||||||
|
</div>
|
||||||
|
</nz-result>
|
||||||
0
src/app/view/maintain/maintain.component.less
Normal file
0
src/app/view/maintain/maintain.component.less
Normal file
16
src/app/view/maintain/maintain.component.ts
Normal file
16
src/app/view/maintain/maintain.component.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-maintain',
|
||||||
|
templateUrl: './maintain.component.html',
|
||||||
|
styleUrls: ['./maintain.component.less']
|
||||||
|
})
|
||||||
|
export class MaintainComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
18
src/app/view/maintain/maintain.module.ts
Normal file
18
src/app/view/maintain/maintain.module.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import {NgModule} from '@angular/core';
|
||||||
|
import {CommonModule} from '@angular/common';
|
||||||
|
import {MaintainComponent} from './maintain.component';
|
||||||
|
import {RouterModule} from '@angular/router';
|
||||||
|
import {NzButtonModule, NzResultModule} from 'ng-zorro-antd';
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [MaintainComponent],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
RouterModule.forChild([{path: '', component: MaintainComponent}]),
|
||||||
|
NzResultModule,
|
||||||
|
NzButtonModule
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class MaintainModule {
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user