Refactor attachment handler.

pull/40/head
ruibaby 2019-09-06 22:51:28 +08:00
parent 49f364bd9f
commit fc2e75f2e3
3 changed files with 104 additions and 71 deletions

View File

@ -142,28 +142,17 @@ export default {
if (!this.postToStage.originalContent) { if (!this.postToStage.originalContent) {
this.postToStage.originalContent = '开始编辑...' this.postToStage.originalContent = '开始编辑...'
} }
this.createOrUpdatePost(
() => this.$message.success('保存草稿成功!'),
() => this.$message.success('保存草稿成功!'),
false
)
},
createOrUpdatePost(createSuccess, updateSuccess, autoSave) {
if (this.postToStage.id) { if (this.postToStage.id) {
// Update the post // Update the post
postApi.update(this.postToStage.id, this.postToStage, autoSave).then(response => { postApi.update(this.postToStage.id, this.postToStage, false).then(response => {
this.$log.debug('Updated post', response.data.data) this.$log.debug('Updated post', response.data.data)
if (updateSuccess) { this.$message.success('保存草稿成功!')
updateSuccess()
}
}) })
} else { } else {
// Create the post // Create the post
postApi.create(this.postToStage, autoSave).then(response => { postApi.create(this.postToStage, false).then(response => {
this.$log.debug('Created post', response.data.data) this.$log.debug('Created post', response.data.data)
if (createSuccess) { this.$message.success('保存草稿成功!')
createSuccess()
}
this.postToStage = response.data.data this.postToStage = response.data.data
}) })
} }
@ -177,7 +166,7 @@ export default {
if (responseObject.status === 200) { if (responseObject.status === 200) {
var HaloEditor = this.$refs.md var HaloEditor = this.$refs.md
HaloEditor.$img2Url(pos, encodeURI(responseObject.data.path)) HaloEditor.$img2Url(pos, encodeURI(responseObject.data.path))
this.$message.success('图片上传成功') this.$message.success('图片上传成功')
} else { } else {
this.$message.error('图片上传失败:' + responseObject.message) this.$message.error('图片上传失败:' + responseObject.message)
} }

View File

@ -132,26 +132,15 @@ export default {
if (!this.sheetToStage.originalContent) { if (!this.sheetToStage.originalContent) {
this.sheetToStage.originalContent = '开始编辑...' this.sheetToStage.originalContent = '开始编辑...'
} }
this.createOrUpdateSheet(
() => this.$message.success('保存草稿成功!'),
() => this.$message.success('保存草稿成功!'),
false
)
},
createOrUpdateSheet(createSuccess, updateSuccess, autoSave) {
if (this.sheetToStage.id) { if (this.sheetToStage.id) {
sheetApi.update(this.sheetToStage.id, this.sheetToStage, autoSave).then(response => { sheetApi.update(this.sheetToStage.id, this.sheetToStage, false).then(response => {
this.$log.debug('Updated sheet', response.data.data) this.$log.debug('Updated sheet', response.data.data)
if (updateSuccess) { this.$message.success('保存草稿成功!')
updateSuccess()
}
}) })
} else { } else {
sheetApi.create(this.sheetToStage, autoSave).then(response => { sheetApi.create(this.sheetToStage, false).then(response => {
this.$log.debug('Created sheet', response.data.data) this.$log.debug('Created sheet', response.data.data)
if (createSuccess) { this.$message.success('保存草稿成功!')
createSuccess()
}
this.sheetToStage = response.data.data this.sheetToStage = response.data.data
}) })
} }
@ -165,7 +154,7 @@ export default {
if (responseObject.status === 200) { if (responseObject.status === 200) {
var HaloEditor = this.$refs.md var HaloEditor = this.$refs.md
HaloEditor.$img2Url(pos, encodeURI(responseObject.data.path)) HaloEditor.$img2Url(pos, encodeURI(responseObject.data.path))
this.$message.success('图片上传成功') this.$message.success('图片上传成功')
} else { } else {
this.$message.error('图片上传失败:' + responseObject.message) this.$message.error('图片上传失败:' + responseObject.message)
} }

View File

@ -95,14 +95,12 @@
label="博客描述:" label="博客描述:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.seo_description" /> <a-input
type="textarea"
:autosize="{ minRows: 5 }"
v-model="options.seo_description"
/>
</a-form-item> </a-form-item>
<!-- <a-form-item
label="百度推送 Token "
:wrapper-col="wrapperCol"
>
<a-input v-model="options.seo_baidu_token" />
</a-form-item> -->
<a-form-item> <a-form-item>
<a-button <a-button
type="primary" type="primary"
@ -287,16 +285,13 @@
v-show="upyunFormVisible" v-show="upyunFormVisible"
> >
<a-form-item <a-form-item
label="域名:" label="绑定域名:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-tooltip <a-input
:trigger="['focus']" v-model="options.oss_upyun_domain"
placement="right" placeholder="需要加上 http:// 或者 https://"
title="需要加上 http:// 或者 https://" />
>
<a-input v-model="options.oss_upyun_domain" />
</a-tooltip>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="空间名称:" label="空间名称:"
@ -329,19 +324,34 @@
label="图片处理策略:" label="图片处理策略:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.oss_upyun_style_rule" /> <a-input
v-model="options.oss_upyun_style_rule"
placeholder="间隔标识符+图片处理版本名称"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="缩略图处理策略:" label="缩略图处理策略:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.oss_upyun_thumbnail_style_rule" /> <a-input
v-model="options.oss_upyun_thumbnail_style_rule"
placeholder="间隔标识符+图片处理版本名称,一般为后台展示所用"
/>
</a-form-item> </a-form-item>
</div> </div>
<div <div
class="qnyunForm" class="qnyunForm"
v-show="qnyunFormVisible" v-show="qnyunFormVisible"
> >
<a-form-item
label="绑定域名:"
:wrapper-col="wrapperCol"
>
<a-input
v-model="options.oss_qiniu_domain"
placeholder="需要加上 http:// 或者 https://"
/>
</a-form-item>
<a-form-item <a-form-item
label="区域:" label="区域:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
@ -355,18 +365,6 @@
<a-select-option value="as0">东南亚</a-select-option> <a-select-option value="as0">东南亚</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item
label="域名:"
:wrapper-col="wrapperCol"
>
<a-tooltip
:trigger="['focus']"
placement="right"
title="需要加上 http:// 或者 https://"
>
<a-input v-model="options.oss_qiniu_domain" />
</a-tooltip>
</a-form-item>
<a-form-item <a-form-item
label="Access Key" label="Access Key"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
@ -386,30 +384,51 @@
label="Bucket" label="Bucket"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.oss_qiniu_bucket" /> <a-input
v-model="options.oss_qiniu_bucket"
placeholder="存储空间名称"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="图片处理策略:" label="图片处理策略:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.oss_qiniu_style_rule" /> <a-input
v-model="options.oss_qiniu_style_rule"
placeholder="样式分隔符+图片处理样式名称"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="缩略图处理策略:" label="缩略图处理策略:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.oss_qiniu_thumbnail_style_rule" /> <a-input
v-model="options.oss_qiniu_thumbnail_style_rule"
placeholder="样式分隔符+图片处理样式名称,一般为后台展示所用"
/>
</a-form-item> </a-form-item>
</div> </div>
<div <div
class="aliyunForm" class="aliyunForm"
v-show="aliyunFormVisible" v-show="aliyunFormVisible"
> >
<a-form-item
label="绑定域名:"
:wrapper-col="wrapperCol"
>
<a-input
v-model="options.oss_aliyun_domain"
placeholder="如不填写,路径根域名将为 Bucket + EndPoint"
/>
</a-form-item>
<a-form-item <a-form-item
label="Bucket" label="Bucket"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.oss_aliyun_bucket_name" /> <a-input
v-model="options.oss_aliyun_bucket_name"
placeholder="存储空间名称"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="EndPoint地域节点" label="EndPoint地域节点"
@ -436,24 +455,42 @@
label="图片处理策略:" label="图片处理策略:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.oss_aliyun_style_rule" /> <a-input
v-model="options.oss_aliyun_style_rule"
placeholder="请到阿里云控制台的图片处理获取"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="缩略图处理策略:" label="缩略图处理策略:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.oss_aliyun_thumbnail_style_rule" /> <a-input
v-model="options.oss_aliyun_thumbnail_style_rule"
placeholder="请到阿里云控制台的图片处理获取,一般为后台展示所用"
/>
</a-form-item> </a-form-item>
</div> </div>
<div <div
class="baiduyunForm" class="baiduyunForm"
v-show="baiduyunFormVisible" v-show="baiduyunFormVisible"
> >
<a-form-item
label="绑定域名:"
:wrapper-col="wrapperCol"
>
<a-input
v-model="options.bos_baiduyun_domain"
placeholder="如不填写,路径根域名将为 Bucket + EndPoint"
/>
</a-form-item>
<a-form-item <a-form-item
label="Bucket" label="Bucket"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.bos_baiduyun_bucket_name" /> <a-input
v-model="options.bos_baiduyun_bucket_name"
placeholder="存储空间名称"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="EndPoint地域节点" label="EndPoint地域节点"
@ -480,24 +517,42 @@
label="图片处理策略:" label="图片处理策略:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.bos_baiduyun_style_rule" /> <a-input
v-model="options.bos_baiduyun_style_rule"
placeholder="请到百度云控制台的图片处理获取"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="缩略图处理策略:" label="缩略图处理策略:"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.bos_baiduyun_thumbnail_style_rule" /> <a-input
v-model="options.bos_baiduyun_thumbnail_style_rule"
placeholder="请到百度云控制台的图片处理获取,一般为后台展示所用"
/>
</a-form-item> </a-form-item>
</div> </div>
<div <div
class="tencentyunForm" class="tencentyunForm"
v-show="tencentyunFormVisible" v-show="tencentyunFormVisible"
> >
<a-form-item
label="绑定域名:"
:wrapper-col="wrapperCol"
>
<a-input
v-model="options.cos_tencentyun_domain"
placeholder="如不填写,路径根域名将为 Bucket + 区域地址"
/>
</a-form-item>
<a-form-item <a-form-item
label="Bucket" label="Bucket"
:wrapper-col="wrapperCol" :wrapper-col="wrapperCol"
> >
<a-input v-model="options.cos_tencentyun_bucket_name" /> <a-input
v-model="options.cos_tencentyun_bucket_name"
placeholder="存储桶名称"
/>
</a-form-item> </a-form-item>
<a-form-item <a-form-item
label="区域:" label="区域:"