feat: add existing file extensions warning and improve file type display in upload settings
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
Typos Check / Spell Check with Typos (push) Waiting to run

This commit is contained in:
CaptainB 2025-04-23 10:47:20 +08:00
parent e58f95832b
commit 131b5b3bbe
4 changed files with 20 additions and 5 deletions

View File

@ -47,7 +47,8 @@ export default {
audio: 'Audio', audio: 'Audio',
video: 'Video', video: 'Video',
other: 'Other', other: 'Other',
addExtensions: 'Add suffix' addExtensions: 'Add suffix',
existingExtensionsTip: 'File suffix already exists',
}, },
status: { status: {
label: 'Status', label: 'Status',

View File

@ -48,6 +48,7 @@ export default {
video: '视频', video: '视频',
other: '其他文件', other: '其他文件',
addExtensions: '添加后缀名', addExtensions: '添加后缀名',
existingExtensionsTip: '文件后缀已存在',
}, },
status: { status: {
label: '状态', label: '状态',

View File

@ -48,6 +48,7 @@ export default {
video: '視頻', video: '視頻',
other: '其他文件', other: '其他文件',
addExtensions: '添加後綴名', addExtensions: '添加後綴名',
existingExtensionsTip: '文件後綴已存在',
}, },
status: { status: {
label: '狀態', label: '狀態',

View File

@ -63,7 +63,7 @@
}} }}
</el-text> </el-text>
</p> </p>
<p>TXTMDDOCXHTMLCSVXLSXXLSPDF</p> <p>{{ documentExtensions.map(s => s.toUpperCase()).join('、') }}</p>
</div> </div>
</div> </div>
<el-checkbox <el-checkbox
@ -93,7 +93,7 @@
}} }}
</el-text> </el-text>
</p> </p>
<p>JPGJPEGPNGGIF</p> <p>{{ imageExtensions.map(s => s.toUpperCase()).join('、') }}</p>
</div> </div>
</div> </div>
<el-checkbox v-model="form_data.image" @change="form_data.image = !form_data.image" /> <el-checkbox v-model="form_data.image" @change="form_data.image = !form_data.image" />
@ -121,7 +121,7 @@
}} }}
</el-text> </el-text>
</p> </p>
<p>MP3WAVOGGACCM4A</p> <p>{{ audioExtensions.map(s => s.toUpperCase()).join('、') }}</p>
</div> </div>
</div> </div>
<el-checkbox v-model="form_data.audio" @change="form_data.audio = !form_data.audio" /> <el-checkbox v-model="form_data.audio" @change="form_data.audio = !form_data.audio" />
@ -199,6 +199,8 @@
import { nextTick, ref } from 'vue' import { nextTick, ref } from 'vue'
import type { InputInstance } from 'element-plus' import type { InputInstance } from 'element-plus'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
import { MsgWarning } from '@/utils/message'
import { t } from '@/locales'
const emit = defineEmits(['refresh']) const emit = defineEmits(['refresh'])
const props = defineProps<{ nodeModel: any }>() const props = defineProps<{ nodeModel: any }>()
@ -210,6 +212,10 @@ const loading = ref(false)
const fieldFormRef = ref() const fieldFormRef = ref()
const InputRef = ref<InputInstance>() const InputRef = ref<InputInstance>()
const documentExtensions = ['txt', 'md', 'docx', 'html', 'csv', 'xlsx', 'xls', 'pdf']
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif']
const audioExtensions = ['mp3', 'wav', 'ogg', 'acc', 'm4a']
const form_data = ref({ const form_data = ref({
maxFiles: 3, maxFiles: 3,
fileLimit: 50, fileLimit: 50,
@ -244,9 +250,15 @@ const showInput = () => {
} }
const handleInputConfirm = () => { const handleInputConfirm = () => {
if (inputValue.value) { if (inputValue.value) {
if (form_data.value.otherExtensions.includes(inputValue.value)) { if (
form_data.value.otherExtensions.includes(inputValue.value) ||
documentExtensions.includes(inputValue.value) ||
imageExtensions.includes(inputValue.value) ||
audioExtensions.includes(inputValue.value)
) {
inputVisible.value = false inputVisible.value = false
inputValue.value = '' inputValue.value = ''
MsgWarning(t('common.fileUpload.existingExtensionsTip'))
return return
} }
form_data.value.otherExtensions.push(inputValue.value) form_data.value.otherExtensions.push(inputValue.value)