feat: update images upload feature

更新图片上传功能
This commit is contained in:
yanglbme 2019-12-01 10:19:15 +08:00
parent 723a870ae3
commit edfa28d0f3
2 changed files with 10 additions and 3 deletions

View File

@ -117,13 +117,13 @@ let app = new Vue({
const markdownImage = `![](${imageUrl})` const markdownImage = `![](${imageUrl})`
// 将 Markdown 形式的 URL 插入编辑框光标所在位置 // 将 Markdown 形式的 URL 插入编辑框光标所在位置
this.editor.replaceSelection(`\n${markdownImage}\n`, cursor); this.editor.replaceSelection(`\n${markdownImage}\n`, cursor);
this.refresh();
this.$message({ this.$message({
showClose: true, showClose: true,
message: '图片插入成功', message: '图片插入成功',
type: 'success' type: 'success'
}); });
this.refresh();
} else { } else {
// 上传失败 // 上传失败
@ -137,6 +137,13 @@ let app = new Vue({
failed(error, file, fileList) { failed(error, file, fileList) {
console.log(error) console.log(error)
}, },
uploading(event, file, fileList) {
this.$message({
showClose: true,
message: '图片上传中...',
type: 'info'
});
},
// 刷新右侧预览 // 刷新右侧预览
refresh() { refresh() {
this.output = this.renderWeChat(this.editor.getValue(0)); this.output = this.renderWeChat(this.editor.getValue(0));

View File

@ -37,7 +37,7 @@
<!-- 图片上传 --> <!-- 图片上传 -->
<el-upload action="https://cors-anywhere.herokuapp.com/https://sm.ms/api/v2/upload" <el-upload action="https://cors-anywhere.herokuapp.com/https://sm.ms/api/v2/upload"
headers="{'Content-Type': 'multipart/form-data'}" :show-file-list="false" :multiple="false" headers="{'Content-Type': 'multipart/form-data'}" :show-file-list="false" :multiple="false"
accept=".jpg,.jpeg,.png,.gif" :limit="1" name="smfile" :on-success="uploaded" :on-error="failed"> accept=".jpg,.jpeg,.png,.gif" :limit="1" name="smfile" :on-success="uploaded" :on-error="failed" :on-progress="uploading">
<i class="el-icon-upload" size="medium">&nbsp;</i> <i class="el-icon-upload" size="medium">&nbsp;</i>
</el-upload> </el-upload>
<el-form size="mini" class="ctrl" :inline=true> <el-form size="mini" class="ctrl" :inline=true>