Skip to content

Commit

Permalink
feat:前端判断是否开启游客上传
Browse files Browse the repository at this point in the history
  • Loading branch information
vastsa committed Jun 15, 2024
1 parent 11696d1 commit f9cd9c9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fcb-fronted/src/components/UploadFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions fcb-fronted/src/components/UploadText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions fcb-fronted/src/locals/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,6 @@ export default {
fileOverSize: '文件过大',
fileUploadFail: '上传失败',
fileUploadSuccess: '上传成功',
uploadClose: '本站已关闭游客上传',
}
};
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ async def get_config():
'explain': settings.page_explain,
'uploadSize': settings.uploadSize,
'expireStyle': settings.expireStyle,
'openUpload': settings.openUpload,
})


Expand Down

0 comments on commit f9cd9c9

Please sign in to comment.