Skip to content

Commit 131b5b3

Browse files
committed
feat: add existing file extensions warning and improve file type display in upload settings
1 parent e58f958 commit 131b5b3

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

ui/src/locales/lang/en-US/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ export default {
4747
audio: 'Audio',
4848
video: 'Video',
4949
other: 'Other',
50-
addExtensions: 'Add suffix'
50+
addExtensions: 'Add suffix',
51+
existingExtensionsTip: 'File suffix already exists',
5152
},
5253
status: {
5354
label: 'Status',

ui/src/locales/lang/zh-CN/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default {
4848
video: '视频',
4949
other: '其他文件',
5050
addExtensions: '添加后缀名',
51+
existingExtensionsTip: '文件后缀已存在',
5152
},
5253
status: {
5354
label: '状态',

ui/src/locales/lang/zh-Hant/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default {
4848
video: '視頻',
4949
other: '其他文件',
5050
addExtensions: '添加後綴名',
51+
existingExtensionsTip: '文件後綴已存在',
5152
},
5253
status: {
5354
label: '狀態',

ui/src/workflow/nodes/base-node/component/FileUploadSettingDialog.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
}}
6464
</el-text>
6565
</p>
66-
<p>TXT、MD、DOCX、HTML、CSV、XLSX、XLS、PDF</p>
66+
<p>{{ documentExtensions.map(s => s.toUpperCase()).join('、') }}</p>
6767
</div>
6868
</div>
6969
<el-checkbox
@@ -93,7 +93,7 @@
9393
}}
9494
</el-text>
9595
</p>
96-
<p>JPG、JPEG、PNG、GIF</p>
96+
<p>{{ imageExtensions.map(s => s.toUpperCase()).join('、') }}</p>
9797
</div>
9898
</div>
9999
<el-checkbox v-model="form_data.image" @change="form_data.image = !form_data.image" />
@@ -121,7 +121,7 @@
121121
}}
122122
</el-text>
123123
</p>
124-
<p>MP3、WAV、OGG、ACC、M4A</p>
124+
<p>{{ audioExtensions.map(s => s.toUpperCase()).join('、') }}</p>
125125
</div>
126126
</div>
127127
<el-checkbox v-model="form_data.audio" @change="form_data.audio = !form_data.audio" />
@@ -199,6 +199,8 @@
199199
import { nextTick, ref } from 'vue'
200200
import type { InputInstance } from 'element-plus'
201201
import { cloneDeep } from 'lodash'
202+
import { MsgWarning } from '@/utils/message'
203+
import { t } from '@/locales'
202204
203205
const emit = defineEmits(['refresh'])
204206
const props = defineProps<{ nodeModel: any }>()
@@ -210,6 +212,10 @@ const loading = ref(false)
210212
const fieldFormRef = ref()
211213
const InputRef = ref<InputInstance>()
212214
215+
const documentExtensions = ['txt', 'md', 'docx', 'html', 'csv', 'xlsx', 'xls', 'pdf']
216+
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif']
217+
const audioExtensions = ['mp3', 'wav', 'ogg', 'acc', 'm4a']
218+
213219
const form_data = ref({
214220
maxFiles: 3,
215221
fileLimit: 50,
@@ -244,9 +250,15 @@ const showInput = () => {
244250
}
245251
const handleInputConfirm = () => {
246252
if (inputValue.value) {
247-
if (form_data.value.otherExtensions.includes(inputValue.value)) {
253+
if (
254+
form_data.value.otherExtensions.includes(inputValue.value) ||
255+
documentExtensions.includes(inputValue.value) ||
256+
imageExtensions.includes(inputValue.value) ||
257+
audioExtensions.includes(inputValue.value)
258+
) {
248259
inputVisible.value = false
249260
inputValue.value = ''
261+
MsgWarning(t('common.fileUpload.existingExtensionsTip'))
250262
return
251263
}
252264
form_data.value.otherExtensions.push(inputValue.value)

0 commit comments

Comments
 (0)