Skip to content

Commit

Permalink
v1.8.14 发布日期:2020-08-25
Browse files Browse the repository at this point in the history
- 解决 Gitee 图片粘贴名字重复问题
- 提示大小超过 1 MB
  • Loading branch information
penpenguan committed Aug 26, 2020
1 parent 16fffc6 commit 75067d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v1.8.14 发布日期:2020-08-25

- 解决 Gitee 图片粘贴名字重复问题
- 提示大小超过 1 MB

v1.8.13 发布日期:2020-08-24

- 新增 Gitee 图床支持
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "markdown-nice",
"author": "mdnice",
"description": "a markdown editor with the function of style edition",
"version": "1.8.13",
"version": "1.8.14",
"private": false,
"main": "lib/Lib.js",
"module": "lib/Lib.js",
Expand Down
9 changes: 7 additions & 2 deletions src/utils/imageHosting.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ export const giteeUpload = ({
}) => {
showUploadNoti();

if (file.size / 1024 / 1024 > 1) {
message.warn("有图片超过 1 MB,无法使用");
}

const config = JSON.parse(window.localStorage.getItem(GITEE_IMAGE_HOSTING));

const base64Reader = new FileReader();
Expand All @@ -347,7 +351,8 @@ export const giteeUpload = ({
const seperator = "-";
const dir = date.getFullYear() + seperator + (date.getMonth() + 1) + seperator + date.getDate();

const url = `https://gitee.com/api/v5/repos/${config.username}/${config.repo}/contents/${dir}/${file.name}`;
const dateFilename = new Date().getTime() + "-" + file.name;
const url = `https://gitee.com/api/v5/repos/${config.username}/${config.repo}/contents/${dir}/${dateFilename}`;

formData.append("content", base64);
formData.append("access_token", config.token);
Expand All @@ -370,7 +375,7 @@ export const giteeUpload = ({
if (response.code === "exception") {
throw response.message;
}
const names = response.content.name.split(".");
const names = file.name.split(".");
names.pop();
const filename = names.join(".");
const image = {
Expand Down

0 comments on commit 75067d3

Please sign in to comment.