Support select theme on theme edit page.

pull/40/head
ruibaby 2019-09-11 20:49:52 +08:00
parent c96d962c75
commit d96a7f6a73
4 changed files with 51 additions and 28 deletions

View File

@ -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) => { themeApi.saveContent = (path, content) => {
return service({ return service({
url: `${baseUrl}/files/content`, 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 = () => { themeApi.reload = () => {
return service({ return service({
url: `${baseUrl}/reload`, url: `${baseUrl}/reload`,

View File

@ -373,7 +373,7 @@ export default {
data() { data() {
return { return {
photoList: [], photoList: [],
showMoreOptions: false, // showMoreOptions: false,
startVal: 0, startVal: 0,
logType: logApi.logType, logType: logApi.logType,
activityLoading: true, activityLoading: true,
@ -450,18 +450,18 @@ export default {
next() next()
}, },
methods: { methods: {
handlerPhotoUploadSuccess(response, file) { // handlerPhotoUploadSuccess(response, file) {
var callData = response.data.data // var callData = response.data.data
var photo = { // var photo = {
name: callData.name, // name: callData.name,
url: callData.path, // url: callData.path,
thumbnail: callData.thumbPath, // thumbnail: callData.thumbPath,
suffix: callData.suffix, // suffix: callData.suffix,
width: callData.width, // width: callData.width,
height: callData.height // height: callData.height
} // }
this.journalPhotos.push(photo) // this.journalPhotos.push(photo)
}, // },
listLatestPosts() { listLatestPosts() {
postApi.listLatest(5).then(response => { postApi.listLatest(5).then(response => {
this.postData = response.data.data this.postData = response.data.data
@ -498,13 +498,13 @@ export default {
this.$message.success('发表成功!') this.$message.success('发表成功!')
this.journal = {} this.journal = {}
// this.photoList = [] // this.photoList = []
this.showMoreOptions = false // this.showMoreOptions = false
}) })
}, },
handleUploadPhotoWallClick() { // handleUploadPhotoWallClick() {
// // //
this.showMoreOptions = !this.showMoreOptions // this.showMoreOptions = !this.showMoreOptions
}, // },
handleShowLogDrawer() { handleShowLogDrawer() {
this.logDrawerVisible = true this.logDrawerVisible = true
this.loadLogs() this.loadLogs()

View File

@ -55,6 +55,7 @@
</a-select> </a-select>
</template> </template>
<theme-file <theme-file
v-if="files"
:files="files" :files="files"
@listenToSelect="handleSelectFile" @listenToSelect="handleSelectFile"
/> />
@ -83,7 +84,7 @@ export default {
lineNumbers: true, lineNumbers: true,
line: true line: true
}, },
files: [], files: null,
file: {}, file: {},
content: '', content: '',
themes: [], themes: [],
@ -112,6 +113,7 @@ export default {
}) })
}, },
onSelectTheme(themeId) { onSelectTheme(themeId) {
this.files = null
themeApi.listFiles(themeId).then(response => { themeApi.listFiles(themeId).then(response => {
this.files = response.data.data 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.content = response.data.data
this.file = file this.file = file
this.buttonDisabled = false this.buttonDisabled = false
}) })
}, },
handlerSaveContent() { 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('保存成功!') this.$message.success('保存成功!')
}) })
} }

View File

@ -313,12 +313,12 @@ export default {
// photoList: [], // // photoList: [], //
// previewVisible: false, // previewVisible: false,
showMoreOptions: false, showMoreOptions: false,
previewPhoto: { // previewPhoto: {
// // //
name: '', // name: '',
description: '', // description: '',
url: '' // url: ''
}, // },
title: '发表', title: '发表',
listLoading: false, listLoading: false,
visible: false, visible: false,