feat: performance optimization.

pull/59/head
ruibaby 2019-11-29 21:26:33 +08:00
parent 9bd3d37a24
commit f3574ef134
2 changed files with 27 additions and 97 deletions

View File

@ -76,23 +76,23 @@ attachmentApi.type = {
type: 'smms', type: 'smms',
text: 'SM.MS' text: 'SM.MS'
}, },
UPYUN: { UPOSS: {
type: 'upyun', type: 'upyun',
text: '又拍云' text: '又拍云'
}, },
QNYUN: { QINIUOSS: {
type: 'qnyun', type: 'qnyun',
text: '七牛云' text: '七牛云'
}, },
ALIYUN: { ALIOSS: {
type: 'aliyun', type: 'aliyun',
text: '阿里云' text: '阿里云'
}, },
BAIDUYUN: { BAIDUBOS: {
type: 'baiduyun', type: 'baiduyun',
text: '百度云' text: '百度云'
}, },
TENCENTYUN: { TENCENTCOS: {
type: 'tencentyun', type: 'tencentyun',
text: '腾讯云' text: '腾讯云'
} }

View File

@ -222,10 +222,7 @@
/> />
</a-form-item> </a-form-item>
<a-form-item label="存储位置:"> <a-form-item label="存储位置:">
<a-select <a-select v-model="options.attachment_type">
@change="handleAttachChange"
v-model="options.attachment_type"
>
<a-select-option <a-select-option
v-for="item in Object.keys(attachmentType)" v-for="item in Object.keys(attachmentType)"
:key="item" :key="item"
@ -234,8 +231,8 @@
</a-select> </a-select>
</a-form-item> </a-form-item>
<div <div
class="smmsForm" id="smmsForm"
v-show="smmsFormVisible" v-show="options.attachment_type === 'SMMS'"
> >
<a-form-item label="Secret Token"> <a-form-item label="Secret Token">
<a-input-password <a-input-password
@ -245,8 +242,8 @@
</a-form-item> </a-form-item>
</div> </div>
<div <div
class="upyunForm" id="upOssForm"
v-show="upyunFormVisible" v-show="options.attachment_type === 'UPOSS'"
> >
<a-form-item label="绑定域名协议:"> <a-form-item label="绑定域名协议:">
<a-select v-model="options.oss_upyun_domain_protocol"> <a-select v-model="options.oss_upyun_domain_protocol">
@ -286,8 +283,8 @@
</a-form-item> </a-form-item>
</div> </div>
<div <div
class="qnyunForm" id="qiniuOssForm"
v-show="qnyunFormVisible" v-show="options.attachment_type === 'QINIUOSS'"
> >
<a-form-item label="绑定域名协议:"> <a-form-item label="绑定域名协议:">
<a-select v-model="options.oss_qiniu_domain_protocol"> <a-select v-model="options.oss_qiniu_domain_protocol">
@ -303,7 +300,7 @@
</a-form-item> </a-form-item>
<a-form-item label="区域:"> <a-form-item label="区域:">
<a-auto-complete <a-auto-complete
:dataSource="qiniuZones" :dataSource="qiniuOssZones"
v-model="options.oss_qiniu_zone" v-model="options.oss_qiniu_zone"
allowClear allowClear
/> />
@ -334,8 +331,8 @@
</a-form-item> </a-form-item>
</div> </div>
<div <div
class="aliyunForm" id="aliOssForm"
v-show="aliyunFormVisible" v-show="options.attachment_type === 'ALIOSS'"
> >
<a-form-item label="绑定域名协议:"> <a-form-item label="绑定域名协议:">
<a-select v-model="options.oss_aliyun_domain_protocol"> <a-select v-model="options.oss_aliyun_domain_protocol">
@ -378,8 +375,8 @@
</a-form-item> </a-form-item>
</div> </div>
<div <div
class="baiduyunForm" id="baiduBosForm"
v-show="baiduyunFormVisible" v-show="options.attachment_type === 'BAIDUBOS'"
> >
<a-form-item label="绑定域名协议:"> <a-form-item label="绑定域名协议:">
<a-select v-model="options.bos_baiduyun_domain_protocol"> <a-select v-model="options.bos_baiduyun_domain_protocol">
@ -422,8 +419,8 @@
</a-form-item> </a-form-item>
</div> </div>
<div <div
class="tencentyunForm" id="tencentCosForm"
v-show="tencentyunFormVisible" v-show="options.attachment_type === 'TENCENTCOS'"
> >
<a-form-item label="绑定域名协议:"> <a-form-item label="绑定域名协议:">
<a-select v-model="options.cos_tencentyun_domain_protocol"> <a-select v-model="options.cos_tencentyun_domain_protocol">
@ -445,7 +442,7 @@
</a-form-item> </a-form-item>
<a-form-item label="区域:"> <a-form-item label="区域:">
<a-auto-complete <a-auto-complete
:dataSource="tencentyunRegions" :dataSource="tencentCosRegions"
v-model="options.cos_tencentyun_region" v-model="options.cos_tencentyun_region"
allowClear allowClear
/> />
@ -663,17 +660,11 @@ export default {
sm: { span: 12 }, sm: { span: 12 },
xs: { span: 24 } xs: { span: 24 }
}, },
smmsFormVisible: false,
upyunFormVisible: false,
qnyunFormVisible: false,
aliyunFormVisible: false,
baiduyunFormVisible: false,
tencentyunFormVisible: false,
logoDrawerVisible: false, logoDrawerVisible: false,
faviconDrawerVisible: false, faviconDrawerVisible: false,
options: [], options: [],
mailParam: {}, mailParam: {},
tencentyunRegions: [ tencentCosRegions: [
{ {
text: '北京一区', text: '北京一区',
value: 'ap-beijing-1' value: 'ap-beijing-1'
@ -699,7 +690,7 @@ export default {
value: 'ap-chongqing' value: 'ap-chongqing'
} }
], ],
qiniuZones: [ qiniuOssZones: [
{ {
text: '自动选择', text: '自动选择',
value: 'auto' value: 'auto'
@ -752,7 +743,6 @@ export default {
loadFormOptions() { loadFormOptions() {
optionApi.listAll().then(response => { optionApi.listAll().then(response => {
this.options = response.data.data this.options = response.data.data
this.handleAttachChange(this.options['attachment_type'])
}) })
}, },
handleSaveOptions() { handleSaveOptions() {
@ -794,7 +784,7 @@ export default {
return return
} }
break break
case 'UPYUN': case 'UPOSS':
if (!this.options.oss_upyun_domain) { if (!this.options.oss_upyun_domain) {
this.$notification['error']({ this.$notification['error']({
message: '提示', message: '提示',
@ -831,7 +821,7 @@ export default {
return return
} }
break break
case 'QNYUN': case 'QINIUOSS':
if (!this.options.oss_qiniu_domain) { if (!this.options.oss_qiniu_domain) {
this.$notification['error']({ this.$notification['error']({
message: '提示', message: '提示',
@ -861,7 +851,7 @@ export default {
return return
} }
break break
case 'ALIYUN': case 'ALIOSS':
if (!this.options.oss_aliyun_bucket_name) { if (!this.options.oss_aliyun_bucket_name) {
this.$notification['error']({ this.$notification['error']({
message: '提示', message: '提示',
@ -891,7 +881,7 @@ export default {
return return
} }
break break
case 'BAIDUYUN': case 'BAIDUBOS':
if (!this.options.bos_baiduyun_bucket_name) { if (!this.options.bos_baiduyun_bucket_name) {
this.$notification['error']({ this.$notification['error']({
message: '提示', message: '提示',
@ -921,7 +911,7 @@ export default {
return return
} }
break break
case 'TENCENTYUN': case 'TENCENTCOS':
if (!this.options.cos_tencentyun_bucket_name) { if (!this.options.cos_tencentyun_bucket_name) {
this.$notification['error']({ this.$notification['error']({
message: '提示', message: '提示',
@ -1017,66 +1007,6 @@ export default {
this.$message.success('保存成功!') this.$message.success('保存成功!')
}) })
}, },
handleAttachChange(e) {
switch (e) {
case 'LOCAL':
this.upyunFormVisible = false
this.qnyunFormVisible = false
this.aliyunFormVisible = false
this.baiduyunFormVisible = false
this.tencentyunFormVisible = false
this.smmsFormVisible = false
break
case 'SMMS':
this.smmsFormVisible = true
this.upyunFormVisible = false
this.qnyunFormVisible = false
this.aliyunFormVisible = false
this.baiduyunFormVisible = false
this.tencentyunFormVisible = false
break
case 'UPYUN':
this.smmsFormVisible = false
this.upyunFormVisible = true
this.qnyunFormVisible = false
this.aliyunFormVisible = false
this.baiduyunFormVisible = false
this.tencentyunFormVisible = false
break
case 'QNYUN':
this.smmsFormVisible = false
this.qnyunFormVisible = true
this.upyunFormVisible = false
this.aliyunFormVisible = false
this.baiduyunFormVisible = false
this.tencentyunFormVisible = false
break
case 'ALIYUN':
this.smmsFormVisible = false
this.aliyunFormVisible = true
this.qnyunFormVisible = false
this.upyunFormVisible = false
this.baiduyunFormVisible = false
this.tencentyunFormVisible = false
break
case 'BAIDUYUN':
this.smmsFormVisible = false
this.aliyunFormVisible = false
this.qnyunFormVisible = false
this.upyunFormVisible = false
this.baiduyunFormVisible = true
this.tencentyunFormVisible = false
break
case 'TENCENTYUN':
this.smmsFormVisible = false
this.aliyunFormVisible = false
this.qnyunFormVisible = false
this.upyunFormVisible = false
this.baiduyunFormVisible = false
this.tencentyunFormVisible = true
break
}
},
handleSelectLogo(data) { handleSelectLogo(data) {
this.$set(this.options, 'blog_logo', encodeURI(data.path)) this.$set(this.options, 'blog_logo', encodeURI(data.path))
this.logoDrawerVisible = false this.logoDrawerVisible = false