Skip to content

Commit f9cd9c9

Browse files
committed
feat:前端判断是否开启游客上传
1 parent 11696d1 commit f9cd9c9

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

fcb-fronted/src/components/UploadFile.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ const handleOnChangeFileList = (file: any) => {
4141
const handleHttpRequest = (options: any) => {
4242
fileBoxStore.showFileBox = true;
4343
const formData = new FormData();
44+
if (config.openUpload === 0 || localStorage.getItem('adminPassword') === null) {
45+
fileStore.shareData.forEach((file: any) => {
46+
if (file.uid === options.file.uid) {
47+
ElMessage.error(t('msg.uploadClose'));
48+
file.status = 'fail';
49+
file.code = t('msg.fileUploadFail');
50+
fileStore.save();
51+
}
52+
});
53+
return;
54+
}
4455
if (options.file.size > config.uploadSize) {
4556
fileStore.shareData.forEach((file: any) => {
4657
if (file.uid === options.file.uid) {

fcb-fronted/src/components/UploadText.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import { useFileBoxStore } from "@/stores/fileBox";
77
import { ElMessage } from "element-plus";
88
99
import { useI18n } from 'vue-i18n'
10+
import { useConfigStore } from "@/stores/config";
1011
1112
const { t } = useI18n()
13+
const {config} = useConfigStore();
1214
const fileBoxStore = useFileBoxStore();
1315
const fileStore = useFileDataStore();
1416
const props = defineProps({
@@ -25,6 +27,8 @@ const props = defineProps({
2527
const handleSubmitShareText = ()=>{
2628
if (shareText.value === '') {
2729
ElMessage.warning(t('send.prompt3'));
30+
} else if(config.openUpload === 0 && localStorage.getItem('adminPassword') === null){
31+
ElMessage.error(t('msg.uploadClose'));
2832
} else {
2933
const formData = new FormData();
3034
formData.append('text', shareText.value);

fcb-fronted/src/locals/zh.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,6 @@ export default {
118118
fileOverSize: '文件过大',
119119
fileUploadFail: '上传失败',
120120
fileUploadSuccess: '上传成功',
121+
uploadClose: '本站已关闭游客上传',
121122
}
122123
};

main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ async def get_config():
7777
'explain': settings.page_explain,
7878
'uploadSize': settings.uploadSize,
7979
'expireStyle': settings.expireStyle,
80+
'openUpload': settings.openUpload,
8081
})
8182

8283

0 commit comments

Comments
 (0)