From 33d7bbaf43f4dd9f4e38711a16093e5937c14051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BE=E5=87=A0=E6=B5=B7?= Date: Fri, 12 Mar 2021 16:11:09 +0800 Subject: [PATCH] style: eslint fix --- src/app/api/api.service.ts | 24 +++++----- src/app/api/http/http.service.ts | 5 +- src/app/class/Link.ts | 2 +- src/app/class/User.ts | 2 +- .../admin-header/admin-header.component.ts | 8 ++-- src/app/components/header/header.component.ts | 4 +- src/app/services/component-state.service.ts | 24 +++++----- src/app/services/error.service.ts | 16 +++---- src/app/services/global-user.service.ts | 26 +++++------ src/app/utils/color.ts | 11 +++-- src/app/utils/dataUtil.ts | 3 +- .../admin-article/admin-article.component.ts | 16 +++---- .../admin-comment/admin-comment.component.ts | 24 +++++----- .../admin-dashboard.component.ts | 22 ++++----- .../admin/admin-link/admin-link.component.ts | 27 +++++++---- .../admin/admin-tag/admin-tag.component.ts | 36 +++++++-------- .../admin-update/admin-update.component.ts | 14 +++--- .../admin/admin-user/admin-user.component.ts | 14 +++--- .../admin-visitor/admin-visitor.component.ts | 8 ++-- src/app/view/admin/admin.component.ts | 38 +++++++-------- src/app/view/admin/auth.guard.ts | 4 +- .../common-table/common-table.component.ts | 46 +++++++++---------- .../common-table/common-table.module.ts | 2 +- .../admin/components/common-table/data.ts | 22 ++++----- .../editable-tag/editable-tag.component.ts | 22 ++++----- .../test-common-table.component.ts | 4 +- src/app/view/article/article.component.ts | 6 +-- .../components/tag-tag/tag-tag.component.ts | 4 +- src/app/view/index/index.component.ts | 14 +++--- src/app/view/link/link.component.ts | 8 ++-- .../components/login/login.component.ts | 2 +- src/app/view/tag/tag.component.ts | 6 +-- src/app/view/update/update.component.ts | 4 +- .../publish-form/publish-form.component.ts | 26 ++++++----- src/app/view/write/write.component.ts | 22 ++++----- 35 files changed, 262 insertions(+), 254 deletions(-) diff --git a/src/app/api/api.service.ts b/src/app/api/api.service.ts index 61436d3..2641b92 100644 --- a/src/app/api/api.service.ts +++ b/src/app/api/api.service.ts @@ -33,7 +33,7 @@ export class ApiService { path: '/admin/article/del', method: 'DELETE', queryParam: {articleID: id} - }) + }); } articles(pageNumber: number = 1, pageSize: number = 5) { @@ -140,7 +140,7 @@ export class ApiService { } tagsNac() { - return this.httpService.Service<{ name: string, size: number }[]>({ + return this.httpService.Service<{ name: string; size: number }[]>({ path: '/tags/nac', method: 'GET' }); @@ -232,11 +232,11 @@ export class ApiService { counts() { return this.httpService.Service<{ - articleCount: number, - visitorCount: number, - categoryCount: number, - tagCount: number, - commentCount: number + articleCount: number; + visitorCount: number; + categoryCount: number; + tagCount: number; + commentCount: number; }>({ path: '/counts', method: 'GET' @@ -394,7 +394,7 @@ export class ApiService { method: 'PUT', data: user, contentType: 'application/json' - }) + }); } deleteUser(id: number) { @@ -418,7 +418,7 @@ export class ApiService { return this.httpService.Service({ path: `/emailStatus/${email}`, method: 'GET' - }) + }); } updateUserInfo(descStr: string, disPlayNameStr: string) { @@ -491,14 +491,14 @@ export class ApiService { } webUpdate() { - return this.httpService.Service<{ id: number, info: string, time: string }[]>({ + return this.httpService.Service<{ id: number; info: string; time: string }[]>({ path: '/webUpdate', method: 'GET' }); } webUpdatePage(pageSize: number = 10, pageNumber: number = 1) { - return this.httpService.Service>({ + return this.httpService.Service>({ path: '/webUpdate/pages', method: 'GET', queryParam: { @@ -515,7 +515,7 @@ export class ApiService { lastCommit: string; committerAuthor: string; committerDate: string; - commitUrl: string + commitUrl: string; }>({ path: '/lastestUpdate', method: 'GET' diff --git a/src/app/api/http/http.service.ts b/src/app/api/http/http.service.ts index bc5fdd2..4d94bbc 100644 --- a/src/app/api/http/http.service.ts +++ b/src/app/api/http/http.service.ts @@ -62,7 +62,7 @@ export class HttpService { } if (o.body.code !== 0) { observer.error(o.body); - errorService.httpException(o.body, request) + errorService.httpException(o.body, request); } else { observer.next(o.body); } @@ -71,7 +71,7 @@ export class HttpService { error: err => { errorService.httpError(err, request); errorService.checkConnection(); - this.subscriptionQueue.splice(this.subscriptionQueue.indexOf(subscription), 1) + this.subscriptionQueue.splice(this.subscriptionQueue.indexOf(subscription), 1); }, complete: () => this.subscriptionQueue.splice(this.subscriptionQueue.indexOf(subscription), 1) }); @@ -117,6 +117,7 @@ export class HttpService { /** * 验证并且处理拼接 URl + * * @param req Request */ private checkUrl(req: RequestObj): string { diff --git a/src/app/class/Link.ts b/src/app/class/Link.ts index 7a74650..16ca04c 100644 --- a/src/app/class/Link.ts +++ b/src/app/class/Link.ts @@ -14,5 +14,5 @@ export class ApplyLinkReq { iconPath: string; linkUrl: string; name: string; - url: string + url: string; } diff --git a/src/app/class/User.ts b/src/app/class/User.ts index d15d989..2b41d3b 100644 --- a/src/app/class/User.ts +++ b/src/app/class/User.ts @@ -8,7 +8,7 @@ export class User { role?: string; token?: string; pwd?: string; - recentlyLandedDate?: string + recentlyLandedDate?: string; } export class LoginReq { diff --git a/src/app/components/admin-header/admin-header.component.ts b/src/app/components/admin-header/admin-header.component.ts index cd4d6c8..99d6df7 100644 --- a/src/app/components/admin-header/admin-header.component.ts +++ b/src/app/components/admin-header/admin-header.component.ts @@ -12,9 +12,9 @@ export class AdminHeaderComponent implements OnInit { constructor(private userService: GlobalUserService) { } - user: User - @Output() infoClicked = new EventEmitter() - noAvatarUrl = 'https://cdn.celess.cn/' + user: User; + @Output() infoClicked = new EventEmitter(); + noAvatarUrl = 'https://cdn.celess.cn/'; logout = () => this.userService.logout(); infoClickedEvent = () => this.infoClicked.emit(); @@ -23,7 +23,7 @@ export class AdminHeaderComponent implements OnInit { next: data => this.user = data.result, error: err => this.user = null, complete: null - }) + }); } } diff --git a/src/app/components/header/header.component.ts b/src/app/components/header/header.component.ts index 34de1e8..4caf56e 100644 --- a/src/app/components/header/header.component.ts +++ b/src/app/components/header/header.component.ts @@ -50,7 +50,7 @@ export class HeaderComponent implements OnInit { @Output() registrationEvent = new EventEmitter(); size: 'large' | 'default'; currentPath: string; - noAvatarUrl = 'https://cdn.celess.cn/' + noAvatarUrl = 'https://cdn.celess.cn/'; public pageList: { path: string; @@ -137,7 +137,7 @@ export class HeaderComponent implements OnInit { } toAdminPage() { - this.router.navigateByUrl('/admin') + this.router.navigateByUrl('/admin'); } } diff --git a/src/app/services/component-state.service.ts b/src/app/services/component-state.service.ts index 57878eb..7e89d2c 100644 --- a/src/app/services/component-state.service.ts +++ b/src/app/services/component-state.service.ts @@ -9,16 +9,16 @@ import {Observable, of, Subscriber} from 'rxjs'; export class ComponentStateService { constructor(private router: Router) { - this.watchRouterChange() + this.watchRouterChange(); } visible = { header: true, footer: true, globalBackToTop: true - } + }; - currentPath: string + currentPath: string; getCurrentRouterPath = () => this.currentPath; watchRouterChange() { @@ -31,9 +31,9 @@ export class ComponentStateService { // lastIndexOf ==> 0/index const indexOf = path.lastIndexOf('/'); const prefix = path.substr(0, indexOf === 0 ? path.length : indexOf); - this.dealWithPathChange(prefix) + this.dealWithPathChange(prefix); this.currentPath = prefix; - if (subscriber) subscriber.next(prefix) + if (subscriber) {subscriber.next(prefix);} }); return ob; } @@ -41,18 +41,18 @@ export class ComponentStateService { private dealWithPathChange(path) { // eslint-disable-next-line guard-for-in for (const visibleKey in this.visible) { - this.visible[visibleKey] = true + this.visible[visibleKey] = true; } switch (path) { case '/admin': - this.visible.header = false - this.visible.footer = false - this.visible.globalBackToTop = false - break + this.visible.header = false; + this.visible.footer = false; + this.visible.globalBackToTop = false; + break; case '/user': case '/write': - this.visible.footer = false - this.visible.globalBackToTop = false + this.visible.footer = false; + this.visible.globalBackToTop = false; break; default: diff --git a/src/app/services/error.service.ts b/src/app/services/error.service.ts index 878c153..646232c 100644 --- a/src/app/services/error.service.ts +++ b/src/app/services/error.service.ts @@ -21,12 +21,12 @@ export class ErrorService { } private static HTTP_ERROR_COUNT: number = 0; - private readonly MAINTAIN_PAGE_PREFIX = '/maintain' - private readonly ADMIN_PAGE_PREFIX = '/admin' + private readonly MAINTAIN_PAGE_PREFIX = '/maintain'; + private readonly ADMIN_PAGE_PREFIX = '/admin'; public httpError(err: any, request: RequestObj) { if (!environment.production) { - console.log('error=>', err, request) + console.log('error=>', err, request); } ErrorService.HTTP_ERROR_COUNT++; // this.httpService.getSubscriptionQueue().map(a => a.unsubscribe()) @@ -34,8 +34,8 @@ export class ErrorService { public httpException(response: Response, request: RequestObj) { if (!environment.production) - console.log('exception=>', response, request) - if (response.code === -1 && response.msg === '重复请求') return + {console.log('exception=>', response, request);} + if (response.code === -1 && response.msg === '重复请求') {return;} if (this.componentStateService.currentPath === this.ADMIN_PAGE_PREFIX) { this.notification.create('error', `请求失败<${response.code}>`, `${response.msg}`); } @@ -62,16 +62,16 @@ export class ErrorService { path: '/headerInfo', method: 'GET', url: environment.host + '/headerInfo' - } + }; this.injector.get(HttpService).get(req).subscribe({ next: () => null, error: () => { if (this.componentStateService.currentPath !== this.MAINTAIN_PAGE_PREFIX) { - this.router.navigateByUrl(this.MAINTAIN_PAGE_PREFIX) + this.router.navigateByUrl(this.MAINTAIN_PAGE_PREFIX); } ErrorService.HTTP_ERROR_COUNT = 0; } - }) + }); } } } diff --git a/src/app/services/global-user.service.ts b/src/app/services/global-user.service.ts index d7f037a..7f723a8 100644 --- a/src/app/services/global-user.service.ts +++ b/src/app/services/global-user.service.ts @@ -23,24 +23,24 @@ export class GlobalUserService { private multicastArray: Observer>[] = []; watchUserInfo(observer: Observer>) { - if (this.userObserverArray.indexOf(observer) < 0) this.userObserverArray.push(observer); + if (this.userObserverArray.indexOf(observer) < 0) {this.userObserverArray.push(observer);} this.multicastArray = [...this.userObserverArray]; let subscription: Subscription = null; const unsubscribe = () => { this.userObserverArray.splice(this.userObserverArray.indexOf(observer), 1); observer.complete(); - if (subscription) subscription.unsubscribe(); + if (subscription) {subscription.unsubscribe();} }; if (this.lastRequestTime && Date.now() - this.lastRequestTime < 3000) { if (this.userInfo && this.multicastArray.length) { - this.broadcast() + this.broadcast(); this.lastRequestTime = Date.now(); } - return {unsubscribe} + return {unsubscribe}; } // 获取数据 subscription = this.getUserInfoFromServer(); - return {unsubscribe} + return {unsubscribe}; } // 刷新用户信息 @@ -59,7 +59,7 @@ export class GlobalUserService { // this.localStorageService.setUser(o.result); // this.userObserver.next(o); this.userInfo = o.result; - this.broadcast() + this.broadcast(); observer.next(o); observer.complete(); }, @@ -82,7 +82,7 @@ export class GlobalUserService { // 如果不需要返回消息也ok this.apiService.logout().subscribe(data => { this.localStorageService.clear(); - this.broadcast() + this.broadcast(); if (observer) { observer.next(data); observer.complete(); @@ -93,7 +93,7 @@ export class GlobalUserService { observer.error(error); observer.complete(); } - }) + }); } getUserInfoFromServer(observer?: Observer>) { @@ -102,7 +102,7 @@ export class GlobalUserService { this.lastRequestTime = Date.now(); this.userInfo = o.result; // this.localStorageService.setUser(o.result); - this.broadcast() + this.broadcast(); if (observer) { observer.next(o); observer.complete(); @@ -118,12 +118,12 @@ export class GlobalUserService { if (err.code === -1) { // 请求重复 - return + return; } // this.requested = false; // this.localStorageService.removeToken(); - this.multicastArray.forEach(ob => ob.next(new Response(this.userInfo))) - this.multicastArray.forEach(ob => ob.error(err)) + this.multicastArray.forEach(ob => ob.next(new Response(this.userInfo))); + this.multicastArray.forEach(ob => ob.error(err)); this.multicastArray.splice(0, this.multicastArray.length); } @@ -131,7 +131,7 @@ export class GlobalUserService { } private broadcast() { - this.multicastArray.forEach(ob => ob.next(new Response(this.userInfo))) + this.multicastArray.forEach(ob => ob.next(new Response(this.userInfo))); this.multicastArray.splice(0, this.multicastArray.length); } } diff --git a/src/app/utils/color.ts b/src/app/utils/color.ts index 7f9773c..fdcb973 100644 --- a/src/app/utils/color.ts +++ b/src/app/utils/color.ts @@ -1,6 +1,6 @@ export class Color { bgColor: string; - fontColor: string + fontColor: string; } export const ColorList: Color[] = [ @@ -13,23 +13,24 @@ export const ColorList: Color[] = [ {bgColor: '#177cb0', fontColor: '#ffffff'}, // 靛青 ]; -export const ColorListLength = ColorList.length +export const ColorListLength = ColorList.length; /** * 获取一组随机颜色 + * * @param count 数量 */ export function RandomColor(count: number = 1): Color[] { const map = new Map(); - ColorList.forEach((color, index) => map.set(index, 0)) + ColorList.forEach((color, index) => map.set(index, 0)); const colorArray: Color[] = []; const oneRandomColor = () => { - const minValue = Math.min.apply(null, Array.from(map.values())) + const minValue = Math.min.apply(null, Array.from(map.values())); const keys = Array.from(map.keys()).filter(key => map.get(key) === minValue); const keyIndex = Math.floor(Math.random() * keys.length); const index = keys[keyIndex]; map.set(index, minValue + 1); - return ColorList[index] + return ColorList[index]; }; for (let i = 0; i < count; i++) { colorArray.push(oneRandomColor()); diff --git a/src/app/utils/dataUtil.ts b/src/app/utils/dataUtil.ts index 98b5657..6edbe83 100644 --- a/src/app/utils/dataUtil.ts +++ b/src/app/utils/dataUtil.ts @@ -3,6 +3,7 @@ import {PageList} from '../class/HttpReqAndResp'; /** * 判断 一个Page[] 中是否存在一条已查询的数据 + * * @param pageNum 页码 * @param pageSize 单页数量 * @param pageList 源数据 @@ -19,7 +20,7 @@ export function exist(pageNum: number, pageSize: number, pageList: PageList> = new Observable(o => { o.next(pageList[i]); o.complete(); - }) + }); } } return null; diff --git a/src/app/view/admin/admin-article/admin-article.component.ts b/src/app/view/admin/admin-article/admin-article.component.ts index 62693c1..1638ff3 100644 --- a/src/app/view/admin/admin-article/admin-article.component.ts +++ b/src/app/view/admin/admin-article/admin-article.component.ts @@ -15,8 +15,8 @@ import {Router} from '@angular/router'; export class AdminArticleComponent implements OnInit { request: RequestObj; - headData: Data
[] - @ViewChild('commonTableComponent') private commonTableComponent: CommonTableComponent
+ headData: Data
[]; + @ViewChild('commonTableComponent') private commonTableComponent: CommonTableComponent
; constructor(private apiService: ApiService, private nzMessage: NzMessageService, private title: Title, private router: Router) { @@ -27,11 +27,11 @@ export class AdminArticleComponent implements OnInit { page: 1, count: 10 } - } + }; } ngOnInit(): void { - this.title.setTitle('小海博客 | 文章管理') + this.title.setTitle('小海博客 | 文章管理'); this.headData = [ {title: '主键', fieldValue: 'id', show: false, primaryKey: true}, {title: '标题', fieldValue: 'title', show: true}, @@ -54,18 +54,18 @@ export class AdminArticleComponent implements OnInit { {name: '编辑', color: '#2db7f5', click: (d) => this.router.navigateByUrl(`/write?id=${d.id}`)}, ] } - ] + ]; } deleteArticle(article: Article) { this.apiService.deleteArticle(article.id).subscribe({ next: data => { - this.nzMessage.success('删除成功') + this.nzMessage.success('删除成功'); this.commonTableComponent.getData(); }, error: err => { - this.nzMessage.error(err.msg) + this.nzMessage.error(err.msg); } - }) + }); } } diff --git a/src/app/view/admin/admin-comment/admin-comment.component.ts b/src/app/view/admin/admin-comment/admin-comment.component.ts index 426b9c3..f431828 100644 --- a/src/app/view/admin/admin-comment/admin-comment.component.ts +++ b/src/app/view/admin/admin-comment/admin-comment.component.ts @@ -19,26 +19,26 @@ export class AdminCommentComponent implements OnInit { editInfo = { id: null, content: new CommentReq(null), - } + }; headData: Data[]; modalData = { visible: false, comment: null - } + }; @ViewChild('editableTagComponent') editableTagComponent: EditableTagComponent; @ViewChild('commonTableComponent') commonTableComponent: CommonTableComponent; constructor(private apiService: ApiService, private messageService: NzMessageService, private userService: GlobalUserService, private title: Title) { - this.title.setTitle('小海博客 | 评论管理') + this.title.setTitle('小海博客 | 评论管理'); this.userService.watchUserInfo({ next: data => { let pathStr; if (data.result) { if (data.result.role === 'admin') { - pathStr = '/admin/comment/pagePath/*' + pathStr = '/admin/comment/pagePath/*'; } else { - pathStr = '/user/comment/pagePath/*' + pathStr = '/user/comment/pagePath/*'; } this.request = { path: pathStr, @@ -47,12 +47,12 @@ export class AdminCommentComponent implements OnInit { page: 1, count: 10 } - } + }; } }, error: () => null, complete: () => null - }) + }); } ngOnInit(): void { @@ -74,7 +74,7 @@ export class AdminCommentComponent implements OnInit { { name: '查看', click: data => { - this.modalData.visible = true + this.modalData.visible = true; this.modalData.comment = data; } }, @@ -88,13 +88,13 @@ export class AdminCommentComponent implements OnInit { deleteComment(data: Comment) { if (data.status === 3) { this.messageService.error('该数据已被删除'); - return + return; } this.apiService.deleteComment(data.id).subscribe({ next: () => this.messageService.success('删除评论成功'), error: err => this.messageService.error(err.msg), complete: () => this.commonTableComponent.getData() - }) + }); } edit() { @@ -106,7 +106,7 @@ export class AdminCommentComponent implements OnInit { this.messageService.success(err.msg); }, complete: () => null - }) + }); } textChange(value: { value: string; originalValue: string; changed: boolean }, data: Comment) { @@ -115,7 +115,7 @@ export class AdminCommentComponent implements OnInit { this.editInfo.content.pid = data.pid; this.editInfo.content.id = data.id; this.editInfo.content.content = value.value; - this.edit() + this.edit(); } } } diff --git a/src/app/view/admin/admin-dashboard/admin-dashboard.component.ts b/src/app/view/admin/admin-dashboard/admin-dashboard.component.ts index 41eaa25..182e6a1 100644 --- a/src/app/view/admin/admin-dashboard/admin-dashboard.component.ts +++ b/src/app/view/admin/admin-dashboard/admin-dashboard.component.ts @@ -14,12 +14,12 @@ export class AdminDashboardComponent implements OnInit { logLoading: boolean = true; logText: string = null; counts: { - articleCount: number, - visitorCount: number, - categoryCount: number, - tagCount: number, - commentCount: number - } = {articleCount: 0, visitorCount: 0, categoryCount: 0, tagCount: 0, commentCount: 0} + articleCount: number; + visitorCount: number; + categoryCount: number; + tagCount: number; + commentCount: number; + } = {articleCount: 0, visitorCount: 0, categoryCount: 0, tagCount: 0, commentCount: 0}; dayVisitCount: number = 0; userInfo: User = new User(); private isRequested: boolean = false; @@ -36,21 +36,21 @@ export class AdminDashboardComponent implements OnInit { getLog() { this.http.get('https://api.celess.cn/blog.log', {responseType: 'text'}).subscribe(data => { this.logText = data; - this.logLoading = false + this.logLoading = false; }); } getCounts = () => this.apiService.counts().subscribe({ next: data => this.counts = data.result - }) + }); getDayVisitCount = () => this.apiService.dayVisitCount().subscribe({ next: data => this.dayVisitCount = data.result - }) + }); getUserInfo = () => this.userService.watchUserInfo({ next: data => { - this.userInfo = data.result + this.userInfo = data.result; if (data.result && data.result.role === 'admin' && !this.isRequested) { this.getLog(); this.getCounts(); @@ -60,5 +60,5 @@ export class AdminDashboardComponent implements OnInit { }, error: () => null, complete: () => null - }) + }); } diff --git a/src/app/view/admin/admin-link/admin-link.component.ts b/src/app/view/admin/admin-link/admin-link.component.ts index 4474e6a..407d1b8 100644 --- a/src/app/view/admin/admin-link/admin-link.component.ts +++ b/src/app/view/admin/admin-link/admin-link.component.ts @@ -19,7 +19,7 @@ export class AdminLinkComponent implements OnInit { modalTitle: string = ''; formGroup: FormGroup; request: RequestObj; - @ViewChild('commonTableComponent') commonTableComponent: CommonTableComponent + @ViewChild('commonTableComponent') commonTableComponent: CommonTableComponent; headData: Data[]; constructor(private apiService: ApiService, private messageService: NzMessageService, private title: Title) { @@ -27,12 +27,19 @@ export class AdminLinkComponent implements OnInit { this.formGroup = new FormGroup({ id: new FormControl(null), name: new FormControl(null, [Validators.required]), - url: new FormControl(null, [Validators.required, Validators.pattern(/^(https:\/\/|http:\/\/|)([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$/)]), + url: new FormControl(null, [ + Validators.required, + Validators.pattern(/^(https:\/\/|http:\/\/|)([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$/) + ] + ), open: new FormControl(null, [Validators.required]), desc: new FormControl(null, [Validators.maxLength(255)]), - iconPath: new FormControl(null, [Validators.pattern(/^(https:\/\/|http:\/\/|)([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$/)]), + iconPath: new FormControl(null, [ + Validators.pattern(/^(https:\/\/|http:\/\/|)([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?$/) + ] + ), oper: new FormControl(null) - }) + }); } ngOnInit(): void { @@ -43,7 +50,7 @@ export class AdminLinkComponent implements OnInit { count: 10, page: 1 } - } + }; this.headData = [ {title: '主键', fieldValue: 'id', show: false, primaryKey: true}, {title: '友链名称', fieldValue: 'name', show: true}, @@ -72,19 +79,19 @@ export class AdminLinkComponent implements OnInit { this.messageService.error('删除失败'); }, complete: () => null, - }) + }); } showEdit(data: Link) { this.modalVisible = true; this.modalTitle = '编辑友链信息'; this.formGroup.patchValue(data); - this.formGroup.controls.oper.setValue('edit') + this.formGroup.controls.oper.setValue('edit'); } modalConfirm() { this.modalVisible = false; - const linkReq: Link = this.formGroup.value + const linkReq: Link = this.formGroup.value; const oper = this.formGroup.value.oper; let observable: Observable>; if (oper === 'edit') { @@ -97,13 +104,13 @@ export class AdminLinkComponent implements OnInit { next: data => this.messageService.success('操作成功'), error: err => this.messageService.error('操作失败,' + err.msg), complete: () => this.commonTableComponent.getData() - }) + }); } addLink() { this.modalVisible = true; this.modalTitle = '新增友链信息'; this.formGroup.reset(); - this.formGroup.controls.oper.setValue('add') + this.formGroup.controls.oper.setValue('add'); } } diff --git a/src/app/view/admin/admin-tag/admin-tag.component.ts b/src/app/view/admin/admin-tag/admin-tag.component.ts index 2c3cced..a74b055 100644 --- a/src/app/view/admin/admin-tag/admin-tag.component.ts +++ b/src/app/view/admin/admin-tag/admin-tag.component.ts @@ -15,19 +15,19 @@ import {EditableTagComponent} from '../components/editable-tag/editable-tag.comp }) export class AdminTagComponent implements OnInit { - categoryCTData: { headData: Data[], commonTable: CommonTableComponent, request: RequestObj } = { + categoryCTData: { headData: Data[]; commonTable: CommonTableComponent; request: RequestObj } = { headData: null, commonTable: null, request: null - } - tagCTData: { headData: Data[], commonTable: CommonTableComponent, request: RequestObj } = { + }; + tagCTData: { headData: Data[]; commonTable: CommonTableComponent; request: RequestObj } = { headData: null, commonTable: null, request: null - } - @ViewChild('categoryCTComponent', {static: true}) categoryCTComponent: CommonTableComponent - @ViewChild('tagCTComponent', {static: true}) tagCTComponent: CommonTableComponent - @ViewChild('editableTagComponent') editableTagComponent: EditableTagComponent + }; + @ViewChild('categoryCTComponent', {static: true}) categoryCTComponent: CommonTableComponent; + @ViewChild('tagCTComponent', {static: true}) tagCTComponent: CommonTableComponent; + @ViewChild('editableTagComponent') editableTagComponent: EditableTagComponent; getData: any; private updateData: any; @@ -35,7 +35,7 @@ export class AdminTagComponent implements OnInit { } ngOnInit(): void { - this.title.setTitle('小海博客 | 标签分类管理') + this.title.setTitle('小海博客 | 标签分类管理'); this.categoryCTData = { commonTable: this.categoryCTComponent, headData: [ @@ -64,7 +64,7 @@ export class AdminTagComponent implements OnInit { count: 1000 } } - } + }; this.tagCTData = { commonTable: this.tagCTComponent, headData: [ @@ -87,7 +87,7 @@ export class AdminTagComponent implements OnInit { count: 10 } } - } + }; this.getData = this.categoryCTComponent.getData; } @@ -96,29 +96,29 @@ export class AdminTagComponent implements OnInit { if (mode === 'tag') { this.apiService.deleteTag(id).subscribe({ next: data => { - this.nzMessageService.success('删除成功') + this.nzMessageService.success('删除成功'); this.tagCTComponent.getData(); }, complete: () => null, error: err => this.nzMessageService.error(err.msg) - }) + }); } else if (mode === 'category') { this.apiService.deleteCategory(id).subscribe({ next: data => { - this.nzMessageService.success('删除成功') + this.nzMessageService.success('删除成功'); this.categoryCTComponent.getData(); }, complete: () => null, error: err => this.nzMessageService.error(err.msg) - }) + }); } } addCategory($event: { value: string; originalValue: string; changed: boolean }) { - if (!$event.value || !$event.changed) return + if (!$event.value || !$event.changed) {return;} this.apiService.createCategory($event.value).subscribe({ next: data => { - this.nzMessageService.success('新增成功') + this.nzMessageService.success('新增成功'); this.getData = this.categoryCTComponent.getData(); }, complete: () => null, @@ -133,14 +133,14 @@ export class AdminTagComponent implements OnInit { this.updateData = this.apiService.updateTag; } else { this.getData = this.tagCTComponent.getData; - this.updateData = this.apiService.updateCategory + this.updateData = this.apiService.updateCategory; } } textChange(value: { value: string; originalValue: string; changed: boolean }, textData: Category | Tag) { this.updateData(textData.id, value.value).subscribe({ next: data => { - this.nzMessageService.success('更新成功') + this.nzMessageService.success('更新成功'); this.tagCTComponent.getData(); this.categoryCTComponent.getData(); }, diff --git a/src/app/view/admin/admin-update/admin-update.component.ts b/src/app/view/admin/admin-update/admin-update.component.ts index 91432da..aedf59f 100644 --- a/src/app/view/admin/admin-update/admin-update.component.ts +++ b/src/app/view/admin/admin-update/admin-update.component.ts @@ -27,7 +27,7 @@ export class AdminUpdateComponent implements OnInit { } ngOnInit(): void { - this.title.setTitle('小海博客 | 更新信息管理') + this.title.setTitle('小海博客 | 更新信息管理'); this.headData = [ {fieldValue: 'id', show: false, title: '主键', primaryKey: true}, {fieldValue: 'info', show: true, title: '更新内容'}, @@ -46,7 +46,7 @@ export class AdminUpdateComponent implements OnInit { count: 1, page: 10, } - } + }; } @@ -54,21 +54,21 @@ export class AdminUpdateComponent implements OnInit { this.apiService.deleteWebUpdateInfo(id).subscribe({ next: data => this.nzMessage.success('删除成功'), error: err => this.nzMessage.error(err.msg) - }) + }); } confirm() { this.modalData.visible = false; - let observable: Observable> + let observable: Observable>; if (this.modalData.id) { - observable = this.apiService.updateWebUpdateInfo(this.modalData.id, this.modalData.content) + observable = this.apiService.updateWebUpdateInfo(this.modalData.id, this.modalData.content); } else { - observable = this.apiService.createWebUpdateInfo(this.modalData.content) + observable = this.apiService.createWebUpdateInfo(this.modalData.content); } observable.subscribe({ next: data => this.nzMessage.success('操作成功'), error: err => this.nzMessage.error(err.msg) - }) + }); } showModal(data?: UpdateInfo) { diff --git a/src/app/view/admin/admin-user/admin-user.component.ts b/src/app/view/admin/admin-user/admin-user.component.ts index 655acd7..427afa0 100644 --- a/src/app/view/admin/admin-user/admin-user.component.ts +++ b/src/app/view/admin/admin-user/admin-user.component.ts @@ -20,7 +20,7 @@ export class AdminUserComponent implements OnInit { title: null, isEdit: false, resetPwd: false - } + }; formGroup: FormGroup; headData: Data[]; request: RequestObj; @@ -40,11 +40,11 @@ export class AdminUserComponent implements OnInit { next: data => this.user = data.result, error: null, complete: null - }) + }); } ngOnInit(): void { - this.title.setTitle('小海博客 | 用户管理') + this.title.setTitle('小海博客 | 用户管理'); this.request = { path: '/admin/users', method: 'GET', @@ -78,24 +78,24 @@ export class AdminUserComponent implements OnInit { this.apiService.deleteUser(id).subscribe({ next: data => this.messageService.success('删除成功'), error: err => this.messageService.error(err.msg) - }) + }); } showModal(isEdit: boolean, data: User) { this.modalData.visible = true; this.modalData.isEdit = isEdit; - this.modalData.title = isEdit ? '编辑用户' : '查看用户' + this.modalData.title = isEdit ? '编辑用户' : '查看用户'; this.formGroup.reset(); this.formGroup.patchValue(data); } modalConfirm() { - this.modalData.visible = false + this.modalData.visible = false; this.apiService.adminUpdateUser(this.formGroup.value).subscribe({ next: data => { this.messageService.success('修改用户信息成功'); this.userService.refreshUserInfo(); } - }) + }); } } diff --git a/src/app/view/admin/admin-visitor/admin-visitor.component.ts b/src/app/view/admin/admin-visitor/admin-visitor.component.ts index b99587f..0ab3b8f 100644 --- a/src/app/view/admin/admin-visitor/admin-visitor.component.ts +++ b/src/app/view/admin/admin-visitor/admin-visitor.component.ts @@ -12,13 +12,13 @@ import {Data} from '../components/common-table/data'; export class AdminVisitorComponent implements OnInit { headData: Data[]; - request: RequestObj + request: RequestObj; constructor(private apiService: ApiService, private title: Title) { } ngOnInit(): void { - this.title.setTitle('小海博客 | 访客信息管理') + this.title.setTitle('小海博客 | 访客信息管理'); this.request = { path: '/admin/visitor/page', method: 'GET', @@ -27,7 +27,7 @@ export class AdminVisitorComponent implements OnInit { page: 10, showLocation: true } - } + }; this.headData = [ {fieldValue: 'id', title: '主键', show: false, primaryKey: true}, {fieldValue: 'date', title: '访问日期', show: true}, @@ -36,6 +36,6 @@ export class AdminVisitorComponent implements OnInit { {fieldValue: 'browserName', title: '浏览器', show: true}, {fieldValue: 'browserVersion', title: '浏览器版本', show: true}, {fieldValue: 'osname', title: '系统', show: true} - ] + ]; } } diff --git a/src/app/view/admin/admin.component.ts b/src/app/view/admin/admin.component.ts index 9831522..ebd3274 100644 --- a/src/app/view/admin/admin.component.ts +++ b/src/app/view/admin/admin.component.ts @@ -25,8 +25,8 @@ export class AdminComponent implements OnInit { resetPwdModalVisible: boolean = false; editInfoFormGroup: FormGroup; resetPwdFormGroup: FormGroup; - noAvatarUrl = 'https://cdn.celess.cn/' - host: string + noAvatarUrl = 'https://cdn.celess.cn/'; + host: string; constructor(public gUserService: GlobalUserService, private apiService: ApiService, private messageService: NzMessageService, private router: Router, private localStorageService: LocalStorageService) { @@ -34,8 +34,8 @@ export class AdminComponent implements OnInit { complete: () => null, error: (err) => null, next: data => { - this.user = data.result - if (data.result) this.initHelloWords() + this.user = data.result; + if (data.result) {this.initHelloWords();} } } ); @@ -53,29 +53,25 @@ export class AdminComponent implements OnInit { Validators.required, Validators.minLength(6), Validators.maxLength(16), Validators.pattern(/^[\w_-]{6,16}$/), this.checkSamePwd() ]), - }) + }); } showInfoDrawer = () => this.infoDrawerVisible = !this.infoDrawerVisible; logout() { this.gUserService.logout(); - this.router.navigateByUrl('/') + this.router.navigateByUrl('/'); } ngOnInit(): void { this.host = environment.host; } - checkSamePwd = () => { - return (control: AbstractControl): { [key: string]: any } | null => { + checkSamePwd = () => (control: AbstractControl): { [key: string]: any } | null => { const newPwd = this.resetPwdFormGroup && this.resetPwdFormGroup.value.newPwd; return control.value !== newPwd ? {pwdNotSame: true} : null; }; - } - uploadHeader = (file: NzUploadFile): object | Observable<{}> => { - return {Authorization: this.localStorageService.getToken()} - }; + uploadHeader = (file: NzUploadFile): any | Observable<{}> => ({Authorization: this.localStorageService.getToken()}); showEditInfoModal() { this.editInfoModalVisible = true; @@ -88,7 +84,7 @@ export class AdminComponent implements OnInit { const displayName = this.editInfoFormGroup.value.displayName; this.apiService.updateUserInfo(desc, displayName).subscribe({ next: data => { - this.messageService.success('修改信息成功') + this.messageService.success('修改信息成功'); this.gUserService.refreshUserInfo(); }, error: err => { @@ -111,13 +107,13 @@ export class AdminComponent implements OnInit { error: err => { this.messageService.error('修改密码失败,' + err.msg); } - }) + }); this.resetPwdModalVisible = false; } showResetPwdModal() { this.resetPwdModalVisible = true; - this.infoDrawerVisible = false + this.infoDrawerVisible = false; } avatarUpload(info: any) { @@ -130,17 +126,17 @@ export class AdminComponent implements OnInit { private initHelloWords() { const hours = new Date().getHours(); if (hours < 6) { - this.sayHelloContent = `夜深了,注意早点休息哦!${this.user.displayName}` + this.sayHelloContent = `夜深了,注意早点休息哦!${this.user.displayName}`; } else if (hours < 10) { - this.sayHelloContent = `早上好呀!${this.user.displayName}` + this.sayHelloContent = `早上好呀!${this.user.displayName}`; } else if (hours < 14) { - this.sayHelloContent = `中午好呀!${this.user.displayName}` + this.sayHelloContent = `中午好呀!${this.user.displayName}`; } else if (hours < 19) { - this.sayHelloContent = `下午好呀!${this.user.displayName}` + this.sayHelloContent = `下午好呀!${this.user.displayName}`; } else if (hours < 22) { - this.sayHelloContent = `晚上好呀!${this.user.displayName}` + this.sayHelloContent = `晚上好呀!${this.user.displayName}`; } else { - this.sayHelloContent = `时间不早了,注意休息哦!${this.user.displayName}` + this.sayHelloContent = `时间不早了,注意休息哦!${this.user.displayName}`; } } } diff --git a/src/app/view/admin/auth.guard.ts b/src/app/view/admin/auth.guard.ts index e024553..5a7344d 100644 --- a/src/app/view/admin/auth.guard.ts +++ b/src/app/view/admin/auth.guard.ts @@ -46,7 +46,7 @@ export class AuthGuard implements CanActivate { this.userInfo = data.result; this.checkPath(observer); } - }) + }); } @@ -60,7 +60,7 @@ export class AuthGuard implements CanActivate { case '/admin/visitor': if (this.userInfo && this.userInfo.role !== 'admin') { observer.next(false); - if (this.visitCount === 1) this.router.navigateByUrl('/admin') + if (this.visitCount === 1) {this.router.navigateByUrl('/admin');} observer.complete(); return; } diff --git a/src/app/view/admin/components/common-table/common-table.component.ts b/src/app/view/admin/components/common-table/common-table.component.ts index 51e4f5d..e46378d 100644 --- a/src/app/view/admin/components/common-table/common-table.component.ts +++ b/src/app/view/admin/components/common-table/common-table.component.ts @@ -15,11 +15,11 @@ export class CommonTableComponent implements OnInit, OnChanges { @Input() cardTitle: string | null; @Input() template: { [fieldValue: string]: { - temp: TemplateRef, - param?: { [key: string]: string } - } + temp: TemplateRef; + param?: { [key: string]: string }; + }; }; - @Output() pageInfo = new EventEmitter<{ page: number, pageSize: number }>(); + @Output() pageInfo = new EventEmitter<{ page: number; pageSize: number }>(); loading: boolean = true; dataList: PageList = new PageList(); settingModalVisible: boolean = false; @@ -37,20 +37,20 @@ export class CommonTableComponent implements OnInit, OnChanges { this.filedData = this.cloneData(localStorage.getItem(this.request.path)); this.changed = true; } else { - this.filedData = this.cloneData(this.headData) + this.filedData = this.cloneData(this.headData); } this.calculateVisibleFieldLength(); - if (!this.template) this.template = {} + if (!this.template) {this.template = {};} this.headData.forEach(dat => { - if (!dat.action) return; + if (!dat.action) {return;} dat.action.forEach(act => { if (!act.hover) { act.hover = () => null; } - }) + }); }); - if (!this.request || !this.request.path) return + if (!this.request || !this.request.path) {return;} this.getData(); } @@ -65,15 +65,15 @@ export class CommonTableComponent implements OnInit, OnChanges { // page: pageValue, // count: countValue // } - this.pageInfo.emit({page: pageValue, pageSize: countValue}) + this.pageInfo.emit({page: pageValue, pageSize: countValue}); return this.httpService.Service>(this.request).subscribe({ next: resp => { this.dataList = resp.result; - setTimeout(() => this.loading = false, 10) + setTimeout(() => this.loading = false, 10); }, error: err => this.loading = false }); - } + }; ngOnChanges(changes: SimpleChanges): void { if (changes.request && !changes.request.isFirstChange()) { @@ -87,7 +87,7 @@ export class CommonTableComponent implements OnInit, OnChanges { getValue(index: number, fieldValue: string): string { let value = this.dataList.list[index]; try { - for (const key of fieldValue.split('.')) value = value[key] + for (const key of fieldValue.split('.')) {value = value[key];} } catch (e) { // ignore } @@ -96,21 +96,21 @@ export class CommonTableComponent implements OnInit, OnChanges { getContext = (fieldValue: string, index: number) => { const valueData = this.getValue(index, fieldValue); - let context: { value: string, originValue?: string, data: T }; + let context: { value: string; originValue?: string; data: T }; if (this.template[fieldValue].param) { context = { value: this.template[fieldValue].param[valueData], originValue: valueData, data: this.dataList.list[index] - } + }; } else { context = { value: valueData, data: this.dataList.list[index] - } + }; } return context; - } + }; showFieldSetting = () => this.settingModalVisible = true; @@ -121,10 +121,10 @@ export class CommonTableComponent implements OnInit, OnChanges { this.calculateVisibleFieldLength(); this.settingModalVisible = !this.settingModalVisible; if (!this.changed) { - return + return; } this.dataList = JSON.parse(JSON.stringify(this.dataList)); - localStorage.setItem(this.request.path, JSON.stringify(this.filedData)) + localStorage.setItem(this.request.path, JSON.stringify(this.filedData)); this.changed = true; } @@ -138,7 +138,7 @@ export class CommonTableComponent implements OnInit, OnChanges { this.filedData = this.cloneData(this.headData); this.changed = false; this.calculateVisibleFieldLength(); - } + }; cloneData = (source: Data[] | string): Data[] => { let dist: Data[]; @@ -151,11 +151,11 @@ export class CommonTableComponent implements OnInit, OnChanges { if (!action) { return dist; } - const del = dist.filter(value => value.isActionColumns).pop() + const del = dist.filter(value => value.isActionColumns).pop(); dist.splice(dist.indexOf(del), 1); dist.push(action); return dist; - } + }; /** * 字段编辑项被点击 @@ -169,5 +169,5 @@ export class CommonTableComponent implements OnInit, OnChanges { this.changed = true; } } - } + }; } diff --git a/src/app/view/admin/components/common-table/common-table.module.ts b/src/app/view/admin/components/common-table/common-table.module.ts index 52820c3..637033d 100644 --- a/src/app/view/admin/components/common-table/common-table.module.ts +++ b/src/app/view/admin/components/common-table/common-table.module.ts @@ -14,7 +14,7 @@ import {NzTagModule} from 'ng-zorro-antd/tag'; import {NzToolTipModule} from 'ng-zorro-antd/tooltip'; import {NzTypographyModule} from 'ng-zorro-antd/typography'; import {FormsModule} from '@angular/forms'; -import {DragDropModule} from '@angular/cdk/drag-drop' +import {DragDropModule} from '@angular/cdk/drag-drop'; @NgModule({ declarations: [ diff --git a/src/app/view/admin/components/common-table/data.ts b/src/app/view/admin/components/common-table/data.ts index e78c69a..91e9efa 100644 --- a/src/app/view/admin/components/common-table/data.ts +++ b/src/app/view/admin/components/common-table/data.ts @@ -7,19 +7,19 @@ export class Data { primaryKey?: boolean = false; isActionColumns?: boolean = false; template?: { - template: TemplateRef, + template: TemplateRef; keymap?: { - [value: string]: string - } + [value: string]: string; + }; }; // order?: number; - action ?: { - name: string, - color?: string, - order?: number, - fontSize?: string, - needConfirm?: boolean, - click: (data: T) => void, + action?: { + name: string; + color?: string; + order?: number; + fontSize?: string; + needConfirm?: boolean; + click: (data: T) => void; hover?: (data: T) => void | null; - }[] = [] + }[] = []; } diff --git a/src/app/view/admin/components/editable-tag/editable-tag.component.ts b/src/app/view/admin/components/editable-tag/editable-tag.component.ts index bab560d..7ebbaac 100644 --- a/src/app/view/admin/components/editable-tag/editable-tag.component.ts +++ b/src/app/view/admin/components/editable-tag/editable-tag.component.ts @@ -29,11 +29,11 @@ import {NzModalRef, NzModalService} from 'ng-zorro-antd/modal'; }) export class EditableTagComponent implements OnInit, OnChanges { - private static instanceArray: EditableTagComponent[] = [] + private static instanceArray: EditableTagComponent[] = []; inputVisible = false; inputValue = ''; @ViewChild('inputElement', {static: false}) inputElement?: ElementRef; - @Output() valueChange = new EventEmitter<{ value: string, originalValue: string, changed: boolean }>(); + @Output() valueChange = new EventEmitter<{ value: string; originalValue: string; changed: boolean }>(); @Input() color: string; @Input() showEditIcon: boolean; @Input() showBorder: boolean; @@ -44,8 +44,8 @@ export class EditableTagComponent implements OnInit, OnChanges { @Input() autoClear: boolean; @Input() size: 'small' | 'default' | 'large'; @Output() inEditStatus = new EventEmitter(); - @Output() modalOK = new EventEmitter<{ value: string, originalValue: string, changed: boolean }>(); - @Output() modalCancel = new EventEmitter<{ value: string, originalValue: string, changed: boolean }>(); + @Output() modalOK = new EventEmitter<{ value: string; originalValue: string; changed: boolean }>(); + @Output() modalCancel = new EventEmitter<{ value: string; originalValue: string; changed: boolean }>(); confirmModal?: NzModalRef; private tmpKey: any; private doubleClickInfo = { @@ -84,17 +84,17 @@ export class EditableTagComponent implements OnInit, OnChanges { if (this.doubleClick && doubleClick) { if (!this.doubleClickInfo.date) { this.doubleClickInfo.date = new Date().getTime(); - return + return; } if (new Date().getTime() - this.doubleClickInfo.date < 200) { - this.inEditStatus.emit() + this.inEditStatus.emit(); this.inputVisible = true; setTimeout(() => this.inputElement?.nativeElement.focus(), 10); } this.doubleClickInfo.date = new Date().getTime(); } else { this.inputVisible = true; - this.inEditStatus.emit() + this.inEditStatus.emit(); setTimeout(() => this.inputElement?.nativeElement.focus(), 10); } } @@ -105,7 +105,7 @@ export class EditableTagComponent implements OnInit, OnChanges { if (tag.key === this.tmpKey) { tag.showInput(false); } - }) + }); } @@ -114,8 +114,8 @@ export class EditableTagComponent implements OnInit, OnChanges { value: this.inputValue, originalValue: this.text, changed: this.inputValue !== this.text - } - this.valueChange.emit(value) + }; + this.valueChange.emit(value); this.text = this.inputValue; this.inputValue = ''; this.inputVisible = false; @@ -128,7 +128,7 @@ export class EditableTagComponent implements OnInit, OnChanges { }); } if (this.autoClear) { - this.text = null + this.text = null; } } diff --git a/src/app/view/admin/test-common-table/test-common-table.component.ts b/src/app/view/admin/test-common-table/test-common-table.component.ts index 2a3ccac..c68af30 100644 --- a/src/app/view/admin/test-common-table/test-common-table.component.ts +++ b/src/app/view/admin/test-common-table/test-common-table.component.ts @@ -62,7 +62,7 @@ updateDateFormat: "2020-05-27 00:55:05"*/ }, ] } - ] + ]; } ngOnInit(): void { @@ -73,7 +73,7 @@ updateDateFormat: "2020-05-27 00:55:05"*/ page: 1, count: 10 } - } + }; } } diff --git a/src/app/view/article/article.component.ts b/src/app/view/article/article.component.ts index c95cc01..48e7e22 100644 --- a/src/app/view/article/article.component.ts +++ b/src/app/view/article/article.component.ts @@ -7,9 +7,9 @@ import {User} from '../../class/User'; import {Comment, CommentReq} from '../../class/Comment'; import {PageList} from '../../class/HttpReqAndResp'; import {GlobalUserService} from '../../services/global-user.service'; -import VditorPreview from 'vditor/dist/method.min' +import VditorPreview from 'vditor/dist/method.min'; -declare var $; +declare let $; @Component({ selector: 'view-article', @@ -49,7 +49,7 @@ export class ArticleComponent implements OnInit { error: (err) => null, next: data => { this.user = data.result; - if (data.result) this.avatarImgUrl = data.result.avatarImgUrl; + if (data.result) {this.avatarImgUrl = data.result.avatarImgUrl;} } }); this.comment = new CommentReq(`article/${this.articleId}`); diff --git a/src/app/view/index/components/tag-tag/tag-tag.component.ts b/src/app/view/index/components/tag-tag/tag-tag.component.ts index ab7e870..fe87d25 100644 --- a/src/app/view/index/components/tag-tag/tag-tag.component.ts +++ b/src/app/view/index/components/tag-tag/tag-tag.component.ts @@ -9,12 +9,12 @@ import {Router} from '@angular/router'; }) export class TagTagComponent implements OnInit { - @Input() tag: { name: string, size: number }; + @Input() tag: { name: string; size: number }; @Input() size: 'default' | 'large' = 'default'; @Input() clickable: boolean; // default true @Input() enableCount: boolean; // default true @Output() tagClick = new EventEmitter(); - randColor: { bgColor: string, fontColor: string }; + randColor: { bgColor: string; fontColor: string }; constructor(private router: Router) { } diff --git a/src/app/view/index/index.component.ts b/src/app/view/index/index.component.ts index 307e4df..919e548 100644 --- a/src/app/view/index/index.component.ts +++ b/src/app/view/index/index.component.ts @@ -23,14 +23,14 @@ export class IndexComponent implements OnInit { imgUrl: string; desc: string; articles: PageList
; - tagNameAndNumber: { name: string, size: number }[]; + tagNameAndNumber: { name: string; size: number }[]; categoryList: Category[]; counts: { - articleCount: number, - visitorCount: number, - categoryCount: number, - tagCount: number, - commentCount: number + articleCount: number; + visitorCount: number; + categoryCount: number; + tagCount: number; + commentCount: number; }; lastestUpdate: { lastUpdateTime: string; @@ -38,7 +38,7 @@ export class IndexComponent implements OnInit { lastCommit: string; committerAuthor: string; committerDate: string; - commitUrl: string + commitUrl: string; }; constructor(private apiService: ApiService, diff --git a/src/app/view/link/link.component.ts b/src/app/view/link/link.component.ts index 2e72145..30698e4 100644 --- a/src/app/view/link/link.component.ts +++ b/src/app/view/link/link.component.ts @@ -55,7 +55,7 @@ export class LinkComponent implements OnInit { this.applyFormGroup.patchValue({linkUrl: linkUrlData.replace(this.lastUrl, data)}); this.lastUrl = data; }, - }) + }); } apply() { @@ -69,7 +69,7 @@ export class LinkComponent implements OnInit { this.message.success('提交成功,请稍等,即将为你处理'); this.loading = false; this.showModal = false; - this.applyFormGroup.reset() + this.applyFormGroup.reset(); }, error: err => { if (err.code === 7200) { @@ -82,7 +82,7 @@ export class LinkComponent implements OnInit { this.apiService.reapplyLink(key).subscribe({ next: data1 => this.message.success('提交成功,请稍等,即将为你处理'), error: err1 => this.message.error('提交失败,原因:' + err.msg) - }) + }); } }); } else { @@ -90,7 +90,7 @@ export class LinkComponent implements OnInit { } this.loading = false; this.showModal = false; - this.applyFormGroup.reset() + this.applyFormGroup.reset(); } }); } diff --git a/src/app/view/login-registration/components/login/login.component.ts b/src/app/view/login-registration/components/login/login.component.ts index 04d96a4..f19256e 100644 --- a/src/app/view/login-registration/components/login/login.component.ts +++ b/src/app/view/login-registration/components/login/login.component.ts @@ -68,7 +68,7 @@ export class LoginComponent implements OnInit { this.router.navigateByUrl(this.url); } else { // window.location.href = '/admin/'; - this.router.navigateByUrl('/admin') + this.router.navigateByUrl('/admin'); } } } diff --git a/src/app/view/tag/tag.component.ts b/src/app/view/tag/tag.component.ts index 10c9ca0..9c71cf3 100644 --- a/src/app/view/tag/tag.component.ts +++ b/src/app/view/tag/tag.component.ts @@ -14,10 +14,10 @@ import {Title} from '@angular/platform-browser'; }) export class TagComponent implements OnInit { - tagList: { name: string, size: number } [] = []; + tagList: { name: string; size: number } [] = []; articleList: PageList
; name: string; - private tag: { name: string, size: number }; + private tag: { name: string; size: number }; constructor(private apiService: ApiService, private nzMessageService: NzMessageService, @@ -56,7 +56,7 @@ export class TagComponent implements OnInit { }); } - changeTag(tag: { name: string, size: number }) { + changeTag(tag: { name: string; size: number }) { if (this.name === tag.name) { return; } diff --git a/src/app/view/update/update.component.ts b/src/app/view/update/update.component.ts index 9c08db9..d6ebc05 100644 --- a/src/app/view/update/update.component.ts +++ b/src/app/view/update/update.component.ts @@ -15,9 +15,9 @@ export class UpdateComponent implements OnInit { lastCommit: string; committerAuthor: string; committerDate: string; - commitUrl: string + commitUrl: string; }; - webUpdate: { id: number, info: string, time: string }[] = []; + webUpdate: { id: number; info: string; time: string }[] = []; constructor(private titleService: Title, private apiService: ApiService) { diff --git a/src/app/view/write/components/publish-form/publish-form.component.ts b/src/app/view/write/components/publish-form/publish-form.component.ts index bf63ada..210f101 100644 --- a/src/app/view/write/components/publish-form/publish-form.component.ts +++ b/src/app/view/write/components/publish-form/publish-form.component.ts @@ -1,7 +1,7 @@ import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core'; import {FormBuilder, FormGroup, Validators} from '@angular/forms'; import {Category} from '../../../../class/Tag'; -import {ColorList} from '../../../../utils/color' +import {ColorList} from '../../../../utils/color'; @Component({ selector: 'c-publish-form', @@ -11,16 +11,16 @@ import {ColorList} from '../../../../utils/color' export class PublishFormComponent implements OnInit { @ViewChild('inputElement', {static: true}) tagInputElement: ElementRef; - @Input() tagNacList: { name: string, size: number }[]; + @Input() tagNacList: { name: string; size: number }[]; @Input() categoryList: Category[]; - @Input() primaryData: { id: number, type: boolean, tags: string[], category: string, url?: string }; + @Input() primaryData: { id: number; type: boolean; tags: string[]; category: string; url?: string }; @Output() submitEvent = new EventEmitter<{ - id: number, - type: boolean, - tags: string[], - category: string, - isUpdate: boolean, - url?: string + id: number; + type: boolean; + tags: string[]; + category: string; + isUpdate: boolean; + url?: string; }>(); formGroup: FormGroup; tagTmpList: string[] = []; @@ -94,7 +94,7 @@ export class PublishFormComponent implements OnInit { this.formGroup.get('tagList').setValue(this.tagTmpList.length ? this.tagTmpList : null); this.formGroup.get('tagList').updateValueAndValidity(); this.tagInputVisible = false; - this.editTagText = '新增' + this.editTagText = '新增'; } // 点击tag切换 @@ -119,7 +119,11 @@ export class PublishFormComponent implements OnInit { articleTypeChanged() { this.formGroup.get(`url`).clearValidators(); const type = this.formGroup.get(`type`).value; - this.formGroup.get(`url`).setValidators(type ? null : [Validators.required, Validators.pattern('^(https:\/\/|http:\/\/|)([\\w-]+\\.)+[\\w-]+(\\/[\\w-./?%&=]*)?$')]); + this.formGroup.get(`url`).setValidators(type ? null : [ + Validators.required, + Validators.pattern('^(https:\/\/|http:\/\/|)([\\w-]+\\.)+[\\w-]+(\\/[\\w-./?%&=]*)?$') + ] + ); this.formGroup.get(`url`).updateValueAndValidity(); } } diff --git a/src/app/view/write/write.component.ts b/src/app/view/write/write.component.ts index 59ef179..6380c8a 100644 --- a/src/app/view/write/write.component.ts +++ b/src/app/view/write/write.component.ts @@ -26,12 +26,12 @@ export class WriteComponent implements OnInit, OnDestroy { public article: ArticleReq = new ArticleReq(); userInfo: User; categoryList: Tag[]; - tagNacList: { name: string, size: number }[]; + tagNacList: { name: string; size: number }[]; primaryData = null; // 发布新文章时,文章相同会被拦回 此处判断一下 title: string; private lastShowTime: number; - private userInfoSub: { unsubscribe: () => void } + private userInfoSub: { unsubscribe: () => void }; constructor(private router: Router, private activatedRoute: ActivatedRoute, @@ -101,7 +101,7 @@ export class WriteComponent implements OnInit, OnDestroy { this.article.category = e.category; this.article.url = e.url; this.article.id = e.id; - this.isUpdate = e.isUpdate + this.isUpdate = e.isUpdate; this.modalVisible = false; @@ -169,8 +169,8 @@ export class WriteComponent implements OnInit, OnDestroy { next: data => { this.article.category = data.result.category; this.article.mdContent = data.result.mdContent; - const tags = [] - data.result.tags.forEach(t => tags.push(t.name)) + const tags = []; + data.result.tags.forEach(t => tags.push(t.name)); this.article.tags = tags; this.article.type = data.result.original; this.article.url = data.result.url; @@ -184,7 +184,7 @@ export class WriteComponent implements OnInit, OnDestroy { url: this.article.url, id: this.article.id }; - this.vditor.setValue(this.article.mdContent) + this.vditor.setValue(this.article.mdContent); }, error: e => { if (e.code === 2010) { @@ -227,7 +227,7 @@ export class WriteComponent implements OnInit, OnDestroy { upload: { url: environment.host + '/fileUpload', format: (files: File[], responseText: string) => { - const data: Response<[{ originalFilename: string, host: string, path: string, success: boolean }]> + const data: Response<[{ originalFilename: string; host: string; path: string; success: boolean }]> = JSON.parse(responseText); const result = { msg: data.msg, @@ -236,16 +236,14 @@ export class WriteComponent implements OnInit, OnDestroy { errFiles: [], succMap: {} } - } + }; data.result.filter(value => value.success) .forEach(value => result.data.succMap[value.originalFilename] = value.host + value.path); data.result.filter(value => !value.success) .forEach(value => result.data.errFiles.push(value.originalFilename)); return JSON.stringify(result); }, - setHeaders: () => { - return {Authorization: this.localStorageService.getToken()} - } + setHeaders: () => ({Authorization: this.localStorageService.getToken()}) }, after: () => { // 判断是更新文章还是恢复文章 @@ -258,6 +256,6 @@ export class WriteComponent implements OnInit, OnDestroy { this.article = JSON.parse(localStorage.getItem('tmpArticle')); } } - } + }; } }