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

View File

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

View File

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

View File

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

View File

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