From e5947754ea72c0117b4ce20df668142b940b3fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=93=E5=8F=91=E5=8F=97=E9=95=BF=E7=94=9F?= Date: Wed, 2 Feb 2022 01:54:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=9C=B0=E5=9D=80=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Home.vue | 2 +- src/views/Login.vue | 4 ++-- src/views/api/Hitokoto.vue | 8 ++++---- src/views/api/Music.vue | 10 +++++----- src/views/api/PhotoWall.vue | 6 +++--- src/views/api/SourceImage.vue | 8 ++++---- src/views/system/Article.vue | 14 +++++++------- src/views/system/Statistics.vue | 4 ++-- src/views/system/SystemConfig.vue | 6 +++--- src/views/system/SystemConfigAdd.vue | 2 +- src/views/system/SystemRole.vue | 6 +++--- src/views/system/SystemUser.vue | 10 +++++----- 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/views/Home.vue b/src/views/Home.vue index 29dda33..5d31f76 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -79,7 +79,7 @@ export default class Home extends Vue{ this.$router.push('/login') return } - const data = await this.$http.post<{token: string}, any>('/api/common/verifyToken', {token: this.$store.state.loginInfo.token}) + const data = await this.$http.post<{token: string}, any>('/api/v1/common/verifyToken', {token: this.$store.state.loginInfo.token}) if(data.status) { // 如果是已过期的token 服务端会签发新的token this.$store.commit('login', {token: data.newToken || this.$store.state.loginInfo.token, userInfo: data.userInfo}) diff --git a/src/views/Login.vue b/src/views/Login.vue index 27f0034..8dc96a9 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -45,7 +45,7 @@ export default class Login extends Vue { async login() { (this.$refs.loginForm as VForm).validate(async (valid: boolean) => { if (!valid) return - const data = await this.$http.post('/api/common/login', this.userInfo) + const data = await this.$http.post('/api/v1/common/login', this.userInfo) if(data.token) { this.$store.commit('login', data) this.$router.push('/') @@ -58,7 +58,7 @@ export default class Login extends Vue { * 访客模式 */ async guestLogin() { - const data = await this.$http.post('/api/common/guestLogin') + const data = await this.$http.post('/api/v1/common/guestLogin') if (data.status && data.data.token) { this.$store.commit('login', data.data) this.$router.push('/') diff --git a/src/views/api/Hitokoto.vue b/src/views/api/Hitokoto.vue index 1e4598b..fb21d84 100644 --- a/src/views/api/Hitokoto.vue +++ b/src/views/api/Hitokoto.vue @@ -88,7 +88,7 @@ export default class Hitokoto extends BaseList { async loadData() { this.loading = true - const data = await this.$http.get('/api/hitokoto/list', {params:this.search}) + const data = await this.$http.get('/api/v1/hitokoto/list', {params:this.search}) selectedData = [] this.loading = false this.total = data.total @@ -98,7 +98,7 @@ export default class Hitokoto extends BaseList { ((this.$refs.addForm as Vue).$refs.hitokotoForm as VForm).validate(async (valid: boolean) => { if (!valid) return this.modalLoading = true - const data = await this.$http.post('/api/hitokoto/save', this.formData) + const data = await this.$http.post('/api/v1/hitokoto/save', this.formData) this.modalLoading = false this.addModal = false ElMessage.success(data.message) @@ -113,7 +113,7 @@ export default class Hitokoto extends BaseList { return } ElMessageBox.confirm(`是否确认删除选中的${selectedData.length}条数据?`, '确认删除', {type: 'warning'}).then(async () => { - const data = await this.$http.delete('/api/hitokoto/delete', {params:{_ids: selectedData}}) + const data = await this.$http.delete('/api/v1/hitokoto/delete', {params:{_ids: selectedData}}) ElMessage.success(data.message) this.loadData() }).catch(() => {}) @@ -123,7 +123,7 @@ export default class Hitokoto extends BaseList { } created() { this.loadData() - this.$http.get('/api/common/config/hitokoto_type').then(data => { + this.$http.get('/api/v1/common/config/hitokoto_type').then(data => { this.typeList = data }) } diff --git a/src/views/api/Music.vue b/src/views/api/Music.vue index 944fd10..35ec868 100644 --- a/src/views/api/Music.vue +++ b/src/views/api/Music.vue @@ -184,17 +184,17 @@ export default class Music extends BaseList { musicPlaying: boolean = false musicList: MusicPlayerItem[] = [] created() { - this.$http.get('/api/music/listLibs').then(data => { + this.$http.get('/api/v1/music/listLibs').then(data => { this.musicLibs = data this.loadData() }) - this.$http.get('/api/music/listExts').then(data => { + this.$http.get('/api/v1/music/listExts').then(data => { this.exts = data }) } async loadData() { this.loading = true - const data = await this.$http.get('/api/music/list', {params: this.search}) + const data = await this.$http.get('/api/v1/music/list', {params: this.search}) selectedIds = [] this.loading = false this.total = data.total @@ -210,7 +210,7 @@ export default class Music extends BaseList { // 根据当前搜索条件播放音乐 async playMusic() { try { - const data = await this.$http.get('/api/music/list/all', {params: selectedIds.length ? {ids: selectedIds} : this.search}) + const data = await this.$http.get('/api/v1/music/list/all', {params: selectedIds.length ? {ids: selectedIds} : this.search}) this.musicList = data.map((item: MusicModel) => { return { name: item.title || item.name, @@ -246,7 +246,7 @@ export default class Music extends BaseList { this.currentRow = { ...row } this.modifyLyricModal = true if (row.lyric_id) { - const data = (await this.$http.get('/api/music/lyric/get', {params: {lyricId: row.lyric_id}})) + const data = (await this.$http.get('/api/v1/music/lyric/get', {params: {lyricId: row.lyric_id}})) data.cloud_id = data.cloud_id ? data.cloud_id.toString() : null this.lyricFormData = data } else { diff --git a/src/views/api/PhotoWall.vue b/src/views/api/PhotoWall.vue index c4107a2..b86ba34 100644 --- a/src/views/api/PhotoWall.vue +++ b/src/views/api/PhotoWall.vue @@ -96,7 +96,7 @@ export default class PhotoWall extends BaseList { isUploading: boolean = false async loadData() { this.loading = true - const data = await this.$http.get('/api/photowall/list', {params:this.search}) + const data = await this.$http.get('/api/v1/photowall/list', {params:this.search}) selectedData = [] this.loading = false this.total = data.total @@ -108,7 +108,7 @@ export default class PhotoWall extends BaseList { return } ElMessageBox.confirm(`是否确认删除选中的${selectedData.length}条数据?`, '确认删除', {type: 'warning'}).then(async () => { - await this.$http.delete('/api/photowall/delete', {params:{_ids: selectedData}}) + await this.$http.delete('/api/v1/photowall/delete', {params:{_ids: selectedData}}) ElMessage.success('删除成功') this.loadData() }).catch(() => {}) @@ -139,7 +139,7 @@ export default class PhotoWall extends BaseList { } async preview(row: PhotoWallModel) { const previewHeight = Math.floor(row.height * (500 / row.width)) - const pictureCdn = await this.$http.get('/api/common/config/picture_cdn') + const pictureCdn = await this.$http.get('/api/v1/common/config/picture_cdn') ElMessageBox({ title: '图片预览', message: h('img', { style: `width:500px;height:${previewHeight}px;`, src: `${pictureCdn}/${row.name}` }, ''), diff --git a/src/views/api/SourceImage.vue b/src/views/api/SourceImage.vue index c27be9a..e19393b 100644 --- a/src/views/api/SourceImage.vue +++ b/src/views/api/SourceImage.vue @@ -107,7 +107,7 @@ export default class SourceImage extends BaseList { } async loadData(): Promise { this.loading = true - const data = await this.$http.get('/api/source-image/list', {params:this.search}) + const data = await this.$http.get('/api/v1/source-image/list', {params:this.search}) selectedData = [] this.loading = false this.total = data.total @@ -119,7 +119,7 @@ export default class SourceImage extends BaseList { return } ElMessageBox.confirm(`是否确认删除选中的${selectedData.length}条数据?`, '确认删除', {type: 'warning'}).then(async () => { - await this.$http.delete('/api/source-image/delete', {params:{_ids: selectedData}}) + await this.$http.delete('/api/v1/source-image/delete', {params:{_ids: selectedData}}) ElMessage.success('删除成功') this.loadData() }).catch(() => {}) @@ -166,10 +166,10 @@ export default class SourceImage extends BaseList { this.modifyModal = true } async tarnsferChange(newTargetKeys: string[], direction: 'right' | 'left', moveKeys: string[]) { - await this.$http.post('/api/source-image/updateLabel', {id: this.curId, labels: newTargetKeys}) + await this.$http.post('/api/v1/source-image/updateLabel', {id: this.curId, labels: newTargetKeys}) } created() { - this.$http.get('/api/common/config/image_label').then(data => { + this.$http.get('/api/v1/common/config/image_label').then(data => { this.labelList.push(...data) this.loadData() }) diff --git a/src/views/system/Article.vue b/src/views/system/Article.vue index 68ba284..06cb018 100644 --- a/src/views/system/Article.vue +++ b/src/views/system/Article.vue @@ -138,7 +138,7 @@ export default class Article extends BaseList { isUploading: boolean = false async loadData() { this.loading = true - const data = await this.$http.get('/api/article/list', {params:this.search}) + const data = await this.$http.get('/api/v1/article/list', {params:this.search}) selectedData = [] this.loading = false this.total = data.total @@ -150,7 +150,7 @@ export default class Article extends BaseList { return } ElMessageBox.confirm(`是否确认对选中的${selectedData.length}篇文章执行分词处理?`, '操作确认', {type: 'info'}).then(async () => { - const data = await this.$http.put<{_ids: string[]}, any>('/api/article/splitWord', {_ids: selectedData}) + const data = await this.$http.put<{_ids: string[]}, any>('/api/v1/article/splitWord', {_ids: selectedData}) if(data.status) { ElMessage.success(data.message) } else { @@ -160,7 +160,7 @@ export default class Article extends BaseList { } pullArticles() { ElMessageBox.confirm('确认拉取全部文章?', '操作确认', {type: 'info'}).then(async () => { - const data = await this.$http.put('/api/article/pull') + const data = await this.$http.put('/api/v1/article/pull') if(data.status) { ElMessage.success(data.message) this.loadData() @@ -194,7 +194,7 @@ export default class Article extends BaseList { isLeaf: 'isLeaf', } async loadTreeData(node: Node, resolve: Function) { - const childItems: TreeNodeSource[] = await this.$http.get('/api/article/tree', {params:{deep: node.level, parent: node.data.name}}) + const childItems: TreeNodeSource[] = await this.$http.get('/api/v1/article/tree', {params:{deep: node.level, parent: node.data.name}}) resolve(childItems.map((childItem): TreeNodeData => { const treeNode: TreeNodeData = { name: childItem._id, @@ -213,7 +213,7 @@ export default class Article extends BaseList { async articlePreview(node: TreeNodeData) { if(!node.isLeaf) return // 加载文章markdown预览 - const mdText = await this.$http.get('/api/article/markdown', {params:{id: node.id}}) + const mdText = await this.$http.get('/api/v1/article/markdown', {params:{id: node.id}}) this.markdownPreview.show = true const markdownHtml = new hyperdown().makeHtml(mdText) this.markdownPreview.content = markdownHtml.replace(/(?<=
]*?>)[\s\S]*?(?=<\/code><\/pre>)/gi, content => {
@@ -223,10 +223,10 @@ export default class Article extends BaseList {
   }
   created() {
     this.loadData()
-    this.$http.get('/api/article/listCategories').then(data => {
+    this.$http.get('/api/v1/article/listCategories').then(data => {
       this.categories = data
     })
-    this.$http.get('/api/article/listTags').then(data => {
+    this.$http.get('/api/v1/article/listTags').then(data => {
       this.tags = data
     })
   }
diff --git a/src/views/system/Statistics.vue b/src/views/system/Statistics.vue
index a1c6ce3..9d5ce5f 100644
--- a/src/views/system/Statistics.vue
+++ b/src/views/system/Statistics.vue
@@ -23,7 +23,7 @@ export default class Statistics extends Vue {
     this.publishDatesChartLoading = true
     this.timelineWordsChartLoading = true
 
-    const articleData = await this.$http.get<{params:{type:string}}, any>('/api/article/statistics', {params:{type:'normal'}})
+    const articleData = await this.$http.get<{params:{type:string}}, any>('/api/v1/article/statistics', {params:{type:'normal'}})
     this.categoriesChartOption.legend.data = articleData.categories.map((item: any) => item._id)
     this.categoriesChartOption.series.data = articleData.categories.map((item: any) => {
       return {name: item._id, value: item.cnt}
@@ -38,7 +38,7 @@ export default class Statistics extends Vue {
     this.categoriesChartLoading = false
     this.publishDatesChartLoading = false
 
-    const timelineData = await this.$http.get<{params:{type:string}}, any>('/api/article/statistics', {params:{type:'timelineWords'}})
+    const timelineData = await this.$http.get<{params:{type:string}}, any>('/api/v1/article/statistics', {params:{type:'timelineWords'}})
     this.timelineWordsChartOption.timeline.data = timelineData.timelineWords.map((item: any) => item._id)
     timelineData.timelineWords.forEach((item: any) => {
       this.timelineWordsChartOption.options.push({
diff --git a/src/views/system/SystemConfig.vue b/src/views/system/SystemConfig.vue
index f2e4655..a8b5551 100644
--- a/src/views/system/SystemConfig.vue
+++ b/src/views/system/SystemConfig.vue
@@ -87,7 +87,7 @@ export default class SystemConfig extends Vue {
   }
   async loadData() {
     this.loading = true
-    this.systemConfigData = await this.$http.get('/api/system/config/list', {params:this.search})
+    this.systemConfigData = await this.$http.get('/api/v1/system/config/list', {params:this.search})
     this.loading = false
   }
   add() {
@@ -112,7 +112,7 @@ export default class SystemConfig extends Vue {
     ((this.$refs.addForm as Vue).$refs.configForm as VForm).validate(async (valid: boolean) => {
       if (!valid) return
       this.modalLoading = true
-      const data = await this.$http.post('/api/system/config/save', this.formData)
+      const data = await this.$http.post('/api/v1/system/config/save', this.formData)
       this.modalLoading = false
       this.addModal = false
       ElMessage.success(data.message)
@@ -121,7 +121,7 @@ export default class SystemConfig extends Vue {
   }
   remove(row: SystemConfigModel) {
     ElMessageBox.confirm(`是否确认删除 ${row.name} 配置项?`, '确认删除', {type: 'warning'}).then(async () => {
-      const data = await this.$http.delete<{params: {id: string}}, any>('/api/system/config/delete', {params: {id: row._id}})
+      const data = await this.$http.delete<{params: {id: string}}, any>('/api/v1/system/config/delete', {params: {id: row._id}})
       if(data.status) {
         ElMessage.success(data.message)
         this.loadData()
diff --git a/src/views/system/SystemConfigAdd.vue b/src/views/system/SystemConfigAdd.vue
index 102e51e..ee31924 100644
--- a/src/views/system/SystemConfigAdd.vue
+++ b/src/views/system/SystemConfigAdd.vue
@@ -38,7 +38,7 @@ export default class SystenConfigAdd extends Vue {
       name: [
         { required: true, message: '请输入配置项名称', trigger: 'blur' },
         { validator: (rule: object, value: string, callback: Function) => {
-            this.$http.get('/api/system/config/exists', {params: {name: value, id: this.formData._id}}).then(data => {
+            this.$http.get('/api/v1/system/config/exists', {params: {name: value, id: this.formData._id}}).then(data => {
               if(data.data.exists) {
                 callback(new Error('配置项名称已存在'))
               } else {
diff --git a/src/views/system/SystemRole.vue b/src/views/system/SystemRole.vue
index db928e7..5784e69 100644
--- a/src/views/system/SystemRole.vue
+++ b/src/views/system/SystemRole.vue
@@ -129,7 +129,7 @@ export default class SystemRole extends BaseList {
   }
   async loadData() {
     this.loading = true
-    const data = await this.$http.get<{params: SystemRolePage}, any>('/api/system/role/list', {params:this.search})
+    const data = await this.$http.get<{params: SystemRolePage}, any>('/api/v1/system/role/list', {params:this.search})
     this.loading = false
     this.total = data.total
     this.systemRoleData = data.data
@@ -180,7 +180,7 @@ export default class SystemRole extends BaseList {
   }
   remove(row: SystemRoleModel) {
     ElMessageBox.confirm(`是否确认删除 ${row.name} 角色?`, '确认删除', {type: 'warning'}).then(async () => {
-      const data = await this.$http.delete<{params: {id: string}}, any>('/api/system/role/delete', {params: {id: row._id}})
+      const data = await this.$http.delete<{params: {id: string}}, any>('/api/v1/system/role/delete', {params: {id: row._id}})
       if(data.status) {
         ElMessage.success(data.message)
         this.loadData()
@@ -193,7 +193,7 @@ export default class SystemRole extends BaseList {
     (this.$refs.roleForm as VForm).validate(async (valid: boolean) => {
       if (!valid) return
       this.modalLoading = true
-      const data = await this.$http.post('/api/system/role/save', this.formData)
+      const data = await this.$http.post('/api/v1/system/role/save', this.formData)
       this.modalLoading = false
       this.addModal = false
       ElMessage.success(data.message)
diff --git a/src/views/system/SystemUser.vue b/src/views/system/SystemUser.vue
index ef3bb38..5036edf 100644
--- a/src/views/system/SystemUser.vue
+++ b/src/views/system/SystemUser.vue
@@ -88,7 +88,7 @@ export default class SystemUser extends BaseList {
       username: [
         { required: true, message: '请输入用户名', trigger: 'blur' },
         { validator: async (rule: object, value: string, callback: Function) => {
-            const data = await this.$http.get('/api/system/user/exists', {params: {username: value, id: this.formData._id}})
+            const data = await this.$http.get('/api/v1/system/user/exists', {params: {username: value, id: this.formData._id}})
             if(data.data.exists) {
               callback(new Error('用户名已存在'))
             } else {
@@ -118,7 +118,7 @@ export default class SystemUser extends BaseList {
   }
   async loadData() {
     this.loading = true
-    const data = await this.$http.get<{params: SystemUserPage}, any>('/api/system/user/list', {params:this.search})
+    const data = await this.$http.get<{params: SystemUserPage}, any>('/api/v1/system/user/list', {params:this.search})
     this.loading = false
     this.total = data.total
     this.systemUserData = data.data
@@ -149,7 +149,7 @@ export default class SystemUser extends BaseList {
     (this.$refs.userForm as VForm).validate(async (valid: boolean) => {
       if (!valid) return
       this.modalLoading = true
-      const data = await this.$http.post('/api/system/user/save', this.formData)
+      const data = await this.$http.post('/api/v1/system/user/save', this.formData)
       this.modalLoading = false
       this.addModal = false
       ElMessage.success(data.message)
@@ -158,7 +158,7 @@ export default class SystemUser extends BaseList {
   }
   remove(row: SystemUserModel) {
     ElMessageBox.confirm(`是否确认删除 ${row.username} 用户?`, '确认删除', {type: 'warning'}).then(async () => {
-      const data = await this.$http.delete<{params: {id: string}}, any>('/api/system/user/delete', {params: {id: row._id}})
+      const data = await this.$http.delete<{params: {id: string}}, any>('/api/v1/system/user/delete', {params: {id: row._id}})
       if(data.status) {
         ElMessage.success(data.message)
         this.loadData()
@@ -169,7 +169,7 @@ export default class SystemUser extends BaseList {
   }
   created() {
     this.loadData()
-    this.$http.get('/api/system/role/listAll').then(data => {
+    this.$http.get('/api/v1/system/role/listAll').then(data => {
       this.roles = data
     })
   }