mirror of
https://github.com/doocs/md.git
synced 2024-10-30 15:57:50 +08:00
feat: update images upload feature
更新图片上传功能
This commit is contained in:
parent
f93a001507
commit
723a870ae3
@ -111,10 +111,11 @@ let app = new Vue({
|
||||
// 图片上传结束
|
||||
uploaded(response, file, fileList) {
|
||||
if (response.success) {
|
||||
// 上传成功
|
||||
// 上传成功,获取光标
|
||||
const cursor = this.editor.getCursor();
|
||||
const imageUrl = response.data.url
|
||||
const markdownImage = `![](${imageUrl})`
|
||||
// 将 Markdown 形式的 URL 插入编辑框光标所在位置
|
||||
this.editor.replaceSelection(`\n${markdownImage}\n`, cursor);
|
||||
this.refresh();
|
||||
|
||||
|
@ -34,9 +34,10 @@
|
||||
<div id="app" class="container">
|
||||
<el-container>
|
||||
<el-header class="top">
|
||||
<!-- 图片上传 -->
|
||||
<el-upload action="https://cors-anywhere.herokuapp.com/https://sm.ms/api/v2/upload"
|
||||
headers="{'Content-Type': 'multipart/form-data'}" :show-file-list="false" name="smfile" :on-success="uploaded"
|
||||
:on-error="failed">
|
||||
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">
|
||||
<i class="el-icon-upload" size="medium"> </i>
|
||||
</el-upload>
|
||||
<el-form size="mini" class="ctrl" :inline=true>
|
||||
|
Loading…
Reference in New Issue
Block a user