From c3022bff788cc6c459d407289e55d30b0fa2f54c Mon Sep 17 00:00:00 2001 From: lan Date: Tue, 27 Dec 2022 13:27:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E5=89=8D=E6=A3=80?= =?UTF-8?q?=E6=B5=8B+=E4=B8=8A=E4=BC=A0=E6=AC=A1=E6=95=B0=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- depends.py | 5 +---- storage.py | 24 ------------------------ templates/index.html | 17 ++++++++++------- 3 files changed, 11 insertions(+), 35 deletions(-) diff --git a/depends.py b/depends.py index 31be37b..40a5f46 100644 --- a/depends.py +++ b/depends.py @@ -16,11 +16,8 @@ async def admin_required(pwd: Union[str, None] = Header(default=None), request: class IPRateLimit: - ips = {} - count = 0 - minutes = 0 - def __init__(self, count, minutes): + self.ips = {} self.count = count self.minutes = minutes diff --git a/storage.py b/storage.py index da20e3d..5ee79f2 100644 --- a/storage.py +++ b/storage.py @@ -9,30 +9,6 @@ from fastapi import UploadFile import settings -class TencentCOS: - def __init__(self, bucket: str, region: str, secret_id: str, secret_key: str): - self.bucket = bucket - self.region = region - self.secret_id = secret_id - self.secret_key = secret_key - - def upload(self, file: UploadFile, path: str) -> str: - # 上传文件 - pass - - def download(self, path: str) -> BinaryIO: - # 下载文件 - pass - - def delete(self, path: str) -> None: - # 删除文件 - pass - - def get_url(self, path: str) -> str: - # 获取文件访问链接 - pass - - class FileSystemStorage: DATA_ROOT = Path(settings.DATA_ROOT) STATIC_URL = settings.STATIC_URL diff --git a/templates/index.html b/templates/index.html index 401c076..d7e77d2 100644 --- a/templates/index.html +++ b/templates/index.html @@ -397,20 +397,23 @@ this.code = value; }, checkFile: function (file) { - if (!this.enable) { + if (!this.enableUpload) { this.$message({ message: '上传功能已关闭', type: 'error' }); return false } - if (file.size > this.fileSizeLimit) { - this.$message({ - message: `文件大小不能超过${this.fileSizeLimit/1024/1024}MB`, - 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) {