mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
feat: update images upload feature
更新图片上传功能
This commit is contained in:
parent
723a870ae3
commit
edfa28d0f3
@ -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));
|
||||||
|
@ -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"> </i>
|
<i class="el-icon-upload" size="medium"> </i>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<el-form size="mini" class="ctrl" :inline=true>
|
<el-form size="mini" class="ctrl" :inline=true>
|
||||||
|
Loading…
Reference in New Issue
Block a user