From f76834563ed746c73250832d0133e6818038269b Mon Sep 17 00:00:00 2001 From: AceDataCloud Date: Sun, 7 Nov 2021 17:16:29 +0800 Subject: [PATCH] add publication view --- src/components/content/Sidebar.vue | 11 ++++- src/i18n/zh/common/nav.ts | 3 +- src/i18n/zh/content/nav.ts | 3 +- src/pages/content/publication/Index.vue | 45 +++++++++++++++++++++ src/router/content.ts | 8 ++++ src/services/content/publication/service.ts | 29 +++++++++++++ src/services/content/publication/types.ts | 12 ++++++ src/services/index.ts | 3 +- 8 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 src/pages/content/publication/Index.vue create mode 100644 src/services/content/publication/service.ts create mode 100644 src/services/content/publication/types.ts diff --git a/src/components/content/Sidebar.vue b/src/components/content/Sidebar.vue index af5b50f3..c133c54e 100644 --- a/src/components/content/Sidebar.vue +++ b/src/components/content/Sidebar.vue @@ -12,18 +12,25 @@ + + + + + + + + diff --git a/src/router/content.ts b/src/router/content.ts index 68f0d757..af1a941e 100644 --- a/src/router/content.ts +++ b/src/router/content.ts @@ -46,6 +46,14 @@ export default { title: t('common.nav.platform') }, component: () => import('@/pages/content/platform/Index.vue') + }, + { + path: 'publication', + name: 'publication-index', + meta: { + title: t('common.nav.publication') + }, + component: () => import('@/pages/content/publication/Index.vue') } ] }; diff --git a/src/services/content/publication/service.ts b/src/services/content/publication/service.ts new file mode 100644 index 00000000..33852253 --- /dev/null +++ b/src/services/content/publication/service.ts @@ -0,0 +1,29 @@ +import { AxiosResponse } from 'axios'; +import httpClient from '../../instance'; +import { IPublication, IPublicationDetailResponse, IPublicationListResponse } from './types'; + +class PublicationService { + key = 'publications'; + + async getAll(): Promise> { + return await httpClient.get(`/${this.key}/`); + } + + async get(id: number): Promise> { + return await httpClient.get(`/${this.key}/${id}`); + } + + async create(data: IPublication): Promise> { + return await httpClient.post(`/${this.key}/`, data); + } + + async update(id: number, data: IPublication): Promise> { + return await httpClient.put(`/${this.key}/${id}`, data); + } + + async delete(id: number): Promise> { + return await httpClient.delete(`/${this.key}/${id}`); + } +} + +export default new PublicationService(); diff --git a/src/services/content/publication/types.ts b/src/services/content/publication/types.ts new file mode 100644 index 00000000..cab02b3b --- /dev/null +++ b/src/services/content/publication/types.ts @@ -0,0 +1,12 @@ +export interface IPublication { + id: number; + name: string; + state: string; +} + +export interface IPublicationListResponse { + count: number; + results: IPublication[]; +} + +export interface IPublicationDetailResponse extends IPublication {} diff --git a/src/services/index.ts b/src/services/index.ts index 53fcbdca..aff63bad 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,4 +1,5 @@ import ArticleService from './content/article/service'; import PlatformService from './content/platform/service'; +import PublicationService from './content/publication/service'; -export { ArticleService, PlatformService }; +export { ArticleService, PlatformService, PublicationService };