Skip to content

Commit c6fe556

Browse files
committed
feat: 上传前判断大小、新文件插入第一位
1 parent 4dfb752 commit c6fe556

File tree

15 files changed

+193
-18
lines changed

15 files changed

+193
-18
lines changed

core/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
'file_storage': 'local',
1414
'name': '文件快递柜-FileCodeBox',
1515
'description': '开箱即用的文件快传系统',
16+
'page_explain': '根据《中华人民共和国网络安全法》、《中华人民共和国刑法》、《中华人民共和国治安管理处罚法》等相关规定。 传播或存储违法、违规内容,会受到相关处罚,严重者将承担刑事责任。请勿上传非法文件,本站坚决配合相关部门,确保网络内容的安全,和谐,打造绿色网络环境。',
1617
'keywords': 'FileCodeBox, 文件快递柜, 口令传送箱, 匿名口令分享文本, 文件',
1718
'max_save_seconds': 0,
1819
's3_access_key_id': '',
@@ -57,7 +58,7 @@ def __init__(self):
5758
for line in f.readlines():
5859
key, value = line.strip().split('=', maxsplit=1)
5960
# 将字符串转换为原本的类型
60-
if not key.startswith('opendal_') and isinstance(default_value[key], int):
61+
if key and not key.startswith('opendal_') and isinstance(default_value.get(key, ''), int):
6162
value = int(value)
6263
default_value[key] = value
6364

fcb-fronted/src/App.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
<script setup lang="ts">
2+
import { onMounted } from "vue";
3+
import { request } from "@/utils/request";
24
5+
onMounted(() => {
6+
request({
7+
url:'/',
8+
method:'post'
9+
}).then((res:any)=>{
10+
if (res.code === 200) {
11+
localStorage.setItem('config', JSON.stringify(res.detail));
12+
}
13+
})
14+
});
315
</script>
416

517
<template>

fcb-fronted/src/components/UploadFile.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { request } from "@/utils/request";
55
import { useFileDataStore } from "@/stores/fileData";
66
import { useFileBoxStore } from "@/stores/fileBox";
77
import { useI18n } from 'vue-i18n'
8+
import { useConfigStore } from "@/stores/config";
9+
import { ElMessage } from "element-plus";
810
11+
const { config } = useConfigStore();
912
const { t } = useI18n()
1013
const fileBoxStore = useFileBoxStore();
1114
const fileStore = useFileDataStore();
@@ -38,6 +41,17 @@ const handleOnChangeFileList = (file: any) => {
3841
const handleHttpRequest = (options: any) => {
3942
fileBoxStore.showFileBox = true;
4043
const formData = new FormData();
44+
if (options.file.size > config.uploadSize) {
45+
fileStore.shareData.forEach((file: any) => {
46+
if (file.uid === options.file.uid) {
47+
ElMessage.error(t('msg.fileOverSize'));
48+
file.status = 'fail';
49+
file.code = t('msg.fileOverSize');
50+
fileStore.save();
51+
}
52+
});
53+
return;
54+
}
4155
formData.append('file', options.file);
4256
formData.append('expire_value', props.shareData.expireValue);
4357
formData.append('expire_style', props.shareData.expireStyle);
@@ -63,14 +77,16 @@ const handleHttpRequest = (options: any) => {
6377
file.status = 'success';
6478
file.text = data.text;
6579
file.code = data.code;
80+
ElMessage.success(t('msg.fileUploadSuccess'));
6681
fileStore.save();
6782
}
6883
});
6984
}).catch(() => {
7085
fileStore.shareData.forEach((file: any) => {
7186
if (file.uid === options.file.uid) {
7287
file.status = 'fail';
73-
file.code = '上传失败';
88+
file.code = t('msg.fileUploadFail');
89+
ElMessage.error(t('msg.fileUploadFail'));
7490
fileStore.save();
7591
}
7692
});

fcb-fronted/src/locals/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default {
5050
name: 'Website Name',
5151
description: 'Website Description',
5252
keywords: 'Keywords',
53+
explain:'Use Explain',
5354
uploadlimit:'Upload Limit',
5455
errorlimit:'Error Limit',
5556
background: 'Background Image',

fcb-fronted/src/locals/i18n.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createI18n } from 'vue-i18n' //引入vue-i18n组件
22
import messages from './index'
33
const language = (
4-
navigator.language || 'zh'
4+
navigator.language || 'zh_cn'
55
).toLowerCase();
66
const lang = (localStorage.getItem('language') || language).replace(/-/, '_');
77
const i18n = createI18n({

fcb-fronted/src/locals/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import zh_cn from './zh_cn';
12
import zh from './zh';
23
import en from './en';
3-
import zh_tw from './zh-tw'
4+
import zh_tw from './zh_tw'
45

56
export default {
6-
zh,
7+
zh_cn,
78
en,
8-
zh_tw
9+
zh_tw,
10+
zh
911
}

fcb-fronted/src/locals/zh.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default {
3232
copySuccess: '复制成功',
3333
inputNotEmpty: '请输入五位取件码',
3434
sendFileBox: '寄件箱',
35+
ok:'确定',
3536
receiveFileBox: '收件箱',
3637
textDetail: '文本详情',
3738
copy: '复 制',
@@ -50,6 +51,7 @@ export default {
5051
name: '网站名称',
5152
description: '网站描述',
5253
uploadlimit: '上传限制',
54+
explain:'界面说明',
5355
errorlimit: '错误限制',
5456
keywords: '关键词',
5557
background: '背景图片',
@@ -109,5 +111,8 @@ export default {
109111
loginSuccess: '登录成功',
110112
loginError: '登录失败',
111113
}
114+
},
115+
msg:{
116+
fileOverSize: '文件过大',
112117
}
113118
};

fcb-fronted/src/locals/zh_cn.ts

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
export default {
2+
send: {
3+
disclaimers:'免责声明',
4+
prompt1: '将文字、文件拖、粘贴到此处,或 ',
5+
prompt2: '天数<7或限制次数(24h后删除)',
6+
prompt3: '请输入您要寄出的文本,支持MarkDown格式',
7+
share: '分享',
8+
textShare: '文本分享',
9+
clickUpload: '点击上传',
10+
pleaseInputExpireValue: '请输入有效期',
11+
expireStyle: '过期方式',
12+
expireData: {
13+
day: '天数',
14+
hour: '小时',
15+
forever: '永久',
16+
minute: '分钟',
17+
count: '次数'
18+
},
19+
expireValue: {
20+
day: '天',
21+
hour: '时',
22+
minute: '分',
23+
count: '次'
24+
},
25+
fileType: {
26+
file: '文件',
27+
text: '文本'
28+
}
29+
},
30+
fileBox: {
31+
copySuccess: '复制成功',
32+
inputNotEmpty: '请输入五位取件码',
33+
sendFileBox: '寄件箱',
34+
ok:'确定',
35+
receiveFileBox: '收件箱',
36+
textDetail: '文本详情',
37+
copy: '复 制',
38+
close: '关 闭',
39+
delete: '删 除',
40+
download: '点 击 下 载',
41+
detail: '查 看 详 情',
42+
copyLink: '复制链接',
43+
},
44+
admin: {
45+
about: {
46+
source1: '本项目开源于Github:',
47+
source2: 'FileCodeBox'
48+
},
49+
settings: {
50+
name: '网站名称',
51+
description: '网站描述',
52+
uploadlimit: '上传限制',
53+
explain:'界面说明',
54+
errorlimit: '错误限制',
55+
keywords: '关键词',
56+
background: '背景图片',
57+
admin_token: '管理密码',
58+
uploadSize: '文件大小',
59+
uploadSizeNote: '最大文件大小,单位:(Bytes),1mb=1 * 1024 * 1024',
60+
openUpload: {
61+
title: '开启上传',
62+
open: '开启游客上传',
63+
close: '关闭游客上传',
64+
note: '关闭之后需要登录后台方可上传',
65+
},
66+
file_storage: {
67+
title: '存储引擎',
68+
local: '本地存储',
69+
s3: 'S3存储',
70+
note: '更新后需要重启FileCodeBox',
71+
},
72+
mei: '每',
73+
minute: '分钟',
74+
upload: '上传',
75+
files: '个文件',
76+
allow: '允许',
77+
errors: '次错误',
78+
save: '保存',
79+
saveSuccess: '保存成功',
80+
},
81+
fileView: {
82+
code: '取件码',
83+
prefix: '文件前缀',
84+
suffix: '文件后缀',
85+
text: '文本',
86+
used_count: '已使用次数',
87+
expired_count: '可用次数',
88+
size: '文件大小',
89+
expired_at: '过期时间',
90+
file_path: '文件路径',
91+
action: '操作',
92+
delete: '删除',
93+
delete_success: '删除成功',
94+
forever: '永久有效',
95+
unlimited_count: '不限次数',
96+
download: '下载',
97+
download_fail: '文件保存失败,请稍后再试~',
98+
},
99+
menu: {
100+
fileManage: '文件管理',
101+
systemSetting: '系统设置',
102+
about: '关于我们',
103+
color: '颜色模式',
104+
signout: '退出登录',
105+
},
106+
login: {
107+
managePassword: '管理密码',
108+
passwordNotEmpty: '密码不能为空',
109+
login: '登 录',
110+
loginSuccess: '登录成功',
111+
loginError: '登录失败',
112+
}
113+
},
114+
msg:{
115+
fileOverSize: '文件过大',
116+
fileUploadFail: '上传失败',
117+
fileUploadSuccess: '上传成功',
118+
}
119+
};

fcb-fronted/src/locals/zh-tw.ts renamed to fcb-fronted/src/locals/zh_tw.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default {
5050
name: '網站名稱',
5151
description: '網站描述',
5252
uploadlimit: '上傳限制',
53+
explain:'介面說明',
5354
errorlimit: '錯誤限制',
5455
keywords: '關鍵詞',
5556
background: '背景圖片',

fcb-fronted/src/stores/config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineStore } from 'pinia';
2+
import {ref} from "vue";
3+
4+
export const useConfigStore = defineStore('config', () => {
5+
const config:any = ref(JSON.parse(localStorage.getItem('config') || '{}') || {}); // 配置
6+
return { config };
7+
});

0 commit comments

Comments
 (0)