Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3da4fc0ea7 | ||
|
|
c7253ba874 | ||
|
|
2bb32bc59c | ||
|
|
c9785b92d7 | ||
|
|
455602d323 | ||
|
|
65fa3c9a7d | ||
|
|
c87e388ad3 | ||
|
|
77b50f950f | ||
|
|
46310bb4b8 | ||
|
|
34327f4a53 | ||
|
|
fbba00fda7 | ||
|
|
ea52327e49 | ||
|
|
7f44093c91 | ||
|
|
1bbe7f4d5d | ||
|
|
b2825cf088 | ||
|
|
e9c34a3710 | ||
|
|
3344f471e3 | ||
|
|
c8ac6bb76b | ||
|
|
e66e668616 | ||
|
|
c3022bff78 | ||
|
|
f070bdcece | ||
|
|
58e8407e7d | ||
|
|
5462584188 | ||
|
|
143d4794bc | ||
|
|
58c1d3d44b | ||
|
|
757e8ec16a | ||
|
|
2fc95ebc7e | ||
|
|
64f476e6db | ||
|
|
0d5e26f752 | ||
|
|
b33671a018 | ||
|
|
56cf08ccd1 | ||
|
|
f4089877ed | ||
|
|
248e6b8292 | ||
|
|
ab3971f911 | ||
|
|
6c07f9a5ab | ||
|
|
f94a918253 | ||
|
|
eec2ec6354 | ||
|
|
330b34953d | ||
|
|
0433507a9c | ||
|
|
63105579f7 | ||
|
|
255a2149b0 | ||
|
|
0b12aad4eb | ||
|
|
7767ade2f3 | ||
|
|
c15bf9563c | ||
|
|
99529b69ee | ||
|
|
d6029e4899 | ||
|
|
f80d50981c | ||
|
|
dfb7367100 | ||
|
|
d764cb48e3 | ||
|
|
14b6f0e9a7 | ||
|
|
f01d39c1c9 | ||
|
|
59805273bf | ||
|
|
a58102a61b | ||
|
|
b40c77e49f | ||
|
|
c686822c43 | ||
|
|
4ed95f8b64 | ||
|
|
d47da11916 | ||
|
|
8a93dd5e38 | ||
|
|
1c938948fd | ||
|
|
141008639a | ||
|
|
dd3267cf1f | ||
|
|
3d6f5ba9f4 | ||
|
|
422ae8adff | ||
|
|
cb340b6b22 | ||
|
|
b3533e897a | ||
|
|
0bc73796e7 | ||
|
|
594c105190 | ||
|
|
6caca3cb7b | ||
|
|
2d9348c293 | ||
|
|
ec6939f824 | ||
|
|
6d83e94c2f | ||
|
|
3c0376b63c | ||
|
|
f021673961 | ||
|
|
de190e6345 | ||
|
|
f9daa3cab3 | ||
|
|
965384500a | ||
|
|
eb9a656ee1 | ||
|
|
5543811c20 | ||
|
|
1f14997e4a | ||
|
|
5297146a63 | ||
|
|
d77dcb3f92 | ||
|
|
133e85fa49 | ||
|
|
a432f8d80f | ||
|
|
2a102bfb1f | ||
|
|
1994ba5917 | ||
|
|
68175f9583 | ||
|
|
0caabe3ee8 | ||
|
|
5c350cbfc6 | ||
|
|
0a200da28b | ||
|
|
7f2c1c9e7c | ||
|
|
12d28ec691 | ||
|
|
65ad220bb4 | ||
|
|
585bf0948c | ||
|
|
a258bb4ea3 | ||
|
|
d8985db3e1 | ||
|
|
a17a7e1d58 | ||
|
|
63d60022d2 | ||
|
|
8ffddd5870 |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [vastsa]
|
||||
custom: [https://share.lanol.cn]
|
||||
@@ -1,7 +1,7 @@
|
||||
FROM python:3.9.5
|
||||
FROM python:3.9.5-slim-buster
|
||||
LABEL author="Lan"
|
||||
LABEL email="vast@tom.com"
|
||||
LABEL version="1.4.4"
|
||||
LABEL version="1.5.9.2"
|
||||
|
||||
|
||||
COPY . /app
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import datetime
|
||||
from sqlalchemy import Boolean, Column, Integer, String, DateTime
|
||||
from sqlalchemy import Boolean, Column, Integer, String, DateTime, JSON, Text
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.ext.asyncio import create_async_engine
|
||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||
import settings
|
||||
|
||||
engine = create_async_engine(settings.DATABASE_URL)
|
||||
|
||||
Base = declarative_base()
|
||||
@@ -19,6 +20,13 @@ async def get_session():
|
||||
yield s
|
||||
|
||||
|
||||
class Values(Base):
|
||||
__tablename__ = 'values'
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
key = Column(String, unique=True)
|
||||
value = Column(JSON)
|
||||
|
||||
|
||||
class Codes(Base):
|
||||
__tablename__ = "codes"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
@@ -27,7 +35,7 @@ class Codes(Base):
|
||||
name = Column(String(500))
|
||||
size = Column(Integer)
|
||||
type = Column(String(20))
|
||||
text = Column(String(500))
|
||||
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)
|
||||
|
||||
@@ -6,17 +6,18 @@ from fastapi import Header, HTTPException, Request
|
||||
import settings
|
||||
|
||||
|
||||
async def admin_required(pwd: Union[str, None] = Header(default=None)):
|
||||
if not pwd or pwd != settings.ADMIN_PASSWORD:
|
||||
raise HTTPException(status_code=401, detail="密码错误")
|
||||
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 not pwd or pwd != settings.ADMIN_PASSWORD:
|
||||
raise HTTPException(status_code=401, detail="密码错误,请重新登录")
|
||||
|
||||
|
||||
class IPRateLimit:
|
||||
ips = {}
|
||||
count = 0
|
||||
minutes = 0
|
||||
|
||||
def __init__(self, count, minutes):
|
||||
self.ips = {}
|
||||
self.count = count
|
||||
self.minutes = minutes
|
||||
|
||||
@@ -30,10 +31,10 @@ class IPRateLimit:
|
||||
self.ips.pop(ip)
|
||||
return True
|
||||
|
||||
def add_ip(cls, ip):
|
||||
ip_info = cls.ips.get(ip, {'count': 0, 'time': datetime.now()})
|
||||
def add_ip(self, ip):
|
||||
ip_info = self.ips.get(ip, {'count': 0, 'time': datetime.now()})
|
||||
ip_info['count'] += 1
|
||||
cls.ips[ip] = ip_info
|
||||
self.ips[ip] = ip_info
|
||||
return ip_info['count']
|
||||
|
||||
async def remove_expired_ip(self):
|
||||
@@ -42,7 +43,7 @@ class IPRateLimit:
|
||||
self.ips.pop(ip)
|
||||
|
||||
def __call__(self, request: Request):
|
||||
ip = request.client.host
|
||||
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
|
||||
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 174 KiB |
|
After Width: | Height: | Size: 59 KiB |
|
After Width: | Height: | Size: 40 KiB |
@@ -2,21 +2,33 @@ import datetime
|
||||
import uuid
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
from fastapi import FastAPI, Depends, UploadFile, Form, File, HTTPException, BackgroundTasks
|
||||
from starlette.responses import HTMLResponse, FileResponse
|
||||
from starlette.staticfiles import StaticFiles
|
||||
|
||||
from sqlalchemy import select, update
|
||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||
try:
|
||||
import chardet
|
||||
from fastapi import FastAPI, Depends, UploadFile, Form, File, HTTPException, BackgroundTasks
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import HTMLResponse, FileResponse
|
||||
from starlette.staticfiles import StaticFiles
|
||||
from sqlalchemy import select, update, func
|
||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||
except ImportError:
|
||||
os.system("pip install -r requirements.txt")
|
||||
import chardet
|
||||
from fastapi import FastAPI, Depends, UploadFile, Form, File, HTTPException, BackgroundTasks
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import HTMLResponse, FileResponse
|
||||
from starlette.staticfiles import StaticFiles
|
||||
from sqlalchemy import select, update, func
|
||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||
|
||||
import settings
|
||||
from utils import delete_expire_files, storage, get_code, error_ip_limit, upload_ip_limit
|
||||
from database import get_session, Codes, init_models
|
||||
from database import get_session, Codes, init_models, Values
|
||||
from depends import admin_required
|
||||
|
||||
# 实例化FastAPI
|
||||
app = FastAPI(debug=settings.DEBUG)
|
||||
app = FastAPI(debug=settings.DEBUG, docs_url=None, redoc_url=None)
|
||||
|
||||
# 数据存储文件夹
|
||||
DATA_ROOT = Path(settings.DATA_ROOT)
|
||||
@@ -39,24 +51,42 @@ async def startup():
|
||||
index_html = open('templates/index.html', 'r', encoding='utf-8').read() \
|
||||
.replace('{{title}}', settings.TITLE) \
|
||||
.replace('{{description}}', settings.DESCRIPTION) \
|
||||
.replace('{{keywords}}', settings.KEYWORDS)
|
||||
# 管理页面
|
||||
.replace('{{keywords}}', settings.KEYWORDS) \
|
||||
.replace("'{{fileSizeLimit}}'", str(settings.FILE_SIZE_LIMIT)) \
|
||||
# 管理页面
|
||||
admin_html = open('templates/admin.html', 'r', encoding='utf-8').read() \
|
||||
.replace('{{title}}', settings.TITLE) \
|
||||
.replace('{{description}}', settings.DESCRIPTION) \
|
||||
.replace('{{keywords}}', settings.KEYWORDS)
|
||||
|
||||
|
||||
@app.get(f'/{settings.ADMIN_ADDRESS}', description='管理页面', response_class=HTMLResponse)
|
||||
@app.get(f'/{settings.ADMIN_ADDRESS}', description='管理页面')
|
||||
async def admin():
|
||||
return HTMLResponse(admin_html)
|
||||
|
||||
|
||||
@app.post(f'/{settings.ADMIN_ADDRESS}', dependencies=[Depends(admin_required)], description='查询数据库列表')
|
||||
async def admin_post(s: AsyncSession = Depends(get_session)):
|
||||
# 查询数据库列表
|
||||
codes = (await s.execute(select(Codes))).scalars().all()
|
||||
return {'detail': '查询成功', 'data': codes}
|
||||
async def admin_post(page: int = Form(default=1), size: int = Form(default=10), s: AsyncSession = Depends(get_session)):
|
||||
codes = (await s.execute(select(Codes).offset((page - 1) * size).limit(size))).scalars().all()
|
||||
total = (await s.execute(select(func.count(Codes.id)))).scalar()
|
||||
return {'detail': '查询成功', 'data': codes, 'paginate': {
|
||||
'page': page,
|
||||
'size': size,
|
||||
'total': total
|
||||
}}
|
||||
|
||||
|
||||
@app.patch(f'/{settings.ADMIN_ADDRESS}', dependencies=[Depends(admin_required)], description='修改数据库数据')
|
||||
async def admin_patch(request: Request, s: AsyncSession = Depends(get_session)):
|
||||
# 从数据库获取系统配置
|
||||
# 如果不存在config这个key,就创建一个
|
||||
config = (await s.execute(select(Values).filter(Values.key == 'config'))).scalar_one_or_none()
|
||||
if not config:
|
||||
s.add(Values(key='config', value=await request.json()))
|
||||
else:
|
||||
await s.execute(update(Values).where(Values.key == 'config').values(value=await request.json()))
|
||||
await s.commit()
|
||||
return {'detail': '修改成功'}
|
||||
|
||||
|
||||
@app.delete(f'/{settings.ADMIN_ADDRESS}', dependencies=[Depends(admin_required)], description='删除数据库记录')
|
||||
@@ -75,11 +105,64 @@ async def admin_delete(code: str, s: AsyncSession = Depends(get_session)):
|
||||
return {'detail': '删除成功'}
|
||||
|
||||
|
||||
@app.get('/config', description='获取系统配置', dependencies=[Depends(admin_required)])
|
||||
async def config(s: AsyncSession = Depends(get_session)):
|
||||
# 从数据库获取系统配置
|
||||
data = (await s.execute(select(Values).filter(Values.key == 'config'))).scalar_one_or_none()
|
||||
return {'detail': '获取成功', 'data': data.value if data else {'banners': []}}
|
||||
|
||||
|
||||
@app.get('/')
|
||||
async def index():
|
||||
return HTMLResponse(index_html)
|
||||
|
||||
|
||||
@app.post('/')
|
||||
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 = f'/select?code={code}'
|
||||
return {
|
||||
'detail': f'取件成功,文件将在{settings.DELETE_EXPIRE_FILES_INTERVAL}分钟后删除',
|
||||
'data': {'type': info.type, 'text': info.text, 'name': info.name, 'code': info.code}
|
||||
}
|
||||
|
||||
|
||||
@app.get('/banner')
|
||||
async def banner(request: Request, s: AsyncSession = Depends(get_session)):
|
||||
# 数据库查询config
|
||||
config = (await s.execute(select(Values).filter(Values.key == 'config'))).scalar_one_or_none()
|
||||
# 如果存在config,就返回config的value
|
||||
if config and config.value.get('banners'):
|
||||
return {
|
||||
'detail': '查询成功',
|
||||
'data': config.value['banners'],
|
||||
'enable': request.headers.get('pwd', '') == settings.ADMIN_PASSWORD or settings.ENABLE_UPLOAD,
|
||||
}
|
||||
# 如果不存在config,就返回默认的banner
|
||||
return {
|
||||
'detail': 'banner',
|
||||
'enable': request.headers.get('pwd', '') == settings.ADMIN_PASSWORD or settings.ENABLE_UPLOAD,
|
||||
'data': [{
|
||||
'text': 'FileCodeBox',
|
||||
'url': 'https://github.com/vastsa/FileCodeBox',
|
||||
'src': '/static/banners/img_1.png'
|
||||
}, {
|
||||
'text': 'FileCodeBox',
|
||||
'url': 'https://www.lanol.cn',
|
||||
'src': '/static/banners/img_2.png'
|
||||
}]
|
||||
}
|
||||
|
||||
|
||||
@app.get('/select')
|
||||
async def get_file(code: str, ip: str = Depends(error_ip_limit), s: AsyncSession = Depends(get_session)):
|
||||
# 查出数据库记录
|
||||
@@ -98,37 +181,14 @@ async def get_file(code: str, ip: str = Depends(error_ip_limit), s: AsyncSession
|
||||
return FileResponse(filepath, filename=info.name)
|
||||
|
||||
|
||||
@app.post('/')
|
||||
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:
|
||||
if info.type != "text":
|
||||
await storage.delete_file(info.text)
|
||||
await s.delete(info)
|
||||
await s.commit()
|
||||
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 = f'/select?code={code}'
|
||||
return {
|
||||
'detail': '取件成功,请点击"取"查看',
|
||||
'data': {'type': info.type, 'text': info.text, 'name': info.name, 'code': info.code}
|
||||
}
|
||||
|
||||
|
||||
@app.post('/share')
|
||||
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)):
|
||||
@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 > 7:
|
||||
raise HTTPException(status_code=400, detail="最大有效天数为7天")
|
||||
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':
|
||||
@@ -153,12 +213,12 @@ async def share(background_tasks: BackgroundTasks, text: str = Form(default=None
|
||||
await s.commit()
|
||||
upload_ip_limit.add_ip(ip)
|
||||
return {
|
||||
'detail': '分享成功,请点击取件码按钮查看上传列表',
|
||||
'data': {'code': code, 'key': key, 'name': name, 'text': _text}
|
||||
'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, debug=settings.DEBUG)
|
||||
uvicorn.run('main:app', host='0.0.0.0', port=settings.PORT, reload=settings.DEBUG)
|
||||
@@ -1,141 +1,258 @@
|
||||
# 文件快递柜
|
||||
<div style="text-align: center">
|
||||
<h1>文件快递柜-轻量</h1>
|
||||
<h2>FileCodeBox-Lite</h2>
|
||||
<p><em>匿名口令分享文本,文件,像拿快递一样取文件</em></p>
|
||||
</div>
|
||||
|
||||
## 解决问题
|
||||
---
|
||||
|
||||
很多时候,我们都想将一些文件或文本传送给别人,或者跨端传递一些信息,但是我们又不想为了分享,而去下载一些七里八里的软件,这时候,我们就可以使用口令传送箱,像拿快递一样取文件。
|
||||
[简体中文](./readme.md) | [English](./readme_en.md)
|
||||
|
||||
## 主要特色
|
||||
|
||||
- [x] 轻量简洁,Fastapi+sqlite3
|
||||
- [x] 拖拽,复制粘贴上传
|
||||
- [x] 文件口令传输,生成二维码
|
||||
- [x] 分享文件:多种上传方式供你选择
|
||||
- [x] 分享文本:直接复制粘贴直接上传
|
||||
- [x] 防爆破:错误五次拉黑十分钟
|
||||
- [x] 完全匿名:不记录任何信息,无需注册,无需登录
|
||||
- [x] Sqlite3数据库:无需安装数据库
|
||||
- [x] 可以加get参数code,这样打开就会读取取件码如:http://host?code=12345
|
||||
- [x] 管理面板:简单列表页删除违规文件
|
||||
- [x] 口令使用次数,口令有效期,二维码分享
|
||||
|
||||
## 更新记录
|
||||
### 2022年12月13日
|
||||
|
||||
- [x] 完善手机版上传文本
|
||||
- [x] 优化Index.html首页
|
||||
|
||||
### 2022年12月12日
|
||||
|
||||
- [x] 重写用户登录和 IP 检查并重定义状态码
|
||||
- [x] 新增存储引擎统一文件读写
|
||||
- [x] 设置PORT
|
||||
|
||||
### 2022年12月11日
|
||||
|
||||
1. 修复取件不显示码的问题
|
||||
2. 修复文件次数为1时,文件被删除的问题
|
||||
3. 使用 aiosqlite 驱动异步化数据库操作
|
||||
4. 增加定时清理过期文件
|
||||
5. 优化部署方式,Docker映射,后续更新直接覆盖代码重启
|
||||
6. 优化配置文件,增加配置项
|
||||
7. 发布V1.4.5稳定版
|
||||
|
||||
### 2022年12月10日
|
||||
|
||||
1. 管理面板已新增,一如既往的极简,只有删除
|
||||
2. 二维码图片(调用的网络接口,如果离线环境将无法使用,一切为了极简)
|
||||
3. 取件码有效期,取件码使用次数
|
||||
4. 优化代码逻辑
|
||||
5. 限制上传文件大小
|
||||
6. 完善配置参数
|
||||
|
||||
## 系统截图
|
||||
|
||||
1. 隐藏文件真实地址
|
||||
|
||||
### 取件
|
||||
|
||||

|
||||

|
||||
|
||||
### 寄件
|
||||
|
||||

|
||||

|
||||
|
||||
### 管理面板
|
||||
|
||||

|
||||

|
||||
|
||||
## 部署教程
|
||||
|
||||
https://www.yuque.com/lxyo/work/zd0kvzy7fofx6w7v
|
||||
- [x] 轻量简洁:Fastapi+Sqlite3+Vue2+ElementUI
|
||||
- [x] 轻松上传:复制粘贴,拖拽选择
|
||||
- [x] 多种类型:文本,文件
|
||||
- [x] 防止爆破:错误次数限制
|
||||
- [x] 防止滥用:IP限制上传次数
|
||||
- [x] 口令分享:随机口令,存取文件,自定义次数以及有效期
|
||||
- [x] 匿名分享:无需注册,无需登录
|
||||
- [x] 管理面板:查看所有文件,删除文件
|
||||
- [x] 一键部署:docker一键部署
|
||||
|
||||
## 部署方式
|
||||
|
||||
为持久化,不管怎么样,先第一步,建一个文件夹,然后再下载代码
|
||||
### Docker一键部署
|
||||
|
||||
#### AMD
|
||||
|
||||
```bash
|
||||
mkdir /opt/FileCodeBox
|
||||
cd /opt/FileCodeBox
|
||||
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:latest
|
||||
```
|
||||
|
||||
新建一个`.env`文件
|
||||
#### ARM
|
||||
|
||||
```bash
|
||||
vi .env
|
||||
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
|
||||
```
|
||||
|
||||
### 其他方式
|
||||
|
||||
仅供参考,历史版本->[部署文档](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://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_10.png" alt="寄文件">
|
||||
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_11.png" alt="寄文件">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### 寄件
|
||||
|
||||
<table style="width: 100%">
|
||||
<tr style="width: 100%">
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_1.png" alt="寄文件">
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_2.png" alt="寄文本">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="width: 100%;">
|
||||
<td colspan="2" style="width: 100%;">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_3.png" alt="寄文本">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### 取件
|
||||
|
||||
<table style="width: 100%">
|
||||
<tr style="width: 100%">
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_6.png" alt="取件">
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_5.png" alt="取件码错误">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="width: 100%;">
|
||||
<td colspan="2" style="width: 100%;">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_4.png" alt="取文件">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### 管理
|
||||
|
||||

|
||||
|
||||
## 配置文件
|
||||
|
||||
如果需要修改配置,可以将该文件放在`/opt/FileCodeBox/`目录下,并命名为`.env`,然后重启容器即可。
|
||||
如果不是Docker,则需要在项目同目录下新建一个`data`文件夹,然后在创建`.env`文件
|
||||
|
||||
```dotenv
|
||||
DEBUG=False
|
||||
# 端口
|
||||
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
|
||||
```
|
||||
|
||||
### 服务端部署
|
||||
## 接口文档
|
||||
|
||||
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. 然后你自己看着填吧
|
||||
#### PATH
|
||||
|
||||
### Docker部署
|
||||
```bash
|
||||
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/.env:/app/data --name filecodebox lanol/filecodebox:latest
|
||||
`/`
|
||||
|
||||
#### METHOD
|
||||
|
||||
`POST`
|
||||
|
||||
#### PARAMS
|
||||
|
||||
code: 取件码
|
||||
|
||||
#### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"detail": "msg",
|
||||
"data": {
|
||||
"type": "类型",
|
||||
"text": "文本",
|
||||
"name": "名称",
|
||||
"code": "取件码"
|
||||
}
|
||||
}
|
||||
```
|
||||
### Docker自己构建部署
|
||||
|
||||
```bash
|
||||
mkdir "/opt/FileCodeBox"
|
||||
cd "/opt/FileCodeBox"
|
||||
wget https://github.com/vastsa/FileCodeBox/releases/download/Main/code.zip
|
||||
unzip code.zip
|
||||
docker build --file Dockerfile --tag filecodebox .
|
||||
docker run -d -p 12345:12345 --name filecodebox --volume /opt/FileCodeBox:/app filecodebox
|
||||
### 寄件
|
||||
|
||||
#### PATH
|
||||
|
||||
`/share`
|
||||
|
||||
#### METHOD
|
||||
|
||||
`POST`
|
||||
|
||||
#### PARAMS
|
||||
|
||||
style: 1为次数,2为时间
|
||||
value: 次数或时间
|
||||
text: 取件码
|
||||
file: 文件
|
||||
|
||||
#### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"detail": "msg",
|
||||
"data": {
|
||||
"code": "类型",
|
||||
"key": "唯一ID",
|
||||
"name": "名称"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 状态
|
||||
|
||||

|
||||
|
||||
## Star History
|
||||
|
||||
[](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://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_9.png" alt="支付宝">
|
||||
</td>
|
||||
<td style="width: 50%;text-align: center">
|
||||
微信
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_8.png" alt="微信">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 常见问题
|
||||
|
||||
1. 413 Request Entity Too Large
|
||||
Nginx限制:
|
||||
找到自己主机的nginx.conf配置文件,打开
|
||||
在http{}中加入 client_max_body_size 10m;
|
||||
然后重启nginx
|
||||
|
||||
## 免责声明
|
||||
|
||||
本项目开源仅供学习使用,不得用于商业用途以及任何违法用途,否则后果自负,与本人无关。使用请保留项目地址谢谢。
|
||||
本项目开源仅供学习使用,不得用于任何违法用途,否则后果自负,与本人无关。使用请保留项目地址谢谢。
|
||||
@@ -0,0 +1,203 @@
|
||||
<div style="text-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>
|
||||
|
||||
---
|
||||
|
||||
[简体中文](./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
|
||||
|
||||
## 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://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_10.png" alt="寄文件">
|
||||
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_11.png" alt="寄文件">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### Send
|
||||
|
||||
<table style="width: 100%">
|
||||
<tr style="width: 100%">
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_1.png" alt="寄文件">
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_2.png" alt="寄文本">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="width: 100%;">
|
||||
<td colspan="2" style="width: 100%;">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_3.png" alt="寄文本">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### Receive
|
||||
|
||||
<table style="width: 100%">
|
||||
<tr style="width: 100%">
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_6.png" alt="取件">
|
||||
</td>
|
||||
<td style="width: 50%">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_5.png" alt="取件码错误">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="width: 100%;">
|
||||
<td colspan="2" style="width: 100%;">
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_4.png" alt="取文件">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### Manage
|
||||
|
||||

|
||||
|
||||
## 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
|
||||
```
|
||||
|
||||
## Status
|
||||
|
||||

|
||||
|
||||
## Star History
|
||||
|
||||
[](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://raw.githubusercontent.com/vastsa/FileCodeBox/master/images/img_9.png" alt="支付宝">
|
||||
</td>
|
||||
<td style="width: 50%;text-align: center">
|
||||
微信
|
||||
<img src="https://raw.githubusercontent.com/vastsa/FileCodeBox/master/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.
|
||||
@@ -4,4 +4,5 @@ SQLAlchemy==1.4.44
|
||||
python-multipart==0.0.5
|
||||
uvicorn==0.15.0
|
||||
greenlet==2.0.1
|
||||
starlette~=0.22.0
|
||||
starlette~=0.22.0
|
||||
chardet == 5.1.0
|
||||
@@ -1,18 +1,31 @@
|
||||
from starlette.config import Config
|
||||
import os
|
||||
import shutil
|
||||
|
||||
# 配置文件.env
|
||||
# 请将.env移动至data目录,方便docker部署
|
||||
# 判断根目录下是否存在.env文件
|
||||
if os.path.exists('.env'):
|
||||
# 将文件复制到data目录
|
||||
shutil.copy('.env', 'data/.env')
|
||||
|
||||
config = Config("data/.env")
|
||||
# 是否开启DEBUG模式
|
||||
DEBUG = config('DEBUG', cast=bool, default=False)
|
||||
# 端口
|
||||
PORT = config('PORT', cast=int, default=12345)
|
||||
# Sqlite数据库文件
|
||||
DATABASE_URL = config('DATABASE_URL', cast=str, default="sqlite+aiosqlite:///data/database.db")
|
||||
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")
|
||||
# 静态文件夹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)
|
||||
# 错误限制分钟数
|
||||
@@ -21,6 +34,8 @@ 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="admin")
|
||||
# 管理密码
|
||||
|
||||
|
Before Width: | Height: | Size: 264 KiB After Width: | Height: | Size: 264 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 172 KiB |
|
After Width: | Height: | Size: 127 KiB |
@@ -49,12 +49,23 @@ class FileSystemStorage:
|
||||
|
||||
async def delete_file(self, text: str):
|
||||
filepath = await self.get_filepath(text)
|
||||
await asyncio.to_thread(os.remove, filepath)
|
||||
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
|
||||
|
||||
@@ -5,25 +5,37 @@
|
||||
<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/assert/index.css">
|
||||
<link rel="shortcut icon" href="/static/assert/favicon.ico" type="image/x-icon"/>
|
||||
<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/assert/vue.min.js"></script>
|
||||
<script src="/static/assert/index.js"></script>
|
||||
<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 :xs="0" :sm="4" :md="4" :lg="4" :xl="4">
|
||||
|
||||
<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>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="16" :md="16" :lg="16" :xl="16">
|
||||
<el-card>
|
||||
<el-empty v-if="files.length===0" description="暂时还没有文件"></el-empty>
|
||||
<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">
|
||||
@@ -32,7 +44,7 @@
|
||||
<div>文件名:${ file.name }</div>
|
||||
<div>次 数:${ file.count }</div>
|
||||
<div>到 期:${ file.exp_time.slice(0,19) }</div>
|
||||
<div v-if="file.name==='分享文本'">
|
||||
<div v-if="file.type==='text'">
|
||||
<span>内 容:${ file.text }</span>
|
||||
</div>
|
||||
<div v-else>
|
||||
@@ -49,8 +61,36 @@
|
||||
</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-form ref="form" style="width: 50%;margin:2rem auto" :model="config" label-width="200px"><el-form-item v-for="(banner,index) in config.banners" :label="'Banner'+ (index+1)">
|
||||
<div style="width: 50%;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>
|
||||
</el-col>
|
||||
<el-col :xs="0" :sm="4" :md="4" :lg="4" :xl="4"> </el-col>
|
||||
</el-row>
|
||||
<div v-else style="width: 250px;text-align: center;margin: 40vh auto">
|
||||
<el-input v-model="pwd" placeholder="请输入登录密码">
|
||||
@@ -60,7 +100,7 @@
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<script src="/static/assert/axios.min.js"></script>
|
||||
<script src="/static/asserts/axios.min.js"></script>
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
@@ -69,12 +109,16 @@
|
||||
return {
|
||||
login: false,
|
||||
pwd: '',
|
||||
files: [],
|
||||
activeIndex: '2',
|
||||
config: {
|
||||
error_count: 0,
|
||||
file_size: 0,
|
||||
admin_pwd: 'admin'
|
||||
}
|
||||
banners: []
|
||||
},
|
||||
files: [],
|
||||
paginate: {
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
},
|
||||
};
|
||||
},
|
||||
mounted: function () {
|
||||
@@ -82,13 +126,58 @@
|
||||
if (pwd) {
|
||||
login = true;
|
||||
this.pwd = pwd;
|
||||
axios.get('/config', {
|
||||
headers: {
|
||||
pwd: pwd
|
||||
}
|
||||
}).then(res => {
|
||||
console.log(res.data.data)
|
||||
this.config = res.data.data;
|
||||
});
|
||||
this.loginAdmin();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
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('', {}, {'headers': {'pwd': this.pwd}}).then(res => {
|
||||
this.files = res.data.data;
|
||||
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);
|
||||
}).catch(e => {
|
||||
@@ -96,6 +185,9 @@
|
||||
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)
|
||||
@@ -108,4 +200,4 @@
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
</html>
|
||||
@@ -5,14 +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="/static/assert/index.css">
|
||||
<link rel="shortcut icon" href="/static/assert/favicon.ico" type="image/x-icon"/>
|
||||
<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-V1.5.1"/>
|
||||
<meta name="template" content="Lan-V1.5.9.2"/>
|
||||
<style>
|
||||
body {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.qu .el-button {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
@@ -21,80 +25,137 @@
|
||||
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;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="/static/assert/vue.min.js"></script>
|
||||
<script src="/static/assert/index.js"></script>
|
||||
.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="pageNum === 0" class="qu" style="width:400px;margin: 6vh auto 0 auto">
|
||||
<el-card style="padding-bottom: 1rem">
|
||||
<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 @change="changeInput" clearable v-model:value="code" maxlength="5"
|
||||
<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="listenInput('1')">1</el-button>
|
||||
<el-button round @click="listenInput('1')">1</el-button>
|
||||
</el-col>
|
||||
<el-col :span=8>
|
||||
<el-button @click="listenInput('2')">2</el-button>
|
||||
<el-button round @click="listenInput('2')">2</el-button>
|
||||
</el-col>
|
||||
<el-col :span=8>
|
||||
<el-button @click="listenInput('3')">3</el-button>
|
||||
<el-button round @click="listenInput('3')">3</el-button>
|
||||
</el-col>
|
||||
<el-col :span=8>
|
||||
<el-button @click="listenInput('4')">4</el-button>
|
||||
<el-button round @click="listenInput('4')">4</el-button>
|
||||
</el-col>
|
||||
<el-col :span=8>
|
||||
<el-button @click="listenInput('5')">5</el-button>
|
||||
<el-button round @click="listenInput('5')">5</el-button>
|
||||
</el-col>
|
||||
<el-col :span=8>
|
||||
<el-button @click="listenInput('6')">6</el-button>
|
||||
<el-button round @click="listenInput('6')">6</el-button>
|
||||
</el-col>
|
||||
<el-col :span=8>
|
||||
<el-button @click="listenInput('7')">7</el-button>
|
||||
<el-button round @click="listenInput('7')">7</el-button>
|
||||
</el-col>
|
||||
<el-col :span=8>
|
||||
<el-button @click="listenInput('8')">8</el-button>
|
||||
<el-button round @click="listenInput('8')">8</el-button>
|
||||
</el-col>
|
||||
<el-col :span=8>
|
||||
<el-button @click="listenInput('9')">9</el-button>
|
||||
<el-button round @click="listenInput('9')">9</el-button>
|
||||
</el-col>
|
||||
<el-col :span=8>
|
||||
<el-button @click="pageNum=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="listenInput('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: 20vh auto 0 auto">
|
||||
<el-col :span="24" style="margin: 1rem 0">
|
||||
<el-card>
|
||||
<el-input style="width: 200px" 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 v-model="uploadData.type" style="margin-left: 18px">
|
||||
<el-radio label="1">文件</el-radio>
|
||||
<el-radio label="2">文本</el-radio>
|
||||
</el-radio-group>
|
||||
<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
|
||||
@@ -102,6 +163,8 @@
|
||||
multiple
|
||||
style="margin: 1rem 0;"
|
||||
:data="uploadData"
|
||||
:before-upload="beforeUpload"
|
||||
:headers="{'pwd':pwd}"
|
||||
:on-success="successUpload"
|
||||
:on-error="errorUpload"
|
||||
>
|
||||
@@ -114,13 +177,23 @@
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 8}"
|
||||
style="margin: 1rem 0"
|
||||
placeholder="请输入内容,完成之后点击下方寄出去"
|
||||
placeholder="请输入内容,使用按钮存入"
|
||||
v-model="uploadData.text">
|
||||
</el-input>
|
||||
|
||||
<div class="el-upload__tip">
|
||||
<el-button @click="pageNum=0">去取件</el-button>
|
||||
<el-button @click="jiDrawer=true">取件码</el-button>
|
||||
<el-button v-if="uploadData.type === '2'" @click="toUploadData">寄出去</el-button>
|
||||
<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>
|
||||
@@ -131,12 +204,12 @@
|
||||
: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>内 容:${ file.text }</span>
|
||||
<span @click="copyText(file.text,1)">内 容:${ file.text }</span>
|
||||
</div>
|
||||
<div v-else>
|
||||
<span>链 接:</span>
|
||||
@@ -146,41 +219,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="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,index) in files" :key="index">
|
||||
<el-row>
|
||||
<el-col :span="20">
|
||||
<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-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-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</a>
|
||||
<a style="text-decoration: none;color: #606266" target="_blank" href="https://github.com/vastsa/FileCodeBox">FileCodeBox
|
||||
V1.5.9.2</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="/static/assert/axios.min.js"></script>
|
||||
<script src="/static/asserts/axios.min.js"></script>
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
@@ -191,9 +266,14 @@
|
||||
quDrawer: false,
|
||||
jiDrawer: false,
|
||||
direction: 'btt',
|
||||
files: [],
|
||||
quFiles: [],
|
||||
jiFiles: [],
|
||||
pageNum: 0,
|
||||
inputDisable: false,
|
||||
fileSizeLimit: '{{fileSizeLimit}}',
|
||||
pwd: localStorage.getItem('pwd') || '',
|
||||
banners: [],
|
||||
enableUpload: false,
|
||||
uploadData: {
|
||||
style: '2',
|
||||
type: '1',
|
||||
@@ -235,6 +315,15 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
// 获取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) {
|
||||
@@ -266,17 +355,35 @@
|
||||
})
|
||||
})
|
||||
},
|
||||
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.files.unshift(res.data);
|
||||
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.origin + '/?code=' + file.code
|
||||
return 'https://api.qrserver.com/v1/create-qr-code/?data=' + window.location.href + '?code=' + file.code
|
||||
},
|
||||
listenInput: function (value) {
|
||||
if (this.code.length < 5) {
|
||||
@@ -286,6 +393,25 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
toUploadData: function () {
|
||||
if (this.uploadData.text === '' && this.uploadData.file === null) {
|
||||
this.$message({
|
||||
@@ -293,25 +419,27 @@
|
||||
type: 'error'
|
||||
});
|
||||
} else {
|
||||
this.http('post', '/share', this.uploadData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
}).then(res => {
|
||||
this.files.unshift(res.data);
|
||||
this.jiDrawer = true;
|
||||
this.uploadData.text = '';
|
||||
this.uploadData.file = null;
|
||||
});
|
||||
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) {
|
||||
console.log(response)
|
||||
this.$message({
|
||||
message: response.detail,
|
||||
type: 'success'
|
||||
});
|
||||
this.files.unshift(response.data);
|
||||
this.jiFiles.unshift(response.data);
|
||||
},
|
||||
errorUpload(error, file, fileList) {
|
||||
error = JSON.parse(error.message)
|
||||
@@ -320,7 +448,10 @@
|
||||
type: 'error'
|
||||
});
|
||||
},
|
||||
beforeUpload: function (file) {
|
||||
return this.checkFile(file);
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
</html>
|
||||
@@ -1,6 +1,8 @@
|
||||
import datetime
|
||||
import random
|
||||
import asyncio
|
||||
|
||||
import chardet
|
||||
from sqlalchemy import or_, select, delete
|
||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||
import settings
|
||||
@@ -33,7 +35,7 @@ async def delete_expire_files():
|
||||
query = delete(Codes).where(Codes.id.in_(exps_ids))
|
||||
await s.execute(query)
|
||||
await s.commit()
|
||||
await asyncio.sleep(random.randint(2, 2))
|
||||
await asyncio.sleep(settings.DELETE_EXPIRE_FILES_INTERVAL * 60)
|
||||
|
||||
|
||||
async def get_code(s: AsyncSession):
|
||||
|
||||