diff --git a/src/components/ChatInput.vue b/src/components/ChatInput.vue index bcbff32..b32aa2c 100644 --- a/src/components/ChatInput.vue +++ b/src/components/ChatInput.vue @@ -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) { @@ -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) => { diff --git a/src/locale/en-us.js b/src/locale/en-us.js index bed9b19..cc4760d 100644 --- a/src/locale/en-us.js +++ b/src/locale/en-us.js @@ -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; diff --git a/src/locale/zh-cn.js b/src/locale/zh-cn.js index de2eb20..228eb0f 100644 --- a/src/locale/zh-cn.js +++ b/src/locale/zh-cn.js @@ -59,6 +59,7 @@ const mZhCN = { Model: '模型', PleaseChooseModel: '请选择模型', Desc: '描述', + FileSizeTooLarge: '文件超出 {maxSize}MB 大小限制', }; export default mZhCN;