Compare commits

...
209 Commits
Author SHA1 Message Date
lan 222c048e38 fix: 基础目录设置 2024-01-18 18:46:16 +08:00
lan 31de5b7ea1 test:1 2023-08-16 13:03:56 +08:00
lan 9b51d592c2 update:后台新增端口设置 2023-01-31 21:07:16 +08:00
lan 4c507fc3cb update:readme 2023-01-19 21:56:19 +08:00
lan fce5194e04 fix:admin 2023-01-18 22:11:58 +08:00
lan 517b7b8a3a fix:admin 2023-01-18 22:11:28 +08:00
lan 8b952eddbf fix:admin 2023-01-18 22:08:01 +08:00
lan 75a94311e4 fix:upload 2023-01-18 11:29:23 +08:00
lan ce828ebb89 fix:upload 2023-01-18 11:19:08 +08:00
lan e593fd8d51 update:readme 2023-01-18 10:56:33 +08:00
lan 3b44b2273c update:readme 2023-01-18 10:53:34 +08:00
lan a21c3a1f6e update:增强iplimit 2023-01-18 10:41:02 +08:00
lan de1096acc4 update:增强iplimit 2023-01-16 22:58:50 +08:00
lan 3864335fca fix:admin 2023-01-16 22:58:09 +08:00
lan 8f3fa8af74 fix:admin 2023-01-16 22:55:53 +08:00
lan 7ed8b68ee8 Merge remote-tracking branch 'origin/master' 2023-01-16 22:55:14 +08:00
lan b6c0bc04fa fix:admin 2023-01-16 22:53:39 +08:00
lan ef4175f191 update:保留文件换行 2023-01-16 20:20:46 +08:00
lan a8052c647d update:保留文件换行 2023-01-16 20:19:52 +08:00
lan 68dd33043e update:保留文件换行 2023-01-16 18:53:45 +08:00
lan 511bfa1632 add:后台分享本地文件 2023-01-16 18:50:46 +08:00
lan f87d61b793 add:后台分享本地文件 2023-01-16 18:47:19 +08:00
lan 1fb758a201 update:后台修改配置信息 2023-01-16 17:54:08 +08:00
lan 9473cb35af fix:后台下载 2023-01-16 16:16:46 +08:00
lan ef2a6551b9 fix:后台下载 2023-01-16 16:14:05 +08:00
lan ee5beb2261 重构中,配置存入数据库,第一次智能生成随机后台地址,登录密码 2023-01-16 16:03:25 +08:00
vastsa c19da62941 Merge pull request #39 from ZHYCarge/master
add:支持使用阿里云OSS进行对象存储服务
2023-01-16 11:22:06 +08:00
ZHYCarge 487895af7e update: 对阿里云OSS的私有Bucket支持访问 2023-01-16 10:38:08 +08:00
ZHYCarge 1b26b03758 add:支持使用阿里云OSS进行对象存储服务
fix:删除utils中未使用的第三方库chardet
2023-01-15 22:06:01 +08:00
lan cfa865c6cd update:update default banner img by @yanyuo 2023-01-14 15:55:14 +08:00
lan fb932f08e4 update:update default banner img by @yanyuo 2023-01-14 15:54:22 +08:00
lan 8f404fbfed update:update default banner img by @yanyuo 2023-01-14 15:51:13 +08:00
lan 3da4fc0ea7 fix:message text color 2023-01-10 13:47:04 +08:00
lan c7253ba874 fix:message text color 2023-01-10 13:42:42 +08:00
lan 2bb32bc59c fix:message text color 2023-01-10 13:40:07 +08:00
lan c9785b92d7 delete:encoding convert 2023-01-10 13:37:32 +08:00
lan 455602d323 update:index.html 2023-01-09 23:10:38 +08:00
lan 65fa3c9a7d update:readme 2023-01-09 23:05:55 +08:00
lan c87e388ad3 Merge remote-tracking branch 'origin/master' 2023-01-09 15:45:23 +08:00
lan 77b50f950f fix:readme 2023-01-09 15:43:33 +08:00
vastsa 46310bb4b8 Create FUNDING.yml 2023-01-08 14:09:08 +08:00
lan 34327f4a53 update:encoding convert 2023-01-07 12:09:25 +08:00
vastsa fbba00fda7 Merge pull request #34 from essesoul/essesoul
自动安装缺少的包,兼容UTF-8
2023-01-03 22:49:36 +08:00
essesoul ea52327e49 兼容UTF-8编码
自动转换UTF-8编码的.env文件为GBK编码
允许用户在根目录配置.env文件
(优先级:.env大于data/.env)
2023-01-03 21:10:38 +08:00
essesoul 7f44093c91 自动安装缺少的python包
自动安装缺少的python包
2023-01-03 19:30:23 +08:00
vastsa 1bbe7f4d5d Merge pull request #31 from mrwoowoo/patch-1
fix:修复二维码分享链接错误
2022-12-30 18:20:46 +08:00
mrwoowoo b2825cf088 修复二维码分享链接错误 2022-12-30 16:59:03 +08:00
lan e9c34a3710 fix:issues/26 2022-12-29 16:51:19 +08:00
lan 3344f471e3 update:删除过期文件夹的方式 2022-12-27 22:45:44 +08:00
lan c8ac6bb76b fix:游客上传 2022-12-27 20:28:52 +08:00
lan e66e668616 fix:上传前检测+上传次数限制 2022-12-27 13:29:54 +08:00
lan c3022bff78 fix:上传前检测+上传次数限制 2022-12-27 13:27:23 +08:00
lan f070bdcece add:输入框清空按钮 2022-12-27 10:01:10 +08:00
vastsa 58e8407e7d Merge pull request #20 from ZHYCarge/master
fix: 修改文件存放路径的拼接方式
2022-12-27 07:15:51 +08:00
ZHYCarge 5462584188 fix: 修改文件存放路径的拼接方式
fix: 修改文件存放路径的拼接方式
2022-12-26 21:12:45 +08:00
vastsa 143d4794bc Merge pull request #19 from ZHYCarge/master
add:当最后一个文件被删除时,删除整个存放目录
2022-12-24 16:11:40 +08:00
ZHYCarge 58c1d3d44b add:当最后一个文件被删除时,删除整个存放目录 2022-12-23 18:09:22 +08:00
lan 757e8ec16a add:上传前进行检测 2022-12-23 12:32:18 +08:00
lan 2fc95ebc7e update:some change 2022-12-23 12:07:46 +08:00
lan 64f476e6db fix:文件不存在删除报错 2022-12-22 20:15:04 +08:00
lan 0d5e26f752 update:开启默认上传 2022-12-22 13:00:44 +08:00
lan b33671a018 update:分开寄取文件箱 2022-12-22 12:15:42 +08:00
lan 56cf08ccd1 update:分开寄取文件箱 2022-12-22 12:14:41 +08:00
lan f4089877ed update:分开寄取文件箱 2022-12-22 12:11:32 +08:00
lan 248e6b8292 update:index.html 2022-12-22 08:47:04 +08:00
lan ab3971f911 update:arm docker 2022-12-21 22:18:44 +08:00
lan 6c07f9a5ab update:arm docker 2022-12-21 22:12:14 +08:00
vastsa f94a918253 Update readme.md 2022-12-21 22:09:37 +08:00
lan eec2ec6354 update:arm docker 2022-12-21 22:05:53 +08:00
lan 330b34953d update:dark theme 2022-12-21 19:43:54 +08:00
lan 0433507a9c update:dark theme 2022-12-21 19:32:39 +08:00
lan 63105579f7 update:dark theme 2022-12-21 19:19:42 +08:00
lan 255a2149b0 update:dark theme 2022-12-21 19:10:51 +08:00
lan 0b12aad4eb update:dark theme 2022-12-21 18:55:30 +08:00
lan 7767ade2f3 update:readme 2022-12-21 17:01:27 +08:00
lan c15bf9563c fix:复制提示词 2022-12-21 14:33:26 +08:00
lan 99529b69ee Merge remote-tracking branch 'origin/master' 2022-12-20 12:09:33 +08:00
lan d6029e4899 fix:max-width 2022-12-20 11:46:48 +08:00
vastsa f80d50981c fix:error 2022-12-19 22:34:19 +08:00
vastsa dfb7367100 fix:error 2022-12-19 22:33:51 +08:00
vastsa d764cb48e3 fix:admin error 2022-12-19 22:28:59 +08:00
lan 14b6f0e9a7 fix:admin error 2022-12-19 22:26:30 +08:00
lan f01d39c1c9 update:background-color 2022-12-19 22:00:04 +08:00
lan 59805273bf add:管理页面页码+Banner配置 2022-12-19 18:50:36 +08:00
lan a58102a61b add:管理页面页码+Banner配置 2022-12-19 18:16:47 +08:00
lan b40c77e49f add:管理页面页码+Banner配置 2022-12-19 18:14:18 +08:00
lan c686822c43 add:管理页面页码+Banner配置 2022-12-19 18:07:51 +08:00
lan 4ed95f8b64 add:管理页面页码+Banner配置 2022-12-19 18:05:56 +08:00
lan d47da11916 add:管理页面页码+Banner配置 2022-12-19 18:05:38 +08:00
lan 8a93dd5e38 add:管理页面页码+Banner配置 2022-12-19 18:01:50 +08:00
lan 1c938948fd add:上传页面新增banner 2022-12-19 15:21:24 +08:00
lan 141008639a add:点击复制取件码,文本 2022-12-19 14:32:48 +08:00
lan dd3267cf1f add:点击复制取件码 2022-12-19 13:59:44 +08:00
lan 3d6f5ba9f4 update:index.html 2022-12-17 14:02:27 +08:00
vastsa 422ae8adff Merge pull request #15 from BrackRat/master
修改文本,按钮和部分布局方便用户理解存取逻辑
2022-12-17 13:44:16 +08:00
“BrackRat” cb340b6b22 修改文本,按钮和部分布局方便用户理解逻辑 2022-12-17 12:40:31 +08:00
lan b3533e897a update:code 2022-12-16 12:21:47 +08:00
lan 0bc73796e7 update:code 2022-12-16 12:20:58 +08:00
lan 594c105190 update:code 2022-12-16 12:19:00 +08:00
lan 6caca3cb7b Merge remote-tracking branch 'origin/master' 2022-12-16 11:51:20 +08:00
lan 2d9348c293 update:静态资源 2022-12-16 11:51:13 +08:00
vastsa ec6939f824 Update readme.md
私有化提示
2022-12-16 11:38:58 +08:00
lan 6d83e94c2f update:update readme 2022-12-16 09:23:56 +08:00
lan 3c0376b63c Merge remote-tracking branch 'origin/master' 2022-12-16 02:22:27 +08:00
lan f021673961 update:rename asserts and update docker file 2022-12-16 02:21:49 +08:00
vastsa de190e6345 Update readme.md
update
2022-12-16 01:56:38 +08:00
lan f9daa3cab3 update:去除取件判断过期删除 2022-12-15 17:14:39 +08:00
lan 965384500a add:前端判断文件大小
add:自定义删除过期文件间隔,修复因间隔过短导致还没下载文件就没了
2022-12-15 16:59:25 +08:00
lan eb9a656ee1 add:前端判断文件大小
add:自定义删除过期文件间隔,修复因间隔过短导致还没下载文件就没了
2022-12-15 16:49:23 +08:00
lan 5543811c20 add:前端判断文件大小
add:自定义删除过期文件间隔,修复因间隔过短导致还没下载文件就没了
2022-12-15 16:34:18 +08:00
lan 1f14997e4a update:readme 2022-12-14 17:22:35 +08:00
lan 5297146a63 add:demo 2022-12-14 13:21:00 +08:00
lan d77dcb3f92 fix:admin list text 2022-12-14 12:31:48 +08:00
lan 133e85fa49 fix:更新获取IP的方式 2022-12-14 12:28:09 +08:00
lan a432f8d80f fix:暂时移除alembic,需要默认创建数据库 2022-12-14 11:22:24 +08:00
lan 2a102bfb1f fix:暂时移除alembic,需要默认创建数据库 2022-12-14 11:16:30 +08:00
lan 1994ba5917 update:关闭docs,redoc 2022-12-14 10:21:11 +08:00
lan 68175f9583 update:限制管理员上传,最长天数配置 2022-12-14 09:55:04 +08:00
lan 0caabe3ee8 update:docker version 2022-12-14 09:36:50 +08:00
lan 5c350cbfc6 update:docker version 2022-12-14 09:35:18 +08:00
lan 0a200da28b update:docker version 2022-12-14 01:32:46 +08:00
lan 7f2c1c9e7c update:english readme and future plan 2022-12-14 01:16:45 +08:00
lan 12d28ec691 add:开关上传功能,关闭则仅允许管理员上传 2022-12-14 01:13:48 +08:00
lan 65ad220bb4 update:readme 2022-12-14 00:16:12 +08:00
lan 585bf0948c update:readme 2022-12-14 00:02:30 +08:00
lan a258bb4ea3 update:readme 2022-12-13 23:10:38 +08:00
lan d8985db3e1 fix: no database file 2022-12-13 22:19:37 +08:00
vastsa a17a7e1d58 Merge pull request #12 from veoco/master
新增 alembic 管理数据库架构
2022-12-13 22:13:39 +08:00
vastsa 63d60022d2 Merge branch 'master' into master 2022-12-13 22:13:27 +08:00
lan 1e2d83aeb6 update:修改文件结构,存储文件不再暴露,自定义数据都放在/data文件夹,方便docker 2022-12-13 22:07:14 +08:00
lan fadb2ffeeb update:修改文件结构,存储文件不再暴露,自定义数据都放在/data文件夹,方便docker 2022-12-13 22:06:29 +08:00
lan cc2a02cc65 update:docker script 2022-12-13 21:37:09 +08:00
lan 676ef1e924 update:docker script 2022-12-13 21:20:09 +08:00
lan b948263519 fix:upload failure 2022-12-13 21:16:41 +08:00
veoco 8ffddd5870 新增 alembic 管理数据库架构 2022-12-13 21:03:15 +08:00
lan 2d7331269c update:新增限制时间内上传次数,移除IP黑名单列表过期IP,防止炸内存 2022-12-13 19:16:29 +08:00
lan 11fb809b62 fix:keyboard double input 2022-12-13 18:51:14 +08:00
lan 7ea84f0941 update:adjust file structure 2022-12-13 17:55:25 +08:00
lan c9ec40803d update:adjust file structure 2022-12-13 17:50:22 +08:00
vastsa 9ecd2c2770 Merge pull request #11 from veoco/master
调整文件的大小计算和写入方法
2022-12-13 17:05:31 +08:00
lan e6fa174c0b update:docker image 2022-12-13 15:12:52 +08:00
veoco 66d9e432bc 调整文件删除方式 2022-12-13 14:18:02 +08:00
lan b300463f54 fix:打不开取件框 2022-12-13 14:13:40 +08:00
veoco bcf0be3d12 调整文件大小计算和写入方法 2022-12-13 12:45:28 +08:00
lan d4209bb3f7 lan 2022-12-13 11:29:33 +08:00
lan 2ba3057f72 test 2022-12-13 11:28:55 +08:00
lan-air bdf508264b logo 2022-12-13 11:25:42 +08:00
lan-air 4218caeaf7 完善手机版上传文本 2022-12-13 10:50:48 +08:00
lan-air 24ad5e08ca 重构index.html 2022-12-13 10:48:09 +08:00
vastsa 31f67fae3f Merge pull request #10 from veoco/master
重写用户登录和 IP 检查并重定义状态码
2022-12-13 08:01:40 +08:00
lan-air 27fc665239 update version 2022-12-13 07:52:20 +08:00
lan-air 541d49d636 update version 2022-12-13 07:46:46 +08:00
veoco 68881c6df0 重写用户登录和 IP 检查并重定义状态码 2022-12-12 22:30:03 +08:00
lan-air fb80d26b70 add setting port 2022-12-12 15:15:17 +08:00
vastsa 9cf0d9418d Merge pull request #7 from veoco/master
新增存储引擎统一文件读写
2022-12-12 11:47:49 +08:00
veoco 4e069486bf 新增存储引擎统一文件读写 2022-12-12 11:18:55 +08:00
lan-air 8935da813b .gitattributes 2022-12-12 11:11:45 +08:00
lan-air 387a3babfd readme.md 2022-12-12 01:02:50 +08:00
lan-air 42dedfae1e 完善文档,以及docker新增文件夹映射 2022-12-11 23:06:28 +08:00
lan-air cfd2989bc0 完善文档,以及docker新增文件夹映射 2022-12-11 22:47:33 +08:00
lan-air 31b61a2f7a 完善文档,以及docker新增文件夹映射 2022-12-11 22:47:08 +08:00
lan-air 802b8a0a8f 完善文档,以及docker新增文件夹映射 2022-12-11 22:35:10 +08:00
vastsa ef89de6294 Merge pull request #6 from veoco/master
增加定时清理过期文件
2022-12-11 22:00:12 +08:00
veoco 74a835f8b6 增加独立配置文件 2022-12-11 21:07:39 +08:00
veoco 2ef6c752ee 增加定时清理过期文件 2022-12-11 18:55:02 +08:00
lan-air bec3eb2ea1 完善 aiosqlite 异步数据库驱动 2022-12-11 18:15:54 +08:00
lan-air ae7aa63e2a 完善 aiosqlite 异步数据库驱动 2022-12-11 18:14:41 +08:00
lan-air b999073da4 完善 aiosqlite 异步数据库驱动 2022-12-11 18:03:46 +08:00
lan-air e5d18a5bf3 完善 aiosqlite 异步数据库驱动 2022-12-11 17:41:54 +08:00
vastsa d25a92199f Merge pull request #1 from veoco/master
使用 aiosqlite 驱动异步化数据库操作
2022-12-11 17:19:00 +08:00
vastsa b7315bb840 Merge branch 'master' into master 2022-12-11 17:18:06 +08:00
vastsa ea647519c6 Update readme.md
update readme
2022-12-11 15:09:50 +08:00
lan-air 1dbcd8bd57 隐藏真实文件地址 2022-12-11 15:09:02 +08:00
lan-air dd39423d1a 隐藏真实文件地址 2022-12-11 15:04:38 +08:00
lan-air ff831e39f4 隐藏真实文件地址 2022-12-11 14:55:29 +08:00
lan-air 0883eafa49 隐藏真实文件地址 2022-12-11 14:52:28 +08:00
lan-air 1dc6a741b6 隐藏真实文件地址 2022-12-11 14:40:14 +08:00
veoco f4e6dfef0d 数据库操作改为异步 2022-12-11 14:04:25 +08:00
veoco 195c6f9ae4 添加 aiosqlite 异步数据库驱动 2022-12-11 14:03:46 +08:00
lan-air 710bb55a93 修改取件框margin 2022-12-11 12:11:10 +08:00
lan-air 8ab74728ac 改个名 2022-12-11 11:50:17 +08:00
lan-air 1cbb7534f3 开源协议 2022-12-11 11:07:38 +08:00
lan-air 132aeee4cc 更新输入取件后,弹出取件码,和寄件文件箱改为取件码 2022-12-11 10:39:54 +08:00
lan-air 896992aff6 Merge remote-tracking branch 'origin/master' 2022-12-11 01:54:58 +08:00
vastsa 2eb2c341eb Update readme.md
改个名
2022-12-11 01:52:59 +08:00
lan-air ce6bc749c1 update readme.md 2022-12-11 01:31:50 +08:00
lan-air 5f99457d14 update readme.md 2022-12-11 00:50:08 +08:00
lan-air e5eb071c2d update readme.md 2022-12-11 00:48:36 +08:00
lan-air 9b8b1e81fe 修复文件次数1直接删除 2022-12-11 00:08:43 +08:00
lan-air 77b7c58885 Merge remote-tracking branch 'origin/master' 2022-12-11 00:02:23 +08:00
lan-air 94fc0e856b 修复文件次数1直接删除 2022-12-11 00:02:12 +08:00
vastsa 5cbb122ddf Update readme.md
修复取件数据
2022-12-10 23:51:01 +08:00
lan-air 5eec46605b 修复取件问题 2022-12-10 23:47:36 +08:00
lan-air b273d38b31 新增部署教程地址 2022-12-10 21:59:09 +08:00
lan-air 90d1ab7330 main.py 启动 2022-12-10 21:43:12 +08:00
lan-air f4ba56138d 新增取件码过期条件,上传大小限制 2022-12-10 21:11:25 +08:00
lan-air 7b045e97f5 delete file from disk 2022-12-10 14:39:33 +08:00
lan-air 0fd38d40f9 update index.html 2022-12-10 14:26:10 +08:00
lan-air 6a04c0f11b fix read html file code 2022-12-10 14:04:48 +08:00
lan-air 6bd7f31700 精简requirement 2022-12-10 13:30:58 +08:00
lan-air e290b46165 修复点击,拖拽上穿 2022-12-10 09:25:06 +08:00
lan-air d74d6cddcc 资源本地化,管理面板,口令转二维码 2022-12-10 02:03:08 +08:00
lan-air 7d2de3466b 资源本地化,管理面板,口令转二维码 2022-12-10 02:02:50 +08:00
lan-air c3b141f650 Merge remote-tracking branch 'origin/master' 2022-12-10 01:55:19 +08:00
lan-air de40b82a82 资源本地化,管理面板,口令转二维码 2022-12-10 01:52:00 +08:00
vastsa ecea266bad Update readme.md
update readme.md
2022-12-09 23:45:23 +08:00
lan-air 14653ab4c9 fix dockerfile port expose 2022-12-09 23:37:04 +08:00
lan-air 3f18af15ed update readme.md 2022-12-09 22:01:00 +08:00
lan-air cea831f89b update index return 2022-12-09 20:31:54 +08:00
45 changed files with 2003 additions and 303 deletions

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
*.js linguist-language=python
*.css linguist-language=python
*.html linguist-language=python
+4
View File
@@ -0,0 +1,4 @@
# These are supported funding model platforms
github: [ vastsa ]
custom: [ https://share.lanol.cn ]
+3 -3
View File
@@ -1,7 +1,7 @@
media/
logs/
.idea
static/
/data
__pycache__/
*.py[cod]
*$py.class
@@ -111,7 +111,7 @@ celerybeat.pid
*.sage.py
# Environments
.env
data/.env
.venv
env/
venv/
@@ -150,6 +150,6 @@ for_test.py
.html
/evaluate/temp.py
/evaluation/back.json
.env*
data/.env
.backup/
/cloc-1.64.exe
+5 -7
View File
@@ -1,13 +1,11 @@
FROM python:3.9.5
FROM python:3.9.5-slim-buster
LABEL author="Lan"
LABEL email="vast@tom.com"
LABEL version="1.0"
LABEL version="6"
COPY . /app
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
WORKDIR /app
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
EXPOSE 123456
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "12345"]
RUN pip install -r requirements.txt
EXPOSE 12345
CMD ["python","main.py"]
+165
View File
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
View File
Whitespace-only changes.
+57
View File
@@ -0,0 +1,57 @@
import datetime
from sqlalchemy import Boolean, Column, Integer, String, DateTime, JSON, Text, select, insert, delete
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.ext.asyncio import create_async_engine
from sqlalchemy.ext.asyncio.session import AsyncSession
from settings import settings
engine = create_async_engine(settings.DATABASE_URL)
Base = declarative_base()
class Options(Base):
__tablename__ = 'options'
id = Column(Integer, primary_key=True, index=True)
key = Column(String, unique=True, index=True)
value = Column(JSON)
class Codes(Base):
__tablename__ = "codes"
id = Column(Integer, primary_key=True, index=True)
code = Column(String(10), unique=True, index=True)
key = Column(String(30), unique=True)
name = Column(String(500))
size = Column(Integer)
type = Column(String(20))
text = Column(Text)
used = Column(Boolean, default=False)
count = Column(Integer, default=-1)
use_time = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
exp_time = Column(DateTime, nullable=True)
async def init_models(s):
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
print(
f'初始化数据库成功!\n'
f'如您未配置.env文件,将为您随机生成信息\n'
f'您的后台地址为:/{settings.ADMIN_ADDRESS}\n'
f'您的管理员密码为:{settings.ADMIN_PASSWORD}\n'
f'请尽快修改后台信息!\n'
f'FileCodeBox https://github.com/vastsa/FileCodeBox'
)
await settings.updates(await conn.execute(select(Options).filter()))
async def get_config(key):
async with engine.begin() as conn:
return await conn.scalar(select(Options.value).filter(Options.key == key))
async def get_session():
async with AsyncSession(engine, expire_on_commit=False) as s:
yield s
+52
View File
@@ -0,0 +1,52 @@
from typing import Union
from datetime import datetime, timedelta
from fastapi import Header, HTTPException, Request
from settings import settings
async def admin_required(pwd: Union[str, None] = Header(default=None), request: Request = None):
if 'share' in request.url.path:
if pwd != settings.ADMIN_PASSWORD and not settings.ENABLE_UPLOAD:
raise HTTPException(status_code=403, detail='本站上传功能已关闭,仅管理员可用')
else:
if settings.ADMIN_PASSWORD is None:
raise HTTPException(status_code=404, detail='您未设置管理员密码,无法使用此功能,请更新配置文件后,重启系统')
if not pwd or pwd != settings.ADMIN_PASSWORD:
raise HTTPException(status_code=401, detail="密码错误,请重新登录")
class IPRateLimit:
def __init__(self, count, minutes):
self.ips = {}
self.count = count
self.minutes = minutes
def check_ip(self, ip):
# 检查ip是否被禁止
if ip in self.ips:
if self.ips[ip]['count'] >= self.count:
if self.ips[ip]['time'] + timedelta(minutes=self.minutes) > datetime.now():
return False
else:
self.ips.pop(ip)
return True
def add_ip(self, ip):
ip_info = self.ips.get(ip, {'count': 0, 'time': datetime.now()})
ip_info['count'] += 1
ip_info['time'] = datetime.now()
self.ips[ip] = ip_info
return ip_info['count']
async def remove_expired_ip(self):
for ip in list(self.ips.keys()):
if self.ips[ip]['time'] + timedelta(minutes=self.minutes) < datetime.now():
self.ips.pop(ip)
def __call__(self, request: Request):
ip = request.headers.get('X-Real-IP', request.headers.get('X-Forwarded-For', request.client.host))
if not self.check_ip(ip):
raise HTTPException(status_code=400, detail=f"请求次数过多,请稍后再试")
return ip
+140
View File
@@ -0,0 +1,140 @@
import os
import asyncio
from datetime import datetime
from pathlib import Path
from typing import BinaryIO
from fastapi import UploadFile
from core.database import Codes
from settings import settings
if settings.STORAGE_ENGINE == 'aliyunsystem':
try:
import oss2
except ImportError:
os.system('pip install oss2')
import oss2
class AliyunFileStorage:
def __init__(self):
auth = oss2.Auth(settings.KeyId, settings.KeySecret)
self.bucket = oss2.Bucket(auth, settings.OSS_ENDPOINT, settings.BUCKET_NAME)
def upload_file(self, upload_filepath, remote_filepath):
self.bucket.put_object_from_file(remote_filepath, upload_filepath)
async def get_text(self, file: UploadFile, key: str):
ext = file.filename.split('.')[-1]
now = datetime.now()
path = f"FileCodeBox/upload/{now.year}/{now.month}/{now.day}"
text = f"{path}/{f'{key}.{ext}'}"
return f"https://{settings.BUCKET_NAME}.{settings.OSS_ENDPOINT}/{text}"
async def get_url(self, info: Codes):
text = info.text.strip(f"https://{settings.BUCKET_NAME}.{settings.OSS_ENDPOINT}/")
url = self.bucket.sign_url('GET', text, settings.ACCESSTIME, slash_safe=True)
return url
@staticmethod
async def get_size(file: UploadFile):
f = file.file
f.seek(0, os.SEEK_END)
size = f.tell()
f.seek(0, os.SEEK_SET)
return size
@staticmethod
def _save(filepath, file: BinaryIO):
with open(filepath, 'wb') as f:
chunk_size = 256 * 1024
chunk = file.read(chunk_size)
while chunk:
f.write(chunk)
chunk = file.read(chunk_size)
async def save_file(self, file: UploadFile, remote_filepath: str):
now = int(datetime.now().timestamp())
upload_filepath = settings.DATA_ROOT + str(now)
await asyncio.to_thread(self._save, upload_filepath, file.file)
self.upload_file(upload_filepath, remote_filepath)
remote_filepath = remote_filepath.strip(f"https://{settings.BUCKET_NAME}.{settings.OSS_ENDPOINT}/")
self.upload_file(upload_filepath, remote_filepath)
await asyncio.to_thread(os.remove, upload_filepath)
async def delete_files(self, texts):
tasks = [self.delete_file(text) for text in texts]
await asyncio.gather(*tasks)
async def delete_file(self, text: str):
text = text.strip(f"https://{settings.BUCKET_NAME}.{settings.OSS_ENDPOINT}/")
self.bucket.delete_object(text)
class FileSystemStorage:
def __init__(self):
self.DATA_ROOT = Path(settings.DATA_ROOT)
self.STATIC_URL = settings.STATIC_URL
self.NAME = "filesystem"
self.DOWN_PATH = '/select'
async def get_filepath(self, text: str):
return self.DATA_ROOT / text.lstrip(self.STATIC_URL + '/')
async def get_url(self, info: Codes):
return f'{self.DOWN_PATH}?code={info.code}'
async def get_text(self, file: UploadFile, key: str):
ext = file.filename.split('.')[-1]
now = datetime.now()
path = self.DATA_ROOT / f"upload/{now.year}/{now.month}/{now.day}/"
if not path.exists():
path.mkdir(parents=True)
text = f"{self.STATIC_URL}/{(path / f'{key}.{ext}').relative_to(self.DATA_ROOT)}"
return text
@staticmethod
async def get_size(file: UploadFile):
f = file.file
f.seek(0, os.SEEK_END)
size = f.tell()
f.seek(0, os.SEEK_SET)
return size
@staticmethod
def _save(filepath, file: BinaryIO):
with open(filepath, 'wb') as f:
chunk_size = 256 * 1024
chunk = file.read(chunk_size)
while chunk:
f.write(chunk)
chunk = file.read(chunk_size)
async def save_file(self, file: UploadFile, text: str):
filepath = await self.get_filepath(text)
await asyncio.to_thread(self._save, filepath, file.file)
async def delete_file(self, text: str):
filepath = await self.get_filepath(text)
if filepath.exists():
await asyncio.to_thread(os.remove, filepath)
await asyncio.to_thread(self.judge_delete_folder, filepath)
async def delete_files(self, texts):
tasks = [self.delete_file(text) for text in texts]
await asyncio.gather(*tasks)
def judge_delete_folder(self, filepath):
current = filepath.parent
while current != self.DATA_ROOT:
if not list(current.iterdir()):
os.rmdir(current)
current = current.parent
else:
break
STORAGE_ENGINE = {
"filesystem": FileSystemStorage,
"aliyunsystem": AliyunFileStorage
}
+43
View File
@@ -0,0 +1,43 @@
import datetime
import random
import asyncio
from sqlalchemy import or_, select, delete
from sqlalchemy.ext.asyncio.session import AsyncSession
from .database import Codes, engine
from .depends import IPRateLimit
from .storage import STORAGE_ENGINE
from settings import settings
storage = STORAGE_ENGINE[settings.STORAGE_ENGINE]()
# 错误IP限制器
error_ip_limit = IPRateLimit(settings.ERROR_COUNT, settings.ERROR_MINUTE)
# 上传文件限制器
upload_ip_limit = IPRateLimit(settings.UPLOAD_COUNT, settings.UPLOAD_MINUTE)
async def delete_expire_files():
while True:
async with AsyncSession(engine, expire_on_commit=False) as s:
await error_ip_limit.remove_expired_ip()
await upload_ip_limit.remove_expired_ip()
query = select(Codes).where(or_(Codes.exp_time < datetime.datetime.now(), Codes.count == 0))
exps = (await s.execute(query)).scalars().all()
files = []
exps_ids = []
for exp in exps:
if exp.type != "text":
files.append(exp.text)
exps_ids.append(exp.id)
await storage.delete_files(files)
query = delete(Codes).where(Codes.id.in_(exps_ids))
await s.execute(query)
await s.commit()
await asyncio.sleep(settings.DELETE_EXPIRE_FILES_INTERVAL * 60)
async def get_code(s: AsyncSession):
code = random.randint(10000, 99999)
while (await s.execute(select(Codes.id).where(Codes.code == code))).scalar():
code = random.randint(10000, 99999)
return str(code)
-23
View File
@@ -1,23 +0,0 @@
import datetime
from sqlalchemy import create_engine, DateTime
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Boolean, Column, Integer, String
engine = create_engine('sqlite:///database.db', connect_args={"check_same_thread": False})
Base = declarative_base()
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
class Codes(Base):
__tablename__ = 'codes'
id = Column(Integer, primary_key=True, index=True)
code = Column(String(10), unique=True, index=True)
key = Column(String(30), unique=True, index=True)
name = Column(String(500))
size = Column(Integer)
type = Column(String(20))
text = Column(String(500))
used = Column(Boolean, default=False)
use_time = Column(DateTime, default=datetime.datetime.now, onupdate=datetime.datetime.now)
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

+226 -98
View File
@@ -1,119 +1,247 @@
import asyncio
import datetime
import os
import uuid
from fastapi import FastAPI, Depends, UploadFile, Form, File
from sqlalchemy.orm import Session
from pathlib import Path
from sqlalchemy import select, func, update
from sqlalchemy.ext.asyncio import AsyncSession
from starlette.requests import Request
from starlette.responses import HTMLResponse
import random
from starlette.responses import HTMLResponse, FileResponse
from starlette.staticfiles import StaticFiles
import os
import shutil
from core.utils import error_ip_limit, upload_ip_limit, get_code, storage, delete_expire_files
from core.depends import admin_required
from fastapi import FastAPI, Depends, UploadFile, Form, File, HTTPException, BackgroundTasks
from core.database import init_models, Options, Codes, get_session
from settings import settings
import database
from database import engine, SessionLocal, Base
Base.metadata.create_all(bind=engine)
app = FastAPI()
if not os.path.exists('./static'):
os.makedirs('./static')
app.mount("/static", StaticFiles(directory="static"), name="static")
index_html = open('templates/index.html', 'r').read()
# 过期时间
exp_hour = 24
# 允许错误次数
error_count = 5
# 禁止分钟数
error_minute = 60
error_ip_count = {}
# 实例化FastAPI
app = FastAPI(debug=settings.DEBUG, redoc_url=None, docs_url=None, openapi_url=None)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
@app.on_event('startup')
async def startup(s: AsyncSession = Depends(get_session)):
# 初始化数据库
await init_models(s)
# 启动后台任务,不定时删除过期文件
asyncio.create_task(delete_expire_files())
def get_code(db: Session = Depends(get_db)):
code = random.randint(10000, 99999)
while db.query(database.Codes).filter(database.Codes.code == code).first():
code = random.randint(10000, 99999)
return str(code)
BASE_DIR = Path(__file__).resolve().parent.parent
# 数据存储文件夹
DATA_ROOT = BASE_DIR / settings.DATA_ROOT
if not DATA_ROOT.exists():
DATA_ROOT.mkdir(parents=True)
# 本地文件文件夹
LOCAL_ROOT = BASE_DIR / settings.LOCAL_ROOT
if not LOCAL_ROOT.exists():
LOCAL_ROOT.mkdir(parents=True)
# 静态文件夹,这个固定就行了,静态资源都放在这里
app.mount('/static', StaticFiles(directory='./static'), name="static")
def get_file_name(key, ext, file):
now = datetime.datetime.now()
path = f'./static/upload/{now.year}/{now.month}/{now.day}/'
name = f'{key}.{ext}'
if not os.path.exists(path):
os.makedirs(path)
file = file.file.read()
with open(f'{os.path.join(path, name)}', 'wb') as f:
f.write(file)
return key, len(file), path[1:] + name
# 首页页面
index_html = open('templates/index.html', 'r', encoding='utf-8').read()
# 管理页面
admin_html = open('templates/admin.html', 'r', encoding='utf-8').read()
@app.get('/')
async def index():
with open('templates/index.html', 'r') as f:
return HTMLResponse(index_html)
return HTMLResponse(
index_html.replace('{{title}}', settings.TITLE).replace('{{description}}', settings.DESCRIPTION).replace(
'{{keywords}}', settings.KEYWORDS).replace("'{{fileSizeLimit}}'", str(settings.FILE_SIZE_LIMIT))
)
@app.get(f'/{settings.ADMIN_ADDRESS}', description='管理页面')
async def admin():
return HTMLResponse(
admin_html.replace('{{title}}', settings.TITLE).replace('{{description}}', settings.DESCRIPTION).replace(
'{{admin_address}}', settings.ADMIN_ADDRESS).replace('{{keywords}}', settings.KEYWORDS)
)
@app.get(f'/{settings.ADMIN_ADDRESS}/files', dependencies=[Depends(admin_required)])
async def get_files():
files = []
for i, j, k in os.walk(f'{LOCAL_ROOT}'):
files.extend([{'name': _.split('/')[-1], 'path': i} for _ in k])
return {'data': files}
@app.post(f'/{settings.ADMIN_ADDRESS}/files', dependencies=[Depends(admin_required)])
async def share_file(name=Form(...), path=File(...), s: AsyncSession = Depends(get_session)):
file_path = path + f'/{name}'
key = uuid.uuid4().hex
code = await get_code(s)
now = datetime.datetime.now()
path = f"{settings.LOCAL_ROOT}/upload/{now.year}/{now.month}/{now.day}/"
if not os.path.exists(path):
os.makedirs(path)
text = f"{path}/{f'{key}{name}'}"
exp_time = datetime.datetime.now() + datetime.timedelta(days=1)
s.add(Codes(code=code, text=text.replace(f'{settings.LOCAL_ROOT}/', ''), type='file', name=name, count=-1,
exp_time=exp_time, key=key))
await s.commit()
shutil.move(file_path, text)
return {
'detail': '分享成功!请在24小时内使用分享使用!',
'data': {
'code': code,
'text': text,
'name': name,
}
}
@app.post(f'/{settings.ADMIN_ADDRESS}', dependencies=[Depends(admin_required)], description='查询数据库列表')
async def admin_post(page: int = Form(default=1), size: int = Form(default=10), s: AsyncSession = Depends(get_session)):
infos = (await s.execute(select(Codes).offset((page - 1) * size).limit(size))).scalars().all()
data = [{
'id': info.id,
'code': info.code,
'name': info.name,
'exp_time': info.exp_time,
'count': info.count,
'text': info.text if info.type == 'text' else await storage.get_url(info),
} for info in infos]
return {
'detail': '查询成功',
'data': data,
'paginate': {
'page': page,
'size': size,
'total': (await s.execute(select(func.count(Codes.id)))).scalar()
}}
@app.delete(f'/{settings.ADMIN_ADDRESS}', dependencies=[Depends(admin_required)], description='删除数据库记录')
async def admin_delete(code: str, s: AsyncSession = Depends(get_session)):
# 找到相应记录
query = select(Codes).where(Codes.code == code)
# 找到第一条记录
file = (await s.execute(query)).scalars().first()
# 如果记录存在,并且不是文本
if file and file.type != 'text':
# 删除文件
await storage.delete_file(file.text)
# 删除数据库记录
await s.delete(file)
await s.commit()
return {'detail': '删除成功'}
@app.get(f'/{settings.ADMIN_ADDRESS}/config', description='获取系统配置', dependencies=[Depends(admin_required)])
async def config(s: AsyncSession = Depends(get_session)):
# 查询数据库
data = {}
for i in (await s.execute(select(Options))).scalars().all():
data[i.key] = i.value
return {'detail': '获取成功', 'data': data, 'menus': [
{'key': 'INSTALL', 'name': '版本信息'},
{'key': 'WEBSITE', 'name': '网站设置'},
{'key': 'SHARE', 'name': '分享设置'},
{'key': 'BANNERS', 'name': 'Banner'},
]}
@app.patch(f'/{settings.ADMIN_ADDRESS}', dependencies=[Depends(admin_required)], description='修改数据库数据')
async def admin_patch(request: Request, s: AsyncSession = Depends(get_session)):
data = await request.json()
data.pop('INSTALL')
for key, value in data.items():
await s.execute(update(Options).where(Options.key == key).values(value=value))
await settings.update(key, value)
await s.commit()
await settings.updates([[i.id, i.key, i.value] for i in (await s.execute(select(Options))).scalars().all()])
return {'detail': '修改成功'}
@app.post('/')
async def index(request: Request, code: str, db: Session = Depends(get_db)):
info = db.query(database.Codes).filter(database.Codes.code == code).first()
error = error_ip_count.get(request.client.host, {'count': 0, 'time': datetime.datetime.now()})
if error['count'] > error_count:
if datetime.datetime.now() - error['time'] < datetime.timedelta(minutes=error_minute):
return {'code': 404, 'msg': '请求过于频繁,请稍后再试'}
else:
error['count'] = 0
else:
if not info:
error['count'] += 1
error_ip_count[request.client.host] = error
return {'code': 404, 'msg': f'取件码错误,错误5次将被禁止10分钟'}
else:
return {'code': 200, 'msg': '取件成功,请点击库查看', 'data': info}
async def index(code: str, ip: str = Depends(error_ip_limit), s: AsyncSession = Depends(get_session)):
query = select(Codes).where(Codes.code == code)
info = (await s.execute(query)).scalars().first()
if not info:
error_count = settings.ERROR_COUNT - error_ip_limit.add_ip(ip)
raise HTTPException(status_code=404, detail=f"取件码错误,{error_count}次后将被禁止{settings.ERROR_MINUTE}分钟")
if info.exp_time < datetime.datetime.now() or info.count == 0:
raise HTTPException(status_code=404, detail="取件码已失效,请联系寄件人")
await s.execute(update(Codes).where(Codes.id == info.id).values(count=info.count - 1))
await s.commit()
if info.type != 'text':
info.text = await storage.get_url(info)
return {
'detail': f'取件成功,请立即下载,避免失效!',
'data': {'type': info.type, 'text': info.text, 'name': info.name, 'code': info.code}
}
@app.post('/share')
async def share(text: str = Form(default=None), file: UploadFile = File(default=None), db: Session = Depends(get_db)):
cutoff_time = datetime.datetime.now() - datetime.timedelta(hours=exp_hour)
db.query(database.Codes).filter(database.Codes.use_time < cutoff_time).delete()
db.commit()
code = get_code(db)
if text:
info = database.Codes(
code=code,
text=text,
type='text/plain',
key=uuid.uuid4().hex,
size=len(text),
used=True,
name='分享文本'
)
db.add(info)
db.commit()
return {'code': 200, 'msg': '上传成功,请点击文件库查看',
'data': {'code': code, 'name': '分享文本', 'text': text}}
elif file:
key, size, full_path = get_file_name(uuid.uuid4().hex, file.filename.split('.')[-1], file)
info = database.Codes(
code=code,
text=full_path,
type=file.content_type,
key=key,
size=size,
used=True,
name=file.filename
)
db.add(info)
db.commit()
return {'code': 200, 'msg': '上传成功,请点击文件库查看',
'data': {'code': code, 'name': file.filename, 'text': full_path}}
@app.get('/banner')
async def banner(request: Request):
# 数据库查询config
return {
'detail': '查询成功',
'data': settings.BANNERS,
'enable': request.headers.get('pwd', '') == settings.ADMIN_PASSWORD or settings.ENABLE_UPLOAD,
}
@app.get('/select')
async def get_file(code: str, ip: str = Depends(error_ip_limit), s: AsyncSession = Depends(get_session)):
# 查出数据库记录
query = select(Codes).where(Codes.code == code)
info = (await s.execute(query)).scalars().first()
# 如果记录不存在,IP错误次数+1
if not info:
error_ip_limit.add_ip(ip)
raise HTTPException(status_code=404, detail="口令不存在,次数过多将被禁止访问")
# 如果是文本,直接返回
if info.type == 'text':
return {'detail': '查询成功', 'data': info.text}
# 如果是文件,返回文件
else:
return {'code': 422, 'msg': '参数错误', 'data': []}
filepath = await storage.get_filepath(info.text)
return FileResponse(filepath, filename=info.name)
@app.post('/share', dependencies=[Depends(admin_required)], description='分享文件')
async def share(background_tasks: BackgroundTasks, text: str = Form(default=None),
style: str = Form(default='2'), value: int = Form(default=1), file: UploadFile = File(default=None),
ip: str = Depends(upload_ip_limit), s: AsyncSession = Depends(get_session)):
code = await get_code(s)
if style == '2':
if value > settings.MAX_DAYS:
raise HTTPException(status_code=400, detail=f"最大有效天数为{settings.MAX_DAYS}天")
exp_time = datetime.datetime.now() + datetime.timedelta(days=value)
exp_count = -1
elif style == '1':
if value < 1:
raise HTTPException(status_code=400, detail="最小有效次数为1次")
exp_time = datetime.datetime.now() + datetime.timedelta(days=1)
exp_count = value
else:
exp_time = datetime.datetime.now() + datetime.timedelta(days=1)
exp_count = -1
key = uuid.uuid4().hex
if file:
size = await storage.get_size(file)
if size > settings.FILE_SIZE_LIMIT:
raise HTTPException(status_code=400, detail="文件过大")
_text, _type, name = await storage.get_text(file, key), file.content_type, file.filename
background_tasks.add_task(storage.save_file, file, _text)
else:
size, _text, _type, name = len(text), text, 'text', '文本分享'
s.add(Codes(code=code, text=_text, size=size, type=_type, name=name, count=exp_count, exp_time=exp_time, key=key))
await s.commit()
upload_ip_limit.add_ip(ip)
return {
'detail': '分享成功,请点击我的文件按钮查看上传列表',
'data': {'code': code, 'key': key, 'name': name}
}
if __name__ == '__main__':
import uvicorn
uvicorn.run('main:app', host='0.0.0.0', port=settings.PORT, reload=settings.DEBUG)
+285 -30
View File
@@ -1,40 +1,295 @@
# 口令传送箱
<div align="center">
<h1>文件快递柜-轻量</h1>
<h2>FileCodeBox-Lite</h2>
<p><em>匿名口令分享文本,文件,像拿快递一样取文件</em></p>
</div>
![banner](https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/static/banners/img_1.png)
---
[简体中文](./readme.md) | [English](./readme_en.md)
## 主要特色
- [x] 拖拽,复制粘贴上传
- [x] 文件口令传输
- [x] 分享文件:多种上传方式供你选择
- [x] 分享文本:直接复制粘贴直接上传
- [x] 防爆破:错误五次拉黑十分钟
- [x] 完全匿名:不记录任何信息
- [x] 无需注册:无需注册,无需登录
- [x] Sqlite3数据库:无需安装数据库
## 系统截图
![取件](https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/%E5%8F%96%E4%BB%B6.png)
![取件箱](https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/%E5%8F%96%E4%BB%B6%E7%AE%B1.png)
![寄件](https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/%E5%AF%84%E4%BB%B6.png)
![寄件箱](https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/%E5%AF%84%E4%BB%B6%E7%AE%B1.png)
- [x] 轻量简洁:Fastapi+Sqlite3+Vue2+ElementUI
- [x] 轻松上传:复制粘贴,拖拽选择
- [x] 多种类型:文本,文件
- [x] 防止爆破:错误次数限制
- [x] 防止滥用:IP限制上传次数
- [x] 口令分享:随机口令,存取文件,自定义次数以及有效期
- [x] 匿名分享:无需注册,无需登录
- [x] 管理面板:查看所有文件,删除文件
- [x] 一键部署:docker一键部署
- [x] 多种存储方式:阿里云OSS、本地文件流
## 部署方式
### 服务端部署
### Docker一键部署
1. 安装Python3
2. 拉取代码,解压缩
3. 安装依赖包:`pip install -r requirements.txt`
4. 运行` uvicorn main:app --host 0.0.0.0 --port 12345`
5. 然后你自己看怎么进程守护吧
### 宝塔部署
1. 安装宝塔Python Manager
2. 然后你自己看着填吧
### Docker部署
#### AMD
```bash
docker build --file Dockerfile --tag filecodebox .
docker run -d -p 12345:12345 --name filecodebox filecodebox
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
```
#### ARM
```bash
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:arm
```
### 更新方式
```bash
// 停止容器并删除
docker stop filecodebox && docker rm filecodebox
// 重新运行容器
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
```
### 1.6版本注意
这一版改变比较大,如果出现问题可以尝试清空/opt/FileCodeBox目录,有问题欢迎反馈留言
注意,如果是第一次安装,请查看docker日志获取初始密码和后台地址,参考指令
后台本地文件列表,需要将服务器文件移动至目录/opt/FileCodeBox/data/locals,这样就可以显示了。
```bash
docker logs filecodebox
```
### 其他方式
仅供参考,历史版本->[部署文档](https://www.yuque.com/lxyo/work/zd0kvzy7fofx6w7v)
## 项目规划
2022年12月14日
这个项目的灵感来源于丁丁快传,然后写了这么一个基于本机存储的快传系统,本系统主要是以轻量,单用户,离线环境(`私有化`
)为主,因此也不需要加太多东西,所以其实这个项目到这基本功能已经完成了,剩下的就是维护和完善现有功能。
也不会再加入新的大功能了,如果你有更好的想法和建议欢迎提issue。
## 预览
### 例站
[https://share.lanol.cn](https://share.lanol.cn)
### 暗黑模式
<table style="width:100%">
<tr style="width: 100%">
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_10.png" alt="寄文件">
</td>
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_11.png" alt="寄文件">
</td>
</tr>
</table>
### 寄件
<table style="width: 100%">
<tr style="width: 100%">
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_1.png" alt="寄文件">
</td>
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_2.png" alt="寄文本">
</td>
</tr>
<tr style="width: 100%;">
<td colspan="2" style="width: 100%;">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_3.png" alt="寄文本">
</td>
</tr>
</table>
### 取件
<table style="width: 100%">
<tr style="width: 100%">
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_6.png" alt="取件">
</td>
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_5.png" alt="取件码错误">
</td>
</tr>
<tr style="width: 100%;">
<td colspan="2" style="width: 100%;">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_4.png" alt="取文件">
</td>
</tr>
</table>
### 管理
<table style="width: 100%">
<tr style="width: 100%">
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_7.png" alt="admin">
</td>
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_12.png" alt="admin">
</td>
</tr>
<tr style="width: 100%;">
<td colspan="2" style="width: 100%;">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_13.png" alt="admin">
</td>
</tr>
</table>
## 配置文件
如果需要修改配置,可以将该文件放在`/opt/FileCodeBox/`目录下,并命名为`.env`,然后重启容器即可。
如果不是Docker,则需要在项目同目录下新建一个`data`文件夹,然后在创建`.env`文件
```dotenv
# 端口
PORT=12345
# Sqlite数据库文件
DATABASE_URL=sqlite+aiosqlite:///database.db
# 静态文件夹
DATA_ROOT=./static
# 静态文件夹URL
STATIC_URL=/static
# 开启上传
ENABLE_UPLOAD=True
# 错误次数
ERROR_COUNT=5
# 错误限制分钟数
ERROR_MINUTE=10
# 上传次数
UPLOAD_COUNT=60
# 上传限制分钟数
UPLOAD_MINUTE=1
# 删除过期文件的间隔(分钟)
DELETE_EXPIRE_FILES_INTERVAL=10
# 管理地址
ADMIN_ADDRESS=admin
# 管理密码
ADMIN_PASSWORD=admin
# 文件大小限制,默认10MB
FILE_SIZE_LIMIT=10
# 网站标题
TITLE=文件快递柜
# 网站描述
DESCRIPTION=FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文本,文件,图片,视频,音频,压缩包等文件
# 网站关键词
KEYWORDS=FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文本,文件,图片,视频,音频,压缩包等文件
# 存储引擎
STORAGE_ENGINE=filesystem
# 如果使用阿里云OSS服务的话需要额外创建如下参数:
# 阿里云账号AccessKey
KeyId=阿里云账号AccessKey
# 阿里云账号AccessKeySecret
KeySecret=阿里云账号AccessKeySecret
# 阿里云OSS Bucket的地域节点
OSS_ENDPOINT=阿里云OSS Bucket的地域节点
# 阿里云OSS Bucket的BucketName
BUCKET_NAME=阿里云OSS Bucket的BucketName
```
## 接口文档
前端比较简陋,可以使用接口进行二次开发
### 取件
#### PATH
`/`
#### METHOD
`POST`
#### PARAMS
code: 取件码
#### Response
```json
{
"detail": "msg",
"data": {
"type": "类型",
"text": "文本",
"name": "名称",
"code": "取件码"
}
}
```
### 寄件
#### PATH
`/share`
#### METHOD
`POST`
#### PARAMS
style: 1为次数,2为时间
value: 次数或时间
text: 取件码
file: 文件
#### Response
```json
{
"detail": "msg",
"data": {
"code": "类型",
"key": "唯一ID",
"name": "名称"
}
}
```
## 状态
![Alt](https://repobeats.axiom.co/api/embed/7a6c92f1d96ee57e6fb67f0df371528397b0c9ac.svg "Repobeats analytics image")
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=vastsa/FileCodeBox&type=Date)](https://star-history.com/#vastsa/FileCodeBox&Date)
## 赞赏
<table style="width: 100%">
<tr style="width: 100%">
<td style="width: 50%;text-align: center;">
支付宝
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_9.png" alt="支付宝">
</td>
<td style="width: 50%;text-align: center">
微信
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_8.png" alt="微信">
</td>
</tr>
</table>
## 常见问题
1. 413 Request Entity Too Large
Nginx限制:
找到自己主机的nginx.conf配置文件,打开
在http{}中加入 client_max_body_size 10m;
然后重启nginx
## 免责声明
本项目开源仅供学习使用,不得用于任何违法用途,否则后果自负,与本人无关。使用请保留项目地址谢谢。
+230
View File
@@ -0,0 +1,230 @@
<div align="center">
<h1>File Express Cabinet - Lite</h1>
<h2>FileCodeBox - Lite</h2>
<p><em>share text and files with anonymous passwords, and take files like express delivery </em></p>
</div>
![banner](https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/static/banners/img_1.png)
---
[简体中文](./readme.md) | [English](./readme_en.md)
## Main features
- [x] lightweight and simple: Fastapi + Sqlite3 + Vue2 + ElementUI
- [x] easy upload: copy and paste, drag and drop
- [x] multiple types: Text, File
- [x] explosion Prevention: error count limit
- [x] prevent abuse: IP address limits the number of uploads
- [x] password sharing: random password, file access, custom times, and validity period
- [x] anonymous sharing: no registration, no login
- [x] management Panel: View all files and delete them
- [x] one-click deployment: docker one-click deployment
- [x] A variety of storage methods : Aliyun OSS、 local file flow
## Deployment method
### One-click Docker deployment
#### AMD
```bash
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
```
#### ARM
```bash
docker run -d --restart=always -p 12345:12345 -v /Users/lan/soft/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:arm
```
### Update
```bash
// 找到容器ID
docker ps -a
// 停止容器并删除
docker stop 容器ID && docker rm 容器ID
// 重新运行容器
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
```
### Other methods
For reference only, historical version->[部署文档](https://www.yuque.com/lxyo/work/zd0kvzy7fofx6w7v)
## Project Plan
December 14, 2022
This project is mainly light-weight, mainly single-user, offline environment, so there is no need to add too many
things, so in fact, the basic functions of this project have been completed, and the rest is to maintain and improve the
existing functions.
No new major functions will be added. If there are new functions, it will be our Pro version. Of course, it will
continue to be open source. It is an honor to be open source with @veoco. I learned from his code Many, I basically used
the Django set before, and only used Fastapi. Many of his writing methods have benefited me a lot, and I have a deeper
understanding of Fastapi, so I will also use Fastapi in the Pro version .
According to some current feedback, I hope to add multi-user functions and multi-storage engines, etc. Welcome to
continue to give comments and join us in joint development.
If you have better ideas and suggestions, welcome to file an issue.
## Preview
### Demo
[https://share.lanol.cn](https://share.lanol.cn)
### Dark Theme
<table style="width:100%">
<tr style="width: 100%">
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_10.png" alt="寄文件">
</td>
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_11.png" alt="寄文件">
</td>
</tr>
</table>
### Send
<table style="width: 100%">
<tr style="width: 100%">
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_1.png" alt="寄文件">
</td>
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_2.png" alt="寄文本">
</td>
</tr>
<tr style="width: 100%;">
<td colspan="2" style="width: 100%;">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_3.png" alt="寄文本">
</td>
</tr>
</table>
### Receive
<table style="width: 100%">
<tr style="width: 100%">
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_6.png" alt="取件">
</td>
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_5.png" alt="取件码错误">
</td>
</tr>
<tr style="width: 100%;">
<td colspan="2" style="width: 100%;">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_4.png" alt="取文件">
</td>
</tr>
</table>
### Manage
<table style="width: 100%">
<tr style="width: 100%">
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_7.png" alt="admin">
</td>
<td style="width: 50%">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_12.png" alt="admin">
</td>
</tr>
<tr style="width: 100%;">
<td colspan="2" style="width: 100%;">
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_13.png" alt="admin">
</td>
</tr>
</table>
## Configuration file
if you need to modify the configuration, you can put the file in `/opt/FileCodeBox/` directory and name it `.env` , and
then restart the container.
If it is not Docker, you need to create a `data` folder in the same directory as the project, and then create a `.env`
file
```dotenv
# 端口
PORT=12345
# Sqlite数据库文件
DATABASE_URL=sqlite+aiosqlite:///database.db
# 静态文件夹
DATA_ROOT=./static
# 静态文件夹URL
STATIC_URL=/static
# 开启上传
ENABLE_UPLOAD=True
# 错误次数
ERROR_COUNT=5
# 错误限制分钟数
ERROR_MINUTE=10
# 上传次数
UPLOAD_COUNT=60
# 上传限制分钟数
UPLOAD_MINUTE=1
# 删除过期文件的间隔(分钟)
DELETE_EXPIRE_FILES_INTERVAL=10
# 管理地址
ADMIN_ADDRESS=admin
# 管理密码
ADMIN_PASSWORD=admin
# 文件大小限制,默认10MB
FILE_SIZE_LIMIT=10
# 网站标题
TITLE=文件快递柜
# 网站描述
DESCRIPTION=FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文本,文件,图片,视频,音频,压缩包等文件
# 网站关键词
KEYWORDS=FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文本,文件,图片,视频,音频,压缩包等文件
# 存储引擎
STORAGE_ENGINE=filesystem
# 如果使用阿里云OSS服务的话需要额外创建如下参数:
# 阿里云账号AccessKey
KeyId=阿里云账号AccessKey
# 阿里云账号AccessKeySecret
KeySecret=阿里云账号AccessKeySecret
# 阿里云OSS Bucket的地域节点
OSS_ENDPOINT=阿里云OSS Bucket的地域节点
# 阿里云OSS Bucket的BucketName
BUCKET_NAME=阿里云OSS Bucket的BucketName
```
## Status
![Alt](https://repobeats.axiom.co/api/embed/7a6c92f1d96ee57e6fb67f0df371528397b0c9ac.svg "Repobeats analytics image")
## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=vastsa/FileCodeBox&type=Date)](https://star-history.com/#vastsa/FileCodeBox&Date)
## Appreciate
<table style="width: 100%">
<tr style="width: 100%">
<td style="width: 50%;text-align: center;">
支付宝
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_9.png" alt="支付宝">
</td>
<td style="width: 50%;text-align: center">
微信
<img src="https://fastly.jsdelivr.net/gh/vastsa/FileCodeBox@V1.6/images/img_8.png" alt="微信">
</td>
</tr>
</table>
## Disclaimer
this project is open source for learning only and cannot be used for any illegal purposes. Otherwise, you will be
responsible for the consequences and have nothing to do with yourself. Please keep the project address. Thank you.
+7 -17
View File
@@ -1,19 +1,9 @@
anyio==3.6.2
click==8.1.3
fastapi==0.88.0
h11==0.14.0
httptools==0.5.0
idna==3.4
pydantic==1.10.2
python-dotenv==0.21.0
python-multipart==0.0.5
PyYAML==6.0
six==1.16.0
sniffio==1.3.0
aiosqlite==0.17.0
SQLAlchemy==1.4.44
starlette==0.22.0
typing_extensions==4.4.0
uvicorn==0.20.0
uvloop==0.17.0
watchfiles==0.18.1
websockets==10.4
python-multipart==0.0.5
uvicorn==0.15.0
greenlet==2.0.1
starlette~=0.22.0
oss2==2.16.0
uvicorn==0.15.0
+88
View File
@@ -0,0 +1,88 @@
import uuid
from starlette.config import Config
# 配置文件.env,存放为data/.env
config = Config("data/.env")
class Settings:
# 项目版本
VERSION: str = config("VERSION", default="1.6")
# 是否开启DEBUG模式
DEBUG = config('DEBUG', cast=bool, default=False)
# 端口
PORT = config('PORT', cast=int, default=12345)
# Sqlite数据库文件
DATABASE_FILE = config('DATABASE_FILE', cast=str, default='data/database.db')
# Sqlite套接字
DATABASE_URL = config('DATABASE_URL', cast=str, default=f"sqlite+aiosqlite:///{DATABASE_FILE}")
# 数据存储文件夹,文件就不暴露在静态资源里面了
DATA_ROOT = './data/' + config('DATA_ROOT', cast=str, default=f"static")
# 本地文件夹
LOCAL_ROOT = './data/' + config('LOCAL_ROOT', cast=str, default=f"local")
# 静态文件夹URL
STATIC_URL = config('STATIC_URL', cast=str, default="/static")
# 开启上传
ENABLE_UPLOAD = config('ENABLE_UPLOAD', cast=bool, default=True)
# 最长天数
MAX_DAYS = config('MAX_DAYS', cast=int, default=7)
# 错误次数
ERROR_COUNT = config('ERROR_COUNT', cast=int, default=5)
# 错误限制分钟数
ERROR_MINUTE = config('ERROR_MINUTE', cast=int, default=10)
# 上传次数
UPLOAD_COUNT = config('UPLOAD_COUNT', cast=int, default=60)
# 上传限制分钟数
UPLOAD_MINUTE = config('UPLOAD_MINUTE', cast=int, default=1)
# 删除过期文件的间隔(分钟)
DELETE_EXPIRE_FILES_INTERVAL = config('DELETE_EXPIRE_FILES_INTERVAL', cast=int, default=10)
# 管理地址
ADMIN_ADDRESS = config('ADMIN_ADDRESS', cast=str, default=uuid.uuid4().hex)
# 管理密码
ADMIN_PASSWORD = config('ADMIN_PASSWORD', cast=str, default=uuid.uuid4().hex)
# 文件大小限制,默认10MB
FILE_SIZE_LIMIT = config('FILE_SIZE_LIMIT', cast=int, default=10) * 1024 * 1024
# 网站标题
TITLE = config('TITLE', cast=str, default="文件快递柜")
# 网站描述
DESCRIPTION = config('DESCRIPTION', cast=str, default="FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文本,文件")
# 网站关键词
KEYWORDS = config('KEYWORDS', cast=str, default="FileCodeBox,文件快递柜,口令传送箱,匿名口令分享文本,文件")
# 存储引擎:['aliyunsystem','filesystem']
STORAGE_ENGINE = config('STORAGE_ENGINE', cast=str, default="filesystem")
# 存储引擎配置
STORAGE_CONFIG = {}
# Banners
BANNERS = [{
'text': 'FileCodeBox',
'url': 'https://github.com/vastsa/FileCodeBox',
'src': '/static/banners/img_1.png'
}, {
'text': 'LanBlog',
'url': 'https://www.lanol.cn',
'src': '/static/banners/img_2.png'
}]
int_dict = {'PORT', 'MAX_DAYS', 'ERROR_COUNT', 'ERROR_MINUTE', 'UPLOAD_COUNT', 'UPLOAD_MINUTE',
'DELETE_EXPIRE_FILES_INTERVAL', 'FILE_SIZE_LIMIT'}
bool_dict = {'DEBUG', 'ENABLE_UPLOAD'}
async def update(self, key, value) -> None:
if hasattr(self, key):
if key in self.int_dict:
value = int(value)
elif key in self.bool_dict:
value = bool(value)
setattr(self, key, value)
async def updates(self, options) -> None:
with open('data/.env', 'w', encoding='utf-8') as f:
for i, key, value in options:
# 更新env文件
f.write(f"{key}={value}\n")
# 更新配置
await self.update(key, value)
f.flush()
settings = Settings()
+2
View File
@@ -0,0 +1,2 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).axios=t()}(this,(function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){return function(){return e.apply(t,arguments)}}var s,u=Object.prototype.toString,c=Object.getPrototypeOf,f=(s=Object.create(null),function(e){var t=u.call(e);return s[t]||(s[t]=t.slice(8,-1).toLowerCase())}),l=function(e){return e=e.toLowerCase(),function(t){return f(t)===e}},d=function(t){return function(n){return e(n)===t}},h=Array.isArray,p=d("undefined");var m=l("ArrayBuffer");var v=d("string"),y=d("function"),b=d("number"),g=function(t){return null!==t&&"object"===e(t)},w=function(e){if("object"!==f(e))return!1;var t=c(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},E=l("Date"),O=l("File"),S=l("Blob"),R=l("FileList"),A=l("URLSearchParams");function j(t,n){var r,o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=i.allOwnKeys,s=void 0!==a&&a;if(null!=t)if("object"!==e(t)&&(t=[t]),h(t))for(r=0,o=t.length;r<o;r++)n.call(null,t[r],r,t);else{var u,c=s?Object.getOwnPropertyNames(t):Object.keys(t),f=c.length;for(r=0;r<f;r++)u=c[r],n.call(null,t[u],u,t)}}function T(e,t){t=t.toLowerCase();for(var n,r=Object.keys(e),o=r.length;o-- >0;)if(t===(n=r[o]).toLowerCase())return n;return null}var x="undefined"==typeof self?"undefined"==typeof global?void 0:global:self,N=function(e){return!p(e)&&e!==x};var C,k=(C="undefined"!=typeof Uint8Array&&c(Uint8Array),function(e){return C&&e instanceof C}),P=l("HTMLFormElement"),_=function(e){var t=Object.prototype.hasOwnProperty;return function(e,n){return t.call(e,n)}}(),B=l("RegExp"),D=function(e,t){var n=Object.getOwnPropertyDescriptors(e),r={};j(n,(function(n,o){!1!==t(n,o,e)&&(r[o]=n)})),Object.defineProperties(e,r)},U={isArray:h,isArrayBuffer:m,isBuffer:function(e){return null!==e&&!p(e)&&null!==e.constructor&&!p(e.constructor)&&y(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||u.call(e)===t||y(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&m(e.buffer)},isString:v,isNumber:b,isBoolean:function(e){return!0===e||!1===e},isObject:g,isPlainObject:w,isUndefined:p,isDate:E,isFile:O,isBlob:S,isRegExp:B,isFunction:y,isStream:function(e){return g(e)&&y(e.pipe)},isURLSearchParams:A,isTypedArray:k,isFileList:R,forEach:j,merge:function e(){for(var t=N(this)&&this||{},n=t.caseless,r={},o=function(t,o){var i=n&&T(r,o)||o;w(r[i])&&w(t)?r[i]=e(r[i],t):w(t)?r[i]=e({},t):h(t)?r[i]=t.slice():r[i]=t},i=0,a=arguments.length;i<a;i++)arguments[i]&&j(arguments[i],o);return r},extend:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=r.allOwnKeys;return j(t,(function(t,r){n&&y(t)?e[r]=a(t,n):e[r]=t}),{allOwnKeys:o}),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:functionLine truncated
//# sourceMappingURL=axios.min.js.map
Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.
+1
View File
@@ -0,0 +1 @@
@charset "UTF-8";@font-face{font-family:element-icons;src:url(fonts/element-icons.woff) format("woff"),url(fonts/element-icons.ttf) format("truetype");font-weight:400;font-display:"auto";font-style:normal}[class*=" el-icon-"],[class^=el-icon-]{font-family:element-icons!important;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;vertical-align:baseline;display:inline-block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.el-icon-ice-cream-round:before{content:"\e6a0"}.el-icon-ice-cream-square:before{content:"\e6a3"}.el-icon-lollipop:before{content:"\e6a4"}.el-icon-potato-strips:before{content:"\e6a5"}.el-icon-milk-tea:before{content:"\e6a6"}.el-icon-ice-drink:before{content:"\e6a7"}.el-icon-ice-tea:before{content:"\e6a9"}.el-icon-coffee:before{content:"\e6aa"}.el-icon-orange:before{content:"\e6ab"}.el-icon-pear:before{content:"\e6ac"}.el-icon-apple:before{content:"\e6ad"}.el-icon-cherry:before{content:"\e6ae"}.el-icon-watermelon:before{content:"\e6af"}.el-icon-grape:before{content:"\e6b0"}.el-icon-refrigerator:before{content:"\e6b1"}.el-icon-goblet-square-full:before{content:"\e6b2"}.el-icon-goblet-square:before{content:"\e6b3"}.el-icon-goblet-full:before{content:"\e6b4"}.el-icon-goblet:before{content:"\e6b5"}.el-icon-cold-drink:before{content:"\e6b6"}.el-icon-coffee-cup:before{content:"\e6b8"}.el-icon-water-cup:before{content:"\e6b9"}.el-icon-hot-water:before{content:"\e6ba"}.el-icon-ice-cream:before{content:"\e6bb"}.el-icon-dessert:before{content:"\e6bc"}.el-icon-sugar:before{content:"\e6bd"}.el-icon-tableware:before{content:"\e6be"}.el-icon-burger:before{content:"\e6bf"}.el-icon-knife-fork:before{content:"\e6c1"}.el-icon-fork-spoon:before{content:"\e6c2"}.el-icon-chicken:before{content:"\e6c3"}.el-icon-food:before{content:"\e6c4"}.el-icon-dish-1:before{content:"\e6c5"}.el-icon-dish:before{content:"\e6c6"}.el-icon-moon-night:before{content:"\e6ee"}.el-icon-moon:before{content:"\e6f0"}.el-icon-cloudy-and-sunny:before{content:"\e6f1"}.el-icon-partly-cloudy:before{content:"\e6f2"}.el-icon-cloudy:before{content:"\e6f3"}.el-icon-sunny:before{content:"\e6f6"}.el-icon-sunset:before{content:"\e6f7"}.el-icon-sunrise-1:before{content:"\e6f8"}.el-icon-sunrise:before{content:"\e6f9"}.el-icon-heavy-rain:before{content:"\e6fa"}.el-icon-lightning:before{content:"\e6fb"}.el-icon-light-rain:before{content:"\e6fc"}.el-icon-wind-power:before{content:"\e6fd"}.el-icon-baseball:before{content:"\e712"}.el-icon-soccer:before{content:"\e713"}.el-icon-football:before{content:"\e715"}.el-icon-basketball:before{content:"\e716"}.el-icon-ship:before{content:"\e73f"}.el-icon-truck:before{content:"\e740"}.el-icon-bicycle:before{content:"\e741"}.el-icon-mobile-phone:before{content:"\e6d3"}.el-icon-service:before{content:"\e6d4"}.el-icon-key:before{content:"\e6e2"}.el-icon-unlock:before{content:"\e6e4"}.el-icon-lock:before{content:"\e6e5"}.el-icon-watch:before{content:"\e6fe"}.el-icon-watch-1:before{content:"\e6ff"}.el-icon-timer:before{content:"\e702"}.el-icon-alarm-clock:before{content:"\e703"}.el-icon-map-location:before{content:"\e704"}.el-icon-delete-location:before{content:"\e705"}.el-icon-add-location:before{content:"\e706"}.el-icon-location-information:before{content:"\e707"}.el-icon-location-outline:before{content:"\e708"}.el-icon-location:before{content:"\e79e"}.el-icon-place:before{content:"\e709"}.el-icon-discover:before{content:"\e70a"}.el-icon-first-aid-kit:before{content:"\e70b"}.el-icon-trophy-1:before{content:"\e70c"}.el-icon-trophy:before{content:"\e70d"}.el-icon-medal:before{content:"\e70e"}.el-icon-medal-1:before{content:"\e70f"}.el-icon-stopwatch:before{content:"\e710"}.el-icon-mic:before{content:"\e711"}.el-icon-copy-document:before{content:"\e718"}.el-icon-full-screen:before{content:"\e719"}.el-icon-switch-button:before{content:"\e71b"}.el-icon-aim:before{content:"\e71c"}.el-icon-crop:before{content:"\e71d"}.el-icon-odometer:before{content:"\e71e"}.el-icon-time:before{content:"\e71f"}.el-icon-bangzhu:before{content:"\e724"}.el-icon-close-notification:before{content:"\e726"}.el-icon-microphone:before{content:"\e727"}.el-icon-turn-off-microphone:before{content:"\e728"}.el-icon-position:before{content:"\e729"}.el-icon-postcard:before{content:"\e72a"}.el-icon-message:before{content:"\e72b"}.el-icon-chat-line-square:before{content:"\e72d"}.el-icon-chat-dot-square:before{content:"\e72e"}.el-icon-chat-dot-round:before{content:"\e72f"}.el-icon-chat-square:before{content:"\e730"}.el-icon-chat-line-round:before{content:"\e731"}.el-icon-chat-round:before{content:"\e732"}.el-icon-set-up:before{content:"\e733"}.el-icon-turn-off:before{content:"\e734"}.el-icon-open:before{content:"\e735"}.el-icon-connection:before{content:"\e736"}.el-icon-link:before{content:"\e737"}.el-icon-cpu:before{content:"\e738"}.el-icon-thumb:before{content:"\e739"}.el-icon-female:before{content:"\e73a"}.el-icon-male:before{content:"\e73b"}.el-icon-guide:before{content:"\e73c"}.el-icon-nLine truncated
+1
View File
@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("vue")):"function"==typeof define&&define.amd?define("ELEMENT",["vue"],t):"object"==typeof exports?exports.ELEMENT=t(require("vue")):e.ELEMENT=t(e.Vue)}("undefined"!=typeof self?self:this,function(e){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=51)}([function(t,n){t.exports=e},function(e,t,n){var i=n(4);e.exports=function(e,t,n){return void 0===n?i(e,t,!1):i(e,n,!1!==t)}},function(e,t,n){var i;!function(r){"use strict";var o={},s=/d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,a="[^\\s]+",l=/\[([^]*?)\]/gm,u=function(){};function c(e,t){for(var n=[],i=0,r=e.length;i<r;i++)n.push(e[i].substr(0,t));return n}function h(e){return function(t,n,i){var r=i[e].indexOf(n.charAt(0).toUpperCase()+n.substr(1).toLowerCase());~r&&(t.month=r)}}function d(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e}var f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],p=["January","February","March","April","May","June","July","August","September","October","November","December"],m=c(p,3),v=c(f,3);o.i18n={dayNamesShort:v,dayNames:f,monthNamesShort:m,monthNames:p,amPm:["am","pm"],DoFn:function(e){return e+["th","st","nd","rd"][e%10>3?0:(e-e%10!=10)*e%10]}};var g={D:function(e){return e.getDay()},DD:function(e){return d(e.getDay())},Do:function(e,t){return t.DoFn(e.getDate())},d:function(e){return e.getDate()},dd:function(e){return d(e.getDate())},ddd:function(e,t){return t.dayNamesShort[e.getDay()]},dddd:function(e,t){return t.dayNames[e.getDay()]},M:function(e){return e.getMonth()+1},MM:function(e){return d(e.getMonth()+1)},MMM:function(e,t){return t.monthNamesShort[e.getMonth()]},MMMM:function(e,t){return t.monthNames[e.getMonth()]},yy:function(e){return d(String(e.getFullYear()),4).substr(2)},yyyy:function(e){return d(e.getFullYear(),4)},h:function(e){return e.getHours()%12||12},hh:function(e){return d(e.getHours()%12||12)},H:function(e){return e.getHours()},HH:function(e){return d(e.getHours())},m:function(e){return e.getMinutes()},mm:function(e){return d(e.getMinutes())},s:function(e){return e.getSeconds()},ss:function(e){return d(e.getSeconds())},S:function(e){return Math.round(e.getMilliseconds()/100)},SS:function(e){return d(Math.round(e.getMilliseconds()/10),2)},SSS:function(e){return d(e.getMilliseconds(),3)},a:function(e,t){return e.getHours()<12?t.amPm[0]:t.amPm[1]},A:function(e,t){return e.getHours()<12?t.amPm[0].toUpperCase():t.amPm[1].toUpperCase()},ZZ:function(e){var t=e.getTimezoneOffset();return(t>0?"-":"+")+d(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)}},y={d:["\\d\\d?",function(e,t){e.day=t}],Do:["\\d\\d?"+a,function(e,t){e.day=parseInt(t,10)}],M:["\\d\\d?",function(e,t){e.month=t-1}],yy:["\\d\\d?",function(e,t){var n=+(""+(new Date).getFullYear()).substr(0,2);e.year=""+(t>68?n-1:n)+t}],h:["\\d\\d?",function(e,t){e.hour=t}],m:["\\d\\d?",function(e,t){e.minute=t}],s:["\\d\\d?",function(e,t){e.second=t}],yyyy:["\\d{4}",function(e,t){e.year=t}],S:["\\d",function(e,t){e.millisecond=100*t}],SS:["\\d{2}",function(e,t){e.millisecond=10*t}],SSS:["\\d{3}",function(e,t){e.millisecond=t}],D:["\\d\\d?",u],ddd:[a,u],MMM:[a,h("monthNamesShort")],MMMM:[a,h("monthNames")],a:[a,function(e,t,n){var i=t.toLowerCase();i===n.amPm[0]?e.isPm=!1:i===n.amPm[1]&&(e.isPm=!0)}],ZZ:["[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z",function(e,t){var n,i=(t+"").match(/([+-]|\d\d)/gi);i&&(n=60*i[1]+parseInt(i[2],10),e.timezoneOffset="+"===i[0]?n:-n)}]};y.dd=y.d,y.dddd=y.ddd,y.DD=y.D,y.mm=y.m,y.hh=y.H=y.HH=y.h,y.MM=y.M,y.ss=y.s,y.A=y.a,o.masks={default:"ddd MMM dd yyyy HH:mm:ss",shortDate:"M/D/yy",mediumDate:"MMM d, yyyy",longDate:"MMMM d, yyyy",fullDate:"dddd, MMMM d, yyyy",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},o.format=function(e,t,n){var i=n||o.i18n;if("number"==typeof e&&(e=new Date(e)),"[object Date]"!==Object.prototype.toString.call(e)||isNaN(e.getTime()))throw new Error("Invalid Date in fecha.format");t=o.masks[t]||t||o.masks.default;var r=[];return(t=(t=t.replace(l,function(e,t){return r.push(t),"@@@"})Line truncated
Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

+11
View File
@@ -0,0 +1,11 @@
/*!
* Vue.js v2.7.14
* (c) 2014-2022 Evan You
* Released under the MIT License.
*/
/*!
* Vue.js v2.7.14
* (c) 2014-2022 Evan You
* Released under the MIT License.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Vue=e()}(this,(function(){"use strict";var t=Object.freeze({}),e=Array.isArray;function n(t){return null==t}function r(t){return null!=t}function o(t){return!0===t}function i(t){return"string"==typeof t||"number"==typeof t||"symbol"==typeof t||"boolean"==typeof t}function a(t){return"function"==typeof t}function s(t){return null!==t&&"object"==typeof t}var c=Object.prototype.toString;function u(t){return"[object Object]"===c.call(t)}function l(t){var e=parseFloat(String(t));return e>=0&&Math.floor(e)===e&&isFinite(t)}function f(t){return r(t)&&"function"==typeof t.then&&"function"==typeof t.catch}function d(t){return null==t?"":Array.isArray(t)||u(t)&&t.toString===c?JSON.stringify(t,null,2):String(t)}function p(t){var e=parseFloat(t);return isNaN(e)?t:e}function v(t,e){for(var n=Object.create(null),r=t.split(","),o=0;o<r.length;o++)n[r[o]]=!0;return e?function(t){return n[t.toLowerCase()]}:function(t){return n[t]}}var h=v("slot,component",!0),m=v("key,ref,slot,slot-scope,is");function g(t,e){var n=t.length;if(n){if(e===t[n-1])return void(t.length=n-1);var r=t.indexOf(e);if(r>-1)return t.splice(r,1)}}var y=Object.prototype.hasOwnProperty;function _(t,e){return y.call(t,e)}function b(t){var e=Object.create(null);return function(n){return e[n]||(e[n]=t(n))}}var $=/-(\w)/g,w=b((function(t){return t.replace($,(function(t,e){return e?e.toUpperCase():""}))})),x=b((function(t){return t.charAt(0).toUpperCase()+t.slice(1)})),C=/\B([A-Z])/g,k=b((function(t){return t.replace(C,"-$1").toLowerCase()}));var S=Function.prototype.bind?function(t,e){return t.bind(e)}:function(t,e){function n(n){var r=arguments.length;return r?r>1?t.apply(e,arguments):t.call(e,n):t.call(e)}return n._length=t.length,n};function O(t,e){e=e||0;for(var n=t.length-e,r=new Array(n);n--;)r[n]=t[n+e];return r}function T(t,e){for(var n in e)t[n]=e[n];return t}function A(t){for(var e={},n=0;n<t.length;n++)t[n]&&T(e,t[n]);return e}function j(t,e,n){}var E=function(t,e,n){return!1},N=function(t){return t};function P(t,e){if(t===e)return!0;var n=s(t),r=s(e);if(!n||!r)return!n&&!r&&String(t)===String(e);try{var o=Array.isArray(t),i=Array.isArray(e);if(o&&i)return t.length===e.length&&t.every((function(t,n){return P(t,e[n])}));if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(o||i)return!1;var a=Object.keys(t),c=Object.keys(e);return a.length===c.length&&a.every((function(n){return P(t[n],e[n])}))}catch(t){return!1}}function D(t,e){for(var n=0;n<t.length;n++)if(P(t[n],e))return n;return-1}function M(t){var e=!1;return function(){e||(e=!0,t.apply(this,arguments))}}function I(t,e){return t===e?0===t&&1/t!=1/e:t==t||e==e}var L="data-server-rendered",R=["component","directive","filter"],F=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured","serverPrefetch","renderTracked","renderTriggered"],H={optionMergeStrategies:Object.create(null),silent:!1,productionTip:!1,devtools:!1,performance:!1,errorHandler:null,warnHandler:null,ignoredElements:[],keyCodes:Object.create(null),isReservedTag:E,isReservedAttr:E,isUnknownElement:E,getTagNamespace:j,parsePlatformTagName:N,mustUseProp:E,async:!0,_lifecycleHooks:F},B=/a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;function U(t){var e=(t+"").charCodeAt(0);return 36===e||95===e}function z(t,e,n,r){Object.defineProperty(t,e,{value:n,enumerable:!!r,writable:!0,configurable:!0})}var V=new RegExp("[^".concat(B.source,".$_\\d]"));var K="__proto__"in{},J="undefined"!=typeof window,q=J&&window.navigator.userAgent.toLowerCase(),W=q&&/msie|trident/.test(q),Z=q&&q.indexOf("msie 9.0")>0,G=q&&q.indexOf("edge/")>0;q&&q.indexOf("android");var X=q&&/iphone|ipad|ipod|ios/.test(q);q&&/chrome\/\d+/.test(q),q&&/phantomjs/.test(q);var Y,Q=q&&q.match(/firefox\/(\d+)/),tt={}.watch,et=!1;if(J)try{var nt={};Object.defineProperty(nt,"passive",{get:function(){et=!0}}),window.addEventListener("test-passive",null,nt)}catch(t){}var rt=function(){return void 0===Y&&(Y=!J&&"undefined"!=typeof global&&(global.process&&"server"===global.process.env.VUE_ENV)),Y},ot=J&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function it(t){return"function"==typeof t&&/native code/.test(t.toString())}var at,st="undefined"!=typeof Symbol&&it(Symbol)&&"undefined"!=typeof Reflect&&it(Reflect.ownKeys);at="undefined"!=typeof Set&&it(Set)?Set:function(){function t(){this.set=Object.create(null)}return t.prototype.has=function(t){return!0===this.set[t]},t.prototype.add=function(t){this.set[t]=!0},t.prototype.clear=function(){this.set=Object.create(null)},t}();var ct=null;function ut(t){void 0===t&&(t=null),t||ct&&ct._scope.off(),ct=t,t&&t._scope.on()}var lt=function(){function tLine truncated
Binary file not shown.

After

Width:  |  Height:  |  Size: 499 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

+354
View File
@@ -0,0 +1,354 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="/static/asserts/index.css">
<link rel="shortcut icon" href="/static/asserts/favicon.ico" type="image/x-icon"/>
<title>后台管理-{{title}}</title>
<meta name="description" content="{{description}}"/>
<meta name="keywords" content="{{keywords}}"/>
<meta name="generator" content="FileCodeBox"/>
<meta name="template" content="Lan"/>
<script src="/static/asserts/vue.min.js"></script>
<script src="/static/asserts/index.js"></script>
<style>
.el-menu-demo {
text-align: center;
}
body {
background: #f5f5f5;
}
</style>
</head>
<body>
<div id="app">
<el-row v-if="login" :gutter="10">
<el-col :span="24" style="text-align: center">
<el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
<el-menu-item index="2">分享文件管理</el-menu-item>
<el-menu-item index="3">本地文件列表</el-menu-item>
<el-menu-item index="4">系统配置</el-menu-item>
</el-menu>
</el-col>
<el-col v-if="activeIndex === '2'">
<el-card style="height: 80vh;overflow: scroll;margin-bottom: 1rem">
<el-empty v-if="files.length === 0" description="暂时还没有文件"></el-empty>
<el-card v-for="file in files" :key="file.code">
<el-row>
<el-col :span="20">
<div style="cursor: pointer;text-align: left">
<div>取件码:${ file.code }</div>
<div>文件名:${ file.name }</div>
<div>次&nbsp;&nbsp; 数:${ file.count }</div>
<div>到&nbsp;&nbsp; 期:${ file.exp_time.slice(0,19) }</div>
<div v-if="file.name==='文本分享'">
<span style="white-space: pre-line">内&nbsp;&nbsp; 容:${ file.text }</span>
</div>
<div v-else>
<span>链&nbsp;&nbsp; 接:</span>
<a :href="file.text" target="_blank"
style="color: #1E9FFF;text-underline: none"
type="primary">点击下载</a>
</div>
</div>
</el-col>
<el-col :span="4">
<el-button type="danger" @click="deleteFile(file.code)">删除</el-button>
</el-col>
</el-row>
</el-card>
</el-card>
<el-pagination
background
style="text-align: center"
layout="prev, pager, next, sizes"
:page-size="paginate.page_size"
@current-change="updatePage"
@size-change="updateSize"
:total="paginate.total"
>
</el-pagination>
</el-col>
<el-col v-if="activeIndex === '3'">
<el-card style="height: 80vh;overflow: scroll;margin-bottom: 1rem">
<el-empty v-if="locals.length === 0"
description="暂时还没有文件,请上传至/opt/data/locals目录"></el-empty>
<el-card v-for="file in locals" :key="file.code">
<el-row>
<el-col :span="20">
<div style="cursor: pointer;text-align: left">
<div>文件名:${ file.name }</div>
<div>路径:${ file.path }</div>
</div>
</el-col>
<el-col :span="4">
<el-button type="primary" @click="shareFile(file)">分享</el-button>
</el-col>
</el-row>
</el-card>
</el-card>
</el-col>
<el-col v-if="activeIndex === '4'">
<el-row>
<el-col :span="4" style="height: 88vh;overflow: scroll;text-align: center" :gutter="10">
<el-card v-for="menu in menus" :key="menu.key">
<div style="cursor: pointer;" @click="updateTab=menu.key">${menu.name}</div>
</el-card>
</el-col>
<el-col :span="20">
<el-card style="height: 88vh;overflow: scroll">
<div v-if="updateTab=='INSTALL'">
<div>
<h1>FileCodeBox V${config.INSTALL}</h1>
<h2>Github:<a target="_blank"
href="https://github.com/vastsa/FileCodeBox">FileCodeBox</a></h2>
</div>
</div>
<div v-else-if="updateTab=='BANNERS'">
<el-form ref="form" style="margin:1rem auto" :model="config" label-width="200px">
<el-form-item v-for="(banner,index) in config.BANNERS" :label="'Banner'+ (index+1)">
<div style="display: inline-block">
<el-input v-model="banner.text" placeholder="文本"></el-input>
<el-input v-model="banner.url" placeholder="跳转链接"></el-input>
<el-input v-model="banner.src" placeholder="图片路径"></el-input>
</div>
<div style="display: inline-block">
<el-button type="danger" @click="deleteBanner(index)">删除</el-button>
</div>
</el-form-item>
<el-form-item>
<el-button size="mini" @click="addBanner" type="primary">新增Banner</el-button>
</el-form-item>
<el-form-item>
<el-button @click="updateConfig" type="primary">更新</el-button>
</el-form-item>
</el-form>
</div>
<div v-else-if="updateTab=='WEBSITE'">
<el-form ref="form" style="margin:1rem auto" :model="config" label-width="200px">
<el-form-item label="后台密码">
<el-input type="password" v-model="config.ADMIN_PASSWORD"
placeholder="网站名称"></el-input>
</el-form-item>
<el-form-item label="网站名称">
<el-input v-model="config.TITLE" placeholder="网站名称"></el-input>
</el-form-item>
<el-form-item label="网站描述">
<el-input v-model="config.DESCRIPTION" placeholder="网站描述"></el-input>
</el-form-item>
<el-form-item label="网站关键词">
<el-input v-model="config.KEYWORDS" placeholder="网站关键词"></el-input>
</el-form-item>
<el-form-item>
<el-alert
title="下列信息修改后需要手动重启系统"
type="warning">
</el-alert>
</el-form-item>
<el-form-item label="系统端口">
<el-input v-model="config.PORT" placeholder="系统端口"></el-input>
</el-form-item>
<el-form-item label="后台地址">
<el-input v-model="config.ADMIN_ADDRESS" placeholder="后台地址"></el-input>
</el-form-item>
<el-form-item label="存储引擎">
<el-input v-model="config.STORAGE_ENGINE" placeholder="存储引擎"></el-input>
</el-form-item>
<el-form-item>
<el-button @click="updateConfig" type="primary">更新</el-button>
</el-form-item>
</el-form>
</div>
<div v-else-if="updateTab=='SHARE'">
<el-form ref="form" style="margin:1rem auto" :model="config" label-width="200px">
<el-form-item label="开启上传">
<el-input v-model="config.ENABLE_UPLOAD" placeholder="开启上传"></el-input>
</el-form-item>
<el-form-item label="最长天数">
<el-input v-model="config.MAX_DAYS" placeholder="最长允许保留多少天"></el-input>
</el-form-item>
<el-form-item label="删除过期间隔">
<el-input v-model="config.DELETE_EXPIRE_FILES_INTERVAL"
placeholder="删除过期文件的间隔(分钟)"></el-input>
</el-form-item>
<el-form-item label="上传大小限制">
<small>单位:(bit),1mb=1 * 1024 * 1024</small>
<el-input v-model="config.FILE_SIZE_LIMIT"
placeholder="上传大小限制(bit)"></el-input>
</el-form-item>
<el-form-item>
<el-alert
title="下列信息修改后需要手动重启系统"
type="warning">
</el-alert>
</el-form-item>
<el-form-item label="口令错误限制">
<small>每几分钟</small>
<el-input v-model="config.ERROR_MINUTE"
placeholder="错误次数过多后限制时间"></el-input>
<small>允许错误几次</small>
<el-input v-model="config.ERROR_COUNT" placeholder="允许错误次数"></el-input>
</el-form-item>
<el-form-item label="上传次数限制">
<small>每几分钟</small>
<el-input v-model="config.UPLOAD_MINUTE"
placeholder="每几分钟"></el-input>
<small>允许上传几次</small>
<el-input v-model="config.UPLOAD_COUNT"
placeholder="允许次数"></el-input>
</el-form-item>
<el-form-item>
<el-button @click="updateConfig" type="primary">更新</el-button>
</el-form-item>
</el-form>
</div>
</el-card>
</el-col>
</el-row>
</el-col>
</el-row>
<div v-else style="width: 250px;text-align: center;margin: 40vh auto">
<el-input v-model="pwd" placeholder="请输入登录密码">
<el-button slot="append" type="primary" @click="loginAdmin">登录</el-button>
</el-input>
</div>
</div>
</body>
<script src="/static/asserts/axios.min.js"></script>
<script>
new Vue({
el: '#app',
delimiters: ['${', '}'],
data: function () {
return {
login: false,
pwd: '',
activeIndex: '2',
config: {
banners: []
},
menus: [],
updateTab: 'INSTALL',
files: [],
locals: [],
paginate: {
page: 1,
size: 10,
total: 0,
},
};
},
mounted: function () {
const pwd = localStorage.getItem('pwd');
if (pwd) {
login = true;
this.pwd = pwd;
this.loginAdmin();
this.getLocalFiles();
}
},
methods: {
getConfig: function () {
axios.get(window.location.href + '/config', {
headers: {
pwd: this.pwd
}
}).then(res => {
this.config = res.data.data;
this.menus = res.data.menus;
});
},
updateSize: function (value) {
this.paginate.size = value;
this.loginAdmin();
},
updatePage: function (value) {
this.paginate.page = value;
this.loginAdmin();
},
deleteBanner: function (index) {
this.config.BANNERS.splice(index, 1);
},
addBanner: function () {
this.config.BANNERS.push({
'url': '',
'src': '',
'text': '',
})
},
updateConfig: function () {
axios.patch('', this.config, {
'headers': {
'pwd': this.pwd,
'Content-Type': 'multipart/json'
}
}).then(res => {
this.$message({
message: res.data.detail,
type: 'success'
});
})
},
loginAdmin: function () {
axios.post('', this.paginate, {
'headers': {
'pwd': this.pwd,
'Content-Type': 'multipart/form-data'
}
}).then(res => {
this.paginate = res.data.paginate;
this.files = res.data.data
this.login = true;
localStorage.setItem('pwd', this.pwd);
this.getConfig();
}).catch(e => {
localStorage.clear()
this.$message({'message': e.response.data.detail, 'type': 'error'});
});
},
handleSelect(key, keyPath) {
this.activeIndex = key;
},
deleteFile: function (code) {
axios.delete('?code=' + code, {'headers': {'pwd': this.pwd}}).then(res => {
this.files = this.files.filter(item => item.code !== code)
this.$message({
message: res.data.detail,
type: 'success'
});
})
},
getLocalFiles: function () {
axios.get(window.location.href + '/files', {
'headers': {
'pwd': this.pwd,
'Content-Type': 'multipart/form-data'
}
}).then(res => {
this.locals = res.data.data;
})
},
shareFile: function (file) {
axios.post(window.location.href + '/files', file, {
'headers': {
'pwd': this.pwd,
'Content-Type': 'multipart/form-data'
}
}).then(res => {
this.getLocalFiles()
this.$alert(`请在24小时内使用:${res.data.data.code}`, '分享成功', {
confirmButtonText: '确定',
});
})
}
}
})
</script>
</html>
+326 -125
View File
@@ -5,11 +5,18 @@
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<title>取件箱-口令传送箱</title>
<link rel="stylesheet" href="/static/asserts/index.css">
<link rel="shortcut icon" href="/static/asserts/favicon.ico" type="image/x-icon"/>
<title>{{title}}</title>
<meta name="description" content="{{description}}"/>
<meta name="keywords" content="{{keywords}}"/>
<meta name="generator" content="FileCodeBox"/>
<meta name="template" content="V1.6 Beta"/>
<style>
body {
background: #f5f5f5;
}
.qu .el-button {
width: 100px;
height: 100px;
@@ -18,96 +25,192 @@
font-weight: bold;
}
.el-icon-circle-close::before {
font-size: 26px !important;
line-height: 128px;
}
.qu .el-input__inner {
height: 100px;
margin: 1rem 0;
font-size: 30px;
font-weight: bold;
border-radius: 20px;
}
.el-card {
border-radius: 20px;
}
@media (prefers-color-scheme: dark) {
body {
background-color: #18181c;
}
.el-card, .el-textarea__inner, .el-upload-dragger {
border-radius: 20px;
border: 1px solid transparent;
background-color: rgba(255, 255, 255, 0.1);
box-shadow: 5px 5px 0 0 rgba(0, 0, 0, 0.2);
}
#app * {
color: #ccc !important;
}
.el-input-group__prepend, .el-input__inner, .el-input-group__append, .el-empty__description, .el-select-dropdown, .el-button {
border: 1px solid transparent;
background-color: rgba(0, 0, 0, 0.2);
}
.el-drawer, #el-drawer__title, .el-drawer__body, .el-drawer__wrapper {
background-color: rgba(0, 0, 0, 0.5);
border: 1px solid transparent;
}
}
</style>
<script src="/static/asserts/vue.min.js"></script>
<script src="/static/asserts/index.js"></script>
</head>
<body>
<div id="app" style="text-align: center;">
<el-row v-if="tool==0" class="qu" style="width:400px;margin: auto">
<el-card style="padding-bottom: 1rem">
<div id="app" style="text-align: center">
<el-row v-if="pageNum === 0" class="qu" style="max-width:400px;margin: 4rem auto 0 auto">
<el-card class="glass" style="padding-bottom: 1rem">
<el-col :span="24">
<el-input autofocus @input="inputing" clearable v-model:value="code" maxlength="5"
:disabled="inout_disable"
placeholder="请输入取件码"></el-input>
<el-input round autofocus @change="changeInput" clearable v-model:value="code" maxlength="5"
:disabled="inputDisable" placeholder="请输入五位取件码">
</el-input>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('1')">1</el-button>
<el-button round @click="listenInput('1')">1</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('2')">2</el-button>
<el-button round @click="listenInput('2')">2</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('3')">3</el-button>
<el-button round @click="listenInput('3')">3</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('4')">4</el-button>
<el-button round @click="listenInput('4')">4</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('5')">5</el-button>
<el-button round @click="listenInput('5')">5</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('6')">6</el-button>
<el-button round @click="listenInput('6')">6</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('7')">7</el-button>
<el-button round @click="listenInput('7')">7</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('8')">8</el-button>
<el-button round @click="listenInput('8')">8</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('9')">9</el-button>
<el-button round @click="listenInput('9')">9</el-button>
</el-col>
<el-col :span=8>
<el-button @click="tool=1">寄</el-button>
<el-button round @click="pageNum=1">
<div style="height: 10px" class="el-icon-upload2"></div>
</el-button>
</el-col>
<el-col :span=8>
<el-button @click="inputNumber('0')">0</el-button>
<el-button round @click="listenInput('0')">0</el-button>
</el-col>
<el-col :span=8>
<el-button @click="quDrawer=true">取</el-button>
<el-button round @click="quDrawer=true">
<div class="el-icon-takeaway-box"></div>
</el-button>
</el-col>
</el-card>
</el-row>
<el-row v-else style="width:400px;margin: auto">
<el-col :span="24" style="margin: 1rem 0">
<el-card>
<el-row v-else style="max-width:400px;margin: 4rem auto 0 auto">
<el-col :span="24">
<el-card :body-style="{ padding: '0px 0px 20px 0px' }">
<div class="block" style="margin-bottom: 1rem">
<el-carousel height="150px">
<el-carousel-item v-for="item in banners" :key="item">
<a :href="item.url" target="_blank">
<img class="image" style="width: 400px" :src="item.src" :alt="item.text">
</a>
</el-carousel-item>
</el-carousel>
</div>
<el-row>
<el-input style="width: 190px" placeholder="数量" v-model="uploadData.value"
class="input-with-select">
<el-select style="width: 75px" v-model="uploadData.style" slot="prepend" placeholder="请选择">
<el-option label="天数" value="2"></el-option>
<el-option label="次数" value="1"></el-option>
</el-select>
<el-button v-if="uploadData.style === '1'" slot="append" disabled>次</el-button>
<el-button v-else slot="append" disabled>天</el-button>
</el-input>
<el-radio-group style="margin-left: 18px" v-model="uploadData.type">
<el-radio label="1">
文件
</el-radio>
<el-radio label="2">
文本
</el-radio>
</el-radio-group>
</el-row>
<el-upload
v-if="uploadData.type === '1'"
drag
action="/share"
multiple
style="margin: 1rem 0;"
:data="uploadData"
:before-upload="beforeUpload"
:headers="{'pwd':pwd}"
:on-success="successUpload"
:on-error="errorUpload"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖、粘贴到此处,或<em>点击上传</em>,24h后删除</div>
<div class="el-upload__tip" slot="tip">
<el-button @click="tool=0">去取件</el-button>
<el-button @click="cunDrawer=true">文件箱</el-button>
</div>
<div class="el-upload__text">将文字、文件拖、粘贴到此处,或<em>点击上传</em></div>
<div class="el-upload__text" style="font-size: 10px">天数<7或限制次数(24h后删除)</div>
</el-upload>
<el-input
v-else
type="textarea"
:autosize="{ minRows: 8}"
style="margin: 1rem 0"
placeholder="请输入内容,使用按钮存入"
v-model="uploadData.text">
</el-input>
<div class="el-upload__tip">
<el-button round @click="pageNum=0">
<div class="el-icon-back"></div>
取件
</el-button>
<el-button round @click="jiDrawer=true">
<div class="el-icon-takeaway-box"></div>
我的文件
</el-button>
<el-button round v-if="uploadData.type === '2'" @click="toUploadData">
<div class="el-icon-upload2"></div>
存入
</el-button>
</div>
</el-card>
</el-col>
</el-row>
<div style="text-align: center; margin-top: 1rem;color: #606266">
<span> By: <a style="text-decoration: none;color: #606266" target="_blank"
href="https://github.com/vastsa/FileCodeBox">Lan</a></span>
</div>
<el-drawer
title="文件库"
title="文件箱"
:visible.sync="quDrawer"
:direction="direction"
size="50%"
>
<el-card v-for="(file,index) in files" :key="index" class="box-card">
<div style="cursor: pointer;text-align: left">
<el-card v-for="(file,index) in quFiles" :key="index" class="box-card">
<div style="cursor: pointer;text-align: left;margin-left: 2rem">
<div>取件码:${ file.code }</div>
<div>文件名:${ file.name }</div>
<div v-if="file.name==='分享文本'">
<span>内&nbsp;&nbsp; 容:${ file.text }</span>
<div v-if="file.name==='文本分享'">
<span style="white-space: pre-line"
@click="copyText(file.text,1)">内&nbsp;&nbsp; 容:${ file.text }</span>
</div>
<div v-else>
<span>链&nbsp;&nbsp; 接:</span>
@@ -117,35 +220,43 @@
</div>
</div>
</el-card>
<el-empty v-if="files.length===0" description="请输入取件码,收取文件"></el-empty>
<el-empty v-if="quFiles.length===0" description="请输入取件码,收取文件"></el-empty>
</el-drawer>
<el-drawer
title="文件库"
:visible.sync="cunDrawer"
direction="btt"
title="文件箱"
:visible.sync="jiDrawer"
:direction="direction"
size="50%">
<el-card>
<el-empty v-if="files.length===0" description="请上传文件"></el-empty>
<el-card style="margin-top: 0.2rem" v-for="file in files" :key="file.code">
<el-row>
<el-col :span="24" style="line-height: 45px">
${ file.name }
</el-col>
<el-col :span="24">
取件码:<h1 style="margin: 0;display: inline">${ file.code }</h1>
</el-col>
</el-row>
</el-card>
<el-empty v-if="jiFiles.length===0" description="请上传文件"></el-empty>
<el-card style="margin-top: 0.2rem" v-for="(file,index) in jiFiles" :key="index">
<el-row>
<el-col :span="15">
<el-row>
<el-col :span="24" style="line-height: 45px">
${ file.name }
</el-col>
<el-col :span="24">
取件码:
<h1 @click="copyText(file.code,0)" style="margin: 0;display: inline;cursor: pointer">
${ file.code }
</h1>
</el-col>
</el-row>
</el-col>
<el-col :span="4">
<img style="width: 80px;height: 80px;"
:src="qrcodeUrl(file)" alt="二维码" :alt="file.code">
</el-col>
</el-row>
</el-card>
</el-drawer>
<div style="text-align: center; margin-top: 1rem;color: #606266">
<a style="text-decoration: none;color: #606266" target="_blank" href="https://github.com/vastsa/FileCodeBox">FileCodeBox
V1.6 Beta</a>
</div>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="//unpkg.com/axios/dist/axios.min.js"></script>
<script src="/static/asserts/axios.min.js"></script>
<script>
new Vue({
el: '#app',
@@ -153,105 +264,195 @@
data: function () {
return {
code: '',
inout_disable: false,
files: [],
quDrawer: false,
cunDrawer: false,
jiDrawer: false,
direction: 'btt',
tool: 0
quFiles: [],
jiFiles: [],
pageNum: 0,
inputDisable: false,
fileSizeLimit: '{{fileSizeLimit}}',
pwd: localStorage.getItem('pwd') || '',
banners: [],
enableUpload: false,
uploadData: {
style: '2',
type: '1',
value: 1,
file: null,
text: ''
},
};
},
mounted: function () {
this.code = window.location.search.substring('code=='.length)
if (this.code) {
this.get_file();
// 进入网站时,判断Get是否有code参数,有则直接进行取件操作
let code = window.location.search.substring('code=='.length)
if (code) {
this.code = code
this.getFile()
}
// 剪切板监听
const that = this
document.addEventListener('paste', function (event) {
if (that.tool === 1) {
if (that.pageNum === 1) {
const items = event.clipboardData && event.clipboardData.items;
if (items && items.length) {
for (let i = 0; i < items.length; i++) {
if (items[i].kind === 'string') {
if (items[i].type.match(/^text\/plain/)) {
const FileData = new FormData();
if (items[i].type.match(/^text\/plain/) && that.uploadData.type !== '2') {
that.$message('剪切板文字正在上传,请稍等');
items[i].getAsString(function (str) {
FileData.append('text', str);
axios.post('/share', FileData)
.then(function (response) {
that.$message({'message': response.data.msg, 'type': 'success'});
that.files.push(response.data.data)
})
.catch(function (error) {
that.$message({'message': error.data.msg, 'type': 'error'});
});
that.uploadData.text = str;
that.toUploadData();
});
}
} else {
const file = items[i].getAsFile();
that.$message('剪切板文件正在上传,请稍等');
const FileData = new FormData();
FileData.append('file', file || '');
axios.post('/share', FileData).then(async res => {
that.files.push(res.data.data);
that.$message({'message': res.data.msg, 'type': 'success'});
})
that.uploadData.file = file
that.toUploadData();
}
}
}
}
});
// 获取Banner
axios.get('/banner', {
headers: {
pwd: localStorage.getItem('pwd')
}
}).then(res => {
this.enableUpload = res.data.enable
this.banners = res.data.data
})
},
watch: {
code: function (code) {
if (code.length === 5) {
this.inout_disable = true;
this.getFile();
}
}
},
methods: {
inputing: function (value) {
if (value.length === 5) {
this.inout_disable = true;
this.get_file();
}
},
get_file: function () {
const that = this;
axios.post('?code=' + this.code).then(function (response) {
if (response.data.code === 404) {
that.$message({
message: response.data.msg,
type: 'error'
});
} else {
that.files.push(response.data.data);
that.$message({
message: response.data.msg,
http: function (method, url, data = {}, config = {}) {
return new Promise((resolve, reject) => {
axios({
method: method,
url: url,
data: data,
...config
}).then(res => {
this.$message({
message: res.data.detail,
type: 'success'
});
}
that.code = '';
that.inout_disable = false
}).catch(function (error) {
console.log(error);
});
resolve(res.data)
}).catch(err => {
this.$message({
message: err.response.data.detail,
type: 'error'
});
})
})
},
inputNumber: function (number) {
if (number === 'C') {
this.code = '';
} else if (number === 'X') {
this.code = this.code.substring(0, this.code.length - 1);
} else {
if (this.code.length < 5) {
this.code += number;
copyText: function (value, style = 1) {
if (style === 0) {
value = `我给你分享了文件,取件码:${value},${window.location.href}?code=${value}`;
}
const input = document.createElement('input');
input.setAttribute('readonly', 'readonly');
input.setAttribute('value', value);
document.body.appendChild(input);
input.select();
if (document.execCommand('copy')) {
document.execCommand('copy');
this.$message({
message: '复制成功,快去分享给你的朋友吧',
type: 'success'
});
}
document.body.removeChild(input);
},
getFile: function () {
const that = this;
this.http('post', `?code=${that.code}`).then(res => {
that.quDrawer = true;
that.quFiles.unshift(res.data);
})
that.code = '';
that.input_disable = false
},
qrcodeUrl(file) {
return 'https://api.qrserver.com/v1/create-qr-code/?data=' + window.location.href + '?code=' + file.code
},
listenInput: function (value) {
if (this.code.length < 5) {
this.code += value;
}
},
changeInput: function (value) {
this.code = value;
},
checkFile: function (file) {
if (!this.enableUpload) {
this.$message({
message: '上传功能已关闭',
type: 'error'
});
return false
}
if (file != null) {
if (file.size > this.fileSizeLimit) {
this.$message({
message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`,
type: 'error'
});
return false;
}
}
if (this.code.length === 5) {
this.inout_disable = true
this.get_file()
return true;
},
toUploadData: function () {
if (this.uploadData.text === '' && this.uploadData.file === null) {
this.$message({
message: '请先粘贴文字或者上传文件',
type: 'error'
});
} else {
if (this.checkFile(this.uploadData.file)) {
this.http('post', '/share', this.uploadData, {
headers: {
'Content-Type': 'multipart/form-data',
'pwd': this.pwd
}
}).then(res => {
this.jiFiles.unshift(res.data);
this.jiDrawer = true;
this.uploadData.text = '';
this.uploadData.file = null;
});
}
}
},
successUpload(response, file, fileList) {
this.files.push(response.data[0])
this.$message({
message: response.detail,
type: 'success'
});
this.jiFiles.unshift(response.data);
},
errorUpload(error, file, fileList) {
error = JSON.parse(error.message)
this.$message({
message: error.detail,
type: 'error'
});
},
beforeUpload: function (file) {
return this.checkFile(file);
}
}
})
</script>
</html>
</html>