mirror of
https://github.com/doocs/md.git
synced 2024-10-31 00:07: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) {
|
uploaded(response, file, fileList) {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
// 上传成功
|
// 上传成功,获取光标
|
||||||
const cursor = this.editor.getCursor();
|
const cursor = this.editor.getCursor();
|
||||||
const imageUrl = response.data.url
|
const imageUrl = response.data.url
|
||||||
const markdownImage = `![](${imageUrl})`
|
const markdownImage = `![](${imageUrl})`
|
||||||
|
// 将 Markdown 形式的 URL 插入编辑框光标所在位置
|
||||||
this.editor.replaceSelection(`\n${markdownImage}\n`, cursor);
|
this.editor.replaceSelection(`\n${markdownImage}\n`, cursor);
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
|
||||||
|
@ -34,9 +34,10 @@
|
|||||||
<div id="app" class="container">
|
<div id="app" class="container">
|
||||||
<el-container>
|
<el-container>
|
||||||
<el-header class="top">
|
<el-header class="top">
|
||||||
|
<!-- 图片上传 -->
|
||||||
<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" name="smfile" :on-success="uploaded"
|
headers="{'Content-Type': 'multipart/form-data'}" :show-file-list="false" :multiple="false"
|
||||||
:on-error="failed">
|
accept=".jpg,.jpeg,.png,.gif" :limit="1" name="smfile" :on-success="uploaded" :on-error="failed">
|
||||||
<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