diff --git a/README.md b/README.md
index 75cff48..150ebed 100644
--- a/README.md
+++ b/README.md
@@ -48,9 +48,10 @@ Markdown 文档自动即时渲染为微信图文,让你不再为微信文章
| --- | ----------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
| 1 | 默认图床 | 否 | - |
| 2 | GitHub 图床 | 配置 `Repo`、`Token` 参数 | [如何获取 GitHub token?](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) |
-| 3 | 阿里云 OSS | 配置 `AccessKey ID`、`AccessKey Secret`、`Bucket`、`Region` 等参数 | [如何使用阿里云 OSS?](https://help.aliyun.com/document_detail/31883.html) |
-| 4 | 腾讯云 COS | 配置 `SecretId`、`SecretKey`、`Bucket`、`Region` 等参数 | [如何使用腾讯云 COS?](https://cloud.tencent.com/document/product/436/38484) |
-| 5 | 七牛云 Kodo | 配置 `AccessKey`、`SecretKey`、`Bucket`、`Domain`、`Region` 等参数 | [如何使用七牛云 Kodo?](https://developer.qiniu.com/kodo) |
+| 3 | Gitee 图床 | 配置 `Repo`、`Token` 参数 | 不支持上传超过 1MB 的图片 |
+| 4 | 阿里云 OSS | 配置 `AccessKey ID`、`AccessKey Secret`、`Bucket`、`Region` 等参数 | [如何使用阿里云 OSS?](https://help.aliyun.com/document_detail/31883.html) |
+| 5 | 腾讯云 COS | 配置 `SecretId`、`SecretKey`、`Bucket`、`Region` 等参数 | [如何使用腾讯云 COS?](https://cloud.tencent.com/document/product/436/38484) |
+| 6 | 七牛云 Kodo | 配置 `AccessKey`、`SecretKey`、`Bucket`、`Domain`、`Region` 等参数 | [如何使用七牛云 Kodo?](https://developer.qiniu.com/kodo) |
![select-and-change-color-theme](./public/assets/images/select-and-change-color-theme.gif)
diff --git a/src/api/file.js b/src/api/file.js
index a9196f2..9798b0f 100644
--- a/src/api/file.js
+++ b/src/api/file.js
@@ -33,6 +33,8 @@ function fileUpload(content, file) {
return txCOSFileUpload(file);
case "qiniu":
return qiniuUpload(file);
+ case "gitee":
+ return giteeUpload(content, file.name);
case "github":
default:
return ghFileUpload(content, file.name);
@@ -116,6 +118,37 @@ async function ghFileUpload(content, filename) {
: res.content.download_url;
}
+async function giteeUpload(content, filename) {
+ const giteeConfig = JSON.parse(localStorage.getItem("giteeConfig"));
+ const repoUrl = giteeConfig.repo
+ .replace("https://gitee.com/", "")
+ .replace("http://gitee.com/", "")
+ .replace("gitee.com/", "")
+ .split("/");
+ const username = repoUrl[0];
+ const repo = repoUrl[1];
+ const date = new Date();
+ const dir =
+ date.getFullYear() +
+ "/" +
+ (date.getMonth() + 1).toString().padStart(2, "0") +
+ "/" +
+ date.getDate().toString().padStart(2, "0");
+ const dateFilename =
+ new Date().getTime() + "-" + uuidv4() + "." + filename.split(".")[1];
+ const res = await fetch({
+ url: `https://gitee.com/api/v5/repos/${username}/${repo}/contents/${dir}/${dateFilename}`,
+ method: "POST",
+ data: {
+ access_token: giteeConfig.accessToken,
+ branch: giteeConfig.branch || "master",
+ content: content,
+ message: `Upload by ${window.location.href}`,
+ },
+ });
+ return encodeURI(res.content.download_url);
+}
+
async function aliOSSFileUpload(content, filename) {
const dateFilename =
new Date().getTime() + "-" + uuidv4() + "." + filename.split(".")[1];
diff --git a/src/components/CodemirrorEditor/uploadImgDialog.vue b/src/components/CodemirrorEditor/uploadImgDialog.vue
index 5c8e6bf..e423353 100644
--- a/src/components/CodemirrorEditor/uploadImgDialog.vue
+++ b/src/components/CodemirrorEditor/uploadImgDialog.vue
@@ -81,6 +81,49 @@
+
+
+
+
+
+
+
+
+
+
+ 请在
+ Gitee「设置->安全设置->私人令牌」中生成
+
+
+ 保存配置
+
+
+