Skip to content

Commit 336c4d1

Browse files
committed
feat: update images upload function
更新图片上传功能,使用新图床,速度更快,感谢图壳
1 parent 17e0a7d commit 336c4d1

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Markdown 文档自动即时渲染为微信图文,让你不再为微信文章
3838

3939
![custom](./assets/images/doocs-md-custom-css.gif)
4040

41+
![doocs-md-upload-image](./assets/images/doocs-md-upload-image.gif)
42+
4143
## 示例文章
4244
- [ES6 特性快速扫盲](https://mp.weixin.qq.com/s/I3EzOO0skf8xDCGtyYM5Lg)
4345
- [GitHub 项目持续本地化,交给它来做,准没错!](https://mp.weixin.qq.com/s/KO4xHr4EI0YfjF0hiT3pbw)
626 KB
Loading

assets/scripts/editor.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ let app = new Vue({
100100
}
101101
},
102102
methods: {
103-
104103
renderWeChat(source) {
105104
let output = marked(source, { renderer: this.wxRenderer.getRenderer(this.status) });
106105
// 去除第一行的 margin-top
@@ -148,7 +147,7 @@ let app = new Vue({
148147
if (response.success) {
149148
// 上传成功,获取光标
150149
const cursor = this.editor.getCursor();
151-
const imageUrl = response.data.url
150+
const imageUrl = response.data
152151
const markdownImage = `![](${imageUrl})`
153152
// 将 Markdown 形式的 URL 插入编辑框光标所在位置
154153
this.editor.replaceSelection(`\n${markdownImage}\n`, cursor);
@@ -157,9 +156,7 @@ let app = new Vue({
157156
message: '图片插入成功',
158157
type: 'success'
159158
});
160-
161159
this.refresh();
162-
163160
} else {
164161
// 上传失败
165162
this.$message({
@@ -172,13 +169,6 @@ let app = new Vue({
172169
failed(error, file, fileList) {
173170
console.log(error)
174171
},
175-
uploading(event, file, fileList) {
176-
this.$message({
177-
showClose: true,
178-
message: '图片上传中...',
179-
type: 'info'
180-
});
181-
},
182172
// 刷新右侧预览
183173
refresh() {
184174
this.output = this.renderWeChat(this.editor.getValue(0));

index.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@
4343
<el-container>
4444
<el-header class="top">
4545
<!-- 图片上传 -->
46-
<el-upload action="https://cors-anywhere.herokuapp.com/https://sm.ms/api/v2/upload"
47-
headers="{'Content-Type': 'multipart/form-data'}" :show-file-list="false" :multiple="false"
48-
accept=".jpg,.jpeg,.png,.gif" :limit="1" name="smfile" :on-success="uploaded" :on-error="failed"
49-
:on-progress="uploading">
46+
<el-upload action="https://imgkr.com/api/files/upload"
47+
headers="{'Content-Type': 'multipart/form-data'}" :show-file-list="false" :multiple="true"
48+
accept=".jpg,.jpeg,.png,.gif" :limit="5" name="file" :on-success="uploaded" :on-error="failed">
5049
<el-tooltip class="item" effect="dark" content="点击上传图片" placement="bottom-start">
5150
<i class="el-icon-upload" size="medium">&nbsp;</i>
5251
</el-tooltip>

0 commit comments

Comments
 (0)