From f9cd9c95c3e210fc6add2bd3a3724d697972eaf5 Mon Sep 17 00:00:00 2001 From: lan Date: Sat, 15 Jun 2024 20:28:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=89=8D=E7=AB=AF=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AF=E6=B8=B8=E5=AE=A2=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fcb-fronted/src/components/UploadFile.vue | 11 +++++++++++ fcb-fronted/src/components/UploadText.vue | 4 ++++ fcb-fronted/src/locals/zh.ts | 1 + main.py | 1 + 4 files changed, 17 insertions(+) diff --git a/fcb-fronted/src/components/UploadFile.vue b/fcb-fronted/src/components/UploadFile.vue index bfab5ebfa..40257bdbb 100644 --- a/fcb-fronted/src/components/UploadFile.vue +++ b/fcb-fronted/src/components/UploadFile.vue @@ -41,6 +41,17 @@ const handleOnChangeFileList = (file: any) => { const handleHttpRequest = (options: any) => { fileBoxStore.showFileBox = true; const formData = new FormData(); + if (config.openUpload === 0 || localStorage.getItem('adminPassword') === null) { + fileStore.shareData.forEach((file: any) => { + if (file.uid === options.file.uid) { + ElMessage.error(t('msg.uploadClose')); + file.status = 'fail'; + file.code = t('msg.fileUploadFail'); + fileStore.save(); + } + }); + return; + } if (options.file.size > config.uploadSize) { fileStore.shareData.forEach((file: any) => { if (file.uid === options.file.uid) { diff --git a/fcb-fronted/src/components/UploadText.vue b/fcb-fronted/src/components/UploadText.vue index 199022b13..8f03a0fb6 100644 --- a/fcb-fronted/src/components/UploadText.vue +++ b/fcb-fronted/src/components/UploadText.vue @@ -7,8 +7,10 @@ import { useFileBoxStore } from "@/stores/fileBox"; import { ElMessage } from "element-plus"; import { useI18n } from 'vue-i18n' +import { useConfigStore } from "@/stores/config"; const { t } = useI18n() +const {config} = useConfigStore(); const fileBoxStore = useFileBoxStore(); const fileStore = useFileDataStore(); const props = defineProps({ @@ -25,6 +27,8 @@ const props = defineProps({ const handleSubmitShareText = ()=>{ if (shareText.value === '') { ElMessage.warning(t('send.prompt3')); + } else if(config.openUpload === 0 && localStorage.getItem('adminPassword') === null){ + ElMessage.error(t('msg.uploadClose')); } else { const formData = new FormData(); formData.append('text', shareText.value); diff --git a/fcb-fronted/src/locals/zh.ts b/fcb-fronted/src/locals/zh.ts index e25c3018e..dfb66f4c2 100644 --- a/fcb-fronted/src/locals/zh.ts +++ b/fcb-fronted/src/locals/zh.ts @@ -118,5 +118,6 @@ export default { fileOverSize: '文件过大', fileUploadFail: '上传失败', fileUploadSuccess: '上传成功', + uploadClose: '本站已关闭游客上传', } }; \ No newline at end of file diff --git a/main.py b/main.py index 7a3742a3c..1455140f5 100644 --- a/main.py +++ b/main.py @@ -77,6 +77,7 @@ async def get_config(): 'explain': settings.page_explain, 'uploadSize': settings.uploadSize, 'expireStyle': settings.expireStyle, + 'openUpload': settings.openUpload, })