Skip to content

Commit

Permalink
Merge pull request #38 from OVINC-CN/feat_cos_size_limit
Browse files Browse the repository at this point in the history
feat(cos): add file size too large notice
  • Loading branch information
OrenZhang authored Dec 12, 2024
2 parents 4665029 + 845a889 commit 5ed7c37
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/components/ChatInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,17 @@ onMounted(() => {
// upload file
const uploadEnabled = ref(false);
onMounted(() => getCOSConfigAPI().then((res) => uploadEnabled.value = res.data.upload_file_enabled));
const uploadMaxSize = ref(0);
onMounted(
() => {
getCOSConfigAPI().then(
(res) => {
uploadEnabled.value = res.data.upload_file_enabled;
uploadMaxSize.value = res.data.upload_max_size;
},
);
},
);
const fileUploadInput = ref(null);
const customUpload = () => {
if (promptForm.value.file) {
Expand All @@ -325,6 +335,13 @@ const handleFileChange = (event) => {
};
const doUploadFile = (file) => {
emits('setChatLoading', true);
if (file.size > uploadMaxSize.value) {
Message.warning(
i18n.t('FileSizeTooLarge', {maxSize: (uploadMaxSize.value / 1024.0 / 1024.0).toFixed(2)}),
);
emits('setChatLoading', false);
return;
}
checkTCaptcha((ret) => {
getCOSUploadTempKeyAPI(file.name, 'file-extract', ret).then(
(res) => {
Expand Down
1 change: 1 addition & 0 deletions src/locale/en-us.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const mEnUS = {
Model: 'Model',
PleaseChooseModel: 'Please choose Model',
Desc: 'Description',
FileSizeTooLarge: 'File size is larger than {maxSize} MB',
};

export default mEnUS;
1 change: 1 addition & 0 deletions src/locale/zh-cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const mZhCN = {
Model: '模型',
PleaseChooseModel: '请选择模型',
Desc: '描述',
FileSizeTooLarge: '文件超出 {maxSize}MB 大小限制',
};

export default mZhCN;

0 comments on commit 5ed7c37

Please sign in to comment.