Skip to content

Commit

Permalink
支持自定义压缩
Browse files Browse the repository at this point in the history
支持链接自动复制到剪切板
支持多种设置记忆
增加仅删除上传成功图片,上传失败图片重试
优化粘贴上传时的文件命名
优化多处细节,提升使用体验
  • Loading branch information
MarSeventh committed Sep 28, 2024
1 parent db0385b commit 3bc21d3
Show file tree
Hide file tree
Showing 33 changed files with 87 additions and 16 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CloudFlare-ImgBed

免费图片托管解决方案,基于 Cloudflare Pages 和 Telegram (文件大小不建议超过20MB,过大图片会**自动压缩**)。
免费图片托管解决方案,基于 Cloudflare Pages 和 Telegram (文件大小不超过50MB,过大图片会**自动压缩**)。

**体验地址**[Sanyue ImgHub (demo-cloudflare-imgbed.pages.dev)](https://demo-cloudflare-imgbed.pages.dev/)

Expand Down Expand Up @@ -33,15 +33,13 @@

免费图片托管解决方案(支持存储绝大多数常见格式的**图片、视频、动图**等),具有**后台管理、图片审查****登录鉴权****页面自定义****多种方式及多文件上传****多文件及多格式链接复制**等功能(详见[第2章](#2.Features))。

此外,拖拽上传的方式**并没有严格限制文件类型**,理论上你可以上传**任何**不超过20MB的文件,但是暂时不会针对图片和视频外的文件进行特殊优化和适配。
此外,拖拽上传的方式**并没有严格限制文件类型**,理论上你可以上传**任何**不超过50MB的文件,但是暂时不会针对图片和视频外的文件进行特殊优化和适配。

![](https://alist.sanyue.site/d/imgbed/202408191757569.png)
![image-20240928171020782](https://alist.sanyue.site/d/imgbed/202409281710586.png)

![](https://alist.sanyue.site/d/imgbed/202407221043832.png)
![image-20240928171101034](https://alist.sanyue.site/d/imgbed/202409281711303.png)

![](https://alist.sanyue.site/d/imgbed/202408211614665.png)

![](https://alist.sanyue.site/d/imgbed/202408211614780.png)
![image-20240928171136160](https://alist.sanyue.site/d/imgbed/202409281711243.png)

![](https://alist.sanyue.site/d/imgbed/202409071737881.png)

Expand All @@ -57,12 +55,13 @@
- **人性化上传**

- 支持绝大多数常见**图片、视频、动图**
- 支持一键切换上传方式**拖拽点击、粘贴**
- 支持多种上传方式**拖拽点击、粘贴**
- 粘贴上传支持**文件****URL**
- 支持批量上传(不限同时选择文件数量,但为了保证稳定性,同时处于上传状态的文件最多为10个)
- 上传显示实时上传进度
- **上传后图片无需手动点击,可直接展示在管理页面中**
- **过大图片在前端进行压缩,提升上传稳定性和加载性能**
- 支持自定义压缩质量,自定义开启前后端压缩功能

- **多样化复制**

Expand Down Expand Up @@ -227,7 +226,7 @@ API格式:
| ------------ | ------------------------------------------------------------ |
| **接口功能** | 上传图片或视频 |
| **请求方法** | POST |
| **请求参数** | **Query参数**:<br />`authCode`,string类型,即为你设置的认证码<br />**Body参数(application/form-data)**:<br />`file`,file类型,你要上传的文件 |
| **请求参数** | **Query参数**:<br />`authCode`,string类型,即为你设置的认证码<br />`serverCompress`,boolean类型,表示是否开启服务端压缩(仅针对图片文件生效)<br />**Body参数(application/form-data)**:<br />`file`,file类型,你要上传的文件 |
| **返回响应** | `data[0].src`为获得的图片链接(注意不包含域名,需要自己添加) |
> **请求示例**:
Expand Down Expand Up @@ -359,13 +358,13 @@ API格式:
7. ~~完善登录逻辑,后端增加认证码校验接口(2024.8.21已完成)~~
8. ~~支持URL粘贴上传(2024.8.23已完成)~~
9. ~~支持大于5MB的图片上传前自动压缩(2024.8.26已完成)~~
10. 上传页面右下角工具栏样式重构,支持上传页自定义压缩(上传前+存储端)
10. ~~上传页面右下角工具栏样式重构,支持上传页自定义压缩(上传前+存储端)~~(2024.9.28已完成
11. 重构管理端,认证+显示效果优化,增加图片详情页
12. 管理端增加访问量统计,IP记录、IP黑名单等
13. 上传页面点击链接,自动复制到剪切板
14. 上传设置记忆(上传方式、链接格式等)
15. 若未设置密码,无需跳转进入登录页
16. 增加仅删除上传成功图片、上传失败图片重试
13. ~~上传页面点击链接,自动复制到剪切板~~(2024.9.27已完成)
14. ~~上传设置记忆(上传方式、链接格式等)~~(2024.9.27已完成,**两种上传方式合并**
15. ~~若未设置密码,无需跳转进入登录页~~(2024.9.27已完成)
16. ~~增加仅删除上传成功图片、上传失败图片重试~~(2024.9.28已完成)
17. ~~优化粘贴上传时文件命名方法(2024.9.26已完成)~~
### 4.2Fix Bugs👻
Expand Down
1 change: 1 addition & 0 deletions css/538.af586728.css

Large diffs are not rendered by default.

Binary file added css/538.af586728.css.gz
Binary file not shown.
1 change: 1 addition & 0 deletions css/782.8fd7696b.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added css/782.8fd7696b.css.gz
Binary file not shown.
1 change: 1 addition & 0 deletions css/880.f72995a0.css

Large diffs are not rendered by default.

Binary file added css/880.f72995a0.css.gz
Binary file not shown.
1 change: 1 addition & 0 deletions css/986.0b7ed77b.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added css/986.0b7ed77b.css.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion functions/file/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function onRequest(context) { // Contents of context object

try {
const headers = new Headers(response.headers);
headers.set('Content-Disposition', `inline; filename="${encodedFileName}"`);
headers.set('Content-Disposition', `inline; filename="${encodedFileName}"; filename*=UTF-8''${encodedFileName}`);
if (fileType) {
headers.set('Content-Type', fileType);
}
Expand Down
9 changes: 9 additions & 0 deletions functions/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export async function onRequestPost(context) { // Contents of context object
sendFunction = {'url': 'sendAnimation', 'type': 'animation'};
}

// 从参数中获取serverCompress,如果为false,则使用sendDocument接口
if (url.searchParams.get('serverCompress') === 'false') {
sendFunction = {'url': 'sendDocument', 'type': 'document'};
}

// 优先从请求 URL 获取 authCode
let authCode = url.searchParams.get('authCode');
// 如果 URL 中没有 authCode,从 Referer 中获取
Expand Down Expand Up @@ -210,6 +215,10 @@ function getFile(response) {
return getFileDetails(response.result.video);
}

if (response.result.audio) {
return getFileDetails(response.result.audio);
}

if (response.result.document) {
return getFileDetails(response.result.document);
}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/logo.png"><title>Sanyue ImgHub</title><script defer="defer" src="/js/app.40c62b88.js"></script><link href="/css/app.def7ef9b.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but sanyue_imghub doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/logo.png"><title>Sanyue ImgHub</title><script defer="defer" src="/js/app.5e5c7c7e.js"></script><link href="/css/app.def7ef9b.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but sanyue_imghub doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
Binary file modified index.html.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions js/538.4708c14c.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added js/538.4708c14c.js.gz
Binary file not shown.
1 change: 1 addition & 0 deletions js/538.4708c14c.js.map

Large diffs are not rendered by default.

Binary file added js/538.4708c14c.js.map.gz
Binary file not shown.
Loading

0 comments on commit 3bc21d3

Please sign in to comment.