Refactor option api

pull/9/head
johnniang 2019-05-07 09:51:33 +08:00
parent 55b12ca6b0
commit 38fb0306b6
6 changed files with 37 additions and 32 deletions

15
src/api/mail.js Normal file
View File

@ -0,0 +1,15 @@
import service from '@/utils/service'
const baseUrl = '/api/admin/mails'
const mailApi = {}
mailApi.test = mailData => {
return service({
url: `${baseUrl}/test`,
method: 'post',
data: mailData
})
}
export default mailApi

View File

@ -1,40 +1,25 @@
import service from '@/utils/service'
const baseUrl = '/api/admin/options/map_view'
const baseUrl = '/api/admin/options'
const optionApi = {}
optionApi.listAll = () => {
optionApi.listAll = keys => {
return service({
url: baseUrl,
method: 'get'
})
}
optionApi.listByKeys = keys => {
return service({
url: `/api/admin/options/map_keys`,
method: 'get',
url: `${baseUrl}/map_view`,
params: {
keys: keys
}
key: keys
},
method: 'get'
})
}
optionApi.save = options => {
return service({
url: `${baseUrl}/saving`,
url: `${baseUrl}/map_view/saving`,
method: 'post',
data: options
})
}
optionApi.testMail = param => {
return service({
url: `/api/admin/options/test_mail`,
method: 'post',
data: param
})
}
export default optionApi

View File

@ -69,7 +69,7 @@ export default {
optionVisible: true,
user: {},
options: [],
keys: 'blog_url'
keys: ['blog_url']
}
},
mounted() {
@ -114,7 +114,7 @@ export default {
})
},
loadOptions() {
optionApi.listByKeys(this.keys).then(response => {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
}

View File

@ -288,7 +288,7 @@
</a-col>
</a-row>
<a-divider class="divider-transparent"/>
<a-divider class="divider-transparent" />
<div class="bottom-control">
<a-popconfirm
title="你确定要清空所有操作日志?"

View File

@ -490,13 +490,13 @@
label="收件人:"
:wrapper-col="wrapperCol"
>
<a-input v-model="mailParam.to"/>
<a-input v-model="mailParam.to" />
</a-form-item>
<a-form-item
label="主题:"
:wrapper-col="wrapperCol"
>
<a-input v-model="mailParam.subject"/>
<a-input v-model="mailParam.subject" />
</a-form-item>
<a-form-item
label="内容:"
@ -509,7 +509,10 @@
/>
</a-form-item>
<a-form-item>
<a-button type="primary" @click="handleTestMailClick"></a-button>
<a-button
type="primary"
@click="handleTestMailClick"
>发送</a-button>
</a-form-item>
</a-form>
</a-tab-pane>
@ -570,7 +573,9 @@
<script>
import AttachmentSelectDrawer from '../attachment/components/AttachmentSelectDrawer'
import optionApi from '@/api/option'
import mailApi from '@/api/mail'
import attachmentApi from '@/api/attachment'
export default {
components: {
AttachmentSelectDrawer
@ -610,7 +615,7 @@ export default {
})
},
handleAttachChange(e) {
switch (e) {
switch (e.toUppper()) {
case 'LOCAL':
case 'SMMS':
this.upyunFormHidden = false
@ -645,7 +650,7 @@ export default {
this.faviconDrawerVisible = true
},
handleTestMailClick() {
optionApi.testMail(this.mailParam).then(response => {
mailApi.testMail(this.mailParam).then(response => {
this.$message.info(response.data.message)
})
},

View File

@ -166,7 +166,7 @@ export default {
},
attachment: {},
options: [],
keys: 'blog_url'
keys: ['blog_url']
}
},
computed: {
@ -190,7 +190,7 @@ export default {
})
},
loadOptions() {
optionApi.listByKeys(this.keys).then(response => {
optionApi.listAll(this.keys).then(response => {
this.options = response.data.data
})
},