From d96a7f6a7312b866ed28d79bad74534e6d1806fd Mon Sep 17 00:00:00 2001 From: ruibaby Date: Wed, 11 Sep 2019 20:49:52 +0800 Subject: [PATCH] Support select theme on theme edit page. --- src/api/theme.js | 23 ++++++++++++++- src/views/dashboard/Dashboard.vue | 36 ++++++++++++------------ src/views/interface/ThemeEdit.vue | 8 ++++-- src/views/sheet/internal/JournalList.vue | 12 ++++---- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/api/theme.js b/src/api/theme.js index 3b3eeb1c..81463706 100644 --- a/src/api/theme.js +++ b/src/api/theme.js @@ -133,6 +133,16 @@ themeApi.getContent = path => { }) } +themeApi.getContent = (themeId, path) => { + return service({ + url: `${baseUrl}/${themeId}/files/content`, + params: { + path: path + }, + method: 'get' + }) +} + themeApi.saveContent = (path, content) => { return service({ url: `${baseUrl}/files/content`, @@ -144,6 +154,17 @@ themeApi.saveContent = (path, content) => { }) } +themeApi.saveContent = (themeId, path, content) => { + return service({ + url: `${baseUrl}/${themeId}/files/content`, + data: { + path: path, + content: content + }, + method: 'put' + }) +} + themeApi.reload = () => { return service({ url: `${baseUrl}/reload`, @@ -161,4 +182,4 @@ themeApi.exists = template => { }) } -export default themeApi +export default themeApi \ No newline at end of file diff --git a/src/views/dashboard/Dashboard.vue b/src/views/dashboard/Dashboard.vue index 9c9df374..c99cd7af 100644 --- a/src/views/dashboard/Dashboard.vue +++ b/src/views/dashboard/Dashboard.vue @@ -373,7 +373,7 @@ export default { data() { return { photoList: [], - showMoreOptions: false, + // showMoreOptions: false, startVal: 0, logType: logApi.logType, activityLoading: true, @@ -450,18 +450,18 @@ export default { next() }, methods: { - handlerPhotoUploadSuccess(response, file) { - var callData = response.data.data - var photo = { - name: callData.name, - url: callData.path, - thumbnail: callData.thumbPath, - suffix: callData.suffix, - width: callData.width, - height: callData.height - } - this.journalPhotos.push(photo) - }, + // handlerPhotoUploadSuccess(response, file) { + // var callData = response.data.data + // var photo = { + // name: callData.name, + // url: callData.path, + // thumbnail: callData.thumbPath, + // suffix: callData.suffix, + // width: callData.width, + // height: callData.height + // } + // this.journalPhotos.push(photo) + // }, listLatestPosts() { postApi.listLatest(5).then(response => { this.postData = response.data.data @@ -498,13 +498,13 @@ export default { this.$message.success('发表成功!') this.journal = {} // this.photoList = [] - this.showMoreOptions = false + // this.showMoreOptions = false }) }, - handleUploadPhotoWallClick() { - // 是否显示上传照片墙组件 - this.showMoreOptions = !this.showMoreOptions - }, + // handleUploadPhotoWallClick() { + // // 是否显示上传照片墙组件 + // this.showMoreOptions = !this.showMoreOptions + // }, handleShowLogDrawer() { this.logDrawerVisible = true this.loadLogs() diff --git a/src/views/interface/ThemeEdit.vue b/src/views/interface/ThemeEdit.vue index d316866a..424fe1b9 100644 --- a/src/views/interface/ThemeEdit.vue +++ b/src/views/interface/ThemeEdit.vue @@ -55,6 +55,7 @@ @@ -83,7 +84,7 @@ export default { lineNumbers: true, line: true }, - files: [], + files: null, file: {}, content: '', themes: [], @@ -112,6 +113,7 @@ export default { }) }, onSelectTheme(themeId) { + this.files = null themeApi.listFiles(themeId).then(response => { this.files = response.data.data }) @@ -141,14 +143,14 @@ export default { } }) } - themeApi.getContent(file.path).then(response => { + themeApi.getContent(this.selectedTheme.id,file.path).then(response => { this.content = response.data.data this.file = file this.buttonDisabled = false }) }, handlerSaveContent() { - themeApi.saveContent(this.file.path, this.content).then(response => { + themeApi.saveContent(this.selectedTheme.id,this.file.path, this.content).then(response => { this.$message.success('保存成功!') }) } diff --git a/src/views/sheet/internal/JournalList.vue b/src/views/sheet/internal/JournalList.vue index e2521a4a..5bbbe41f 100644 --- a/src/views/sheet/internal/JournalList.vue +++ b/src/views/sheet/internal/JournalList.vue @@ -313,12 +313,12 @@ export default { // photoList: [], // 编辑图片时回显所需对象 // previewVisible: false, showMoreOptions: false, - previewPhoto: { - // 图片预览信息临时对象 - name: '', - description: '', - url: '' - }, + // previewPhoto: { + // // 图片预览信息临时对象 + // name: '', + // description: '', + // url: '' + // }, title: '发表', listLoading: false, visible: false,