hookehuyr

fix: 修复音频上传格式校验逻辑并移除未使用的Divider组件

重构 beforeReadGuard 函数,为视频和音频类型分别添加格式校验逻辑。视频类型保持原有的 MOV 格式拦截,音频类型新增对 .mp3, .m4a, .aac, .wav 格式的支持,并拦截不支持的格式(如 .wma)。同时更新了 accept 类型和上传提示文案以保持一致性。

移除 components.d.ts 中未使用的 VanDivider 类型声明。
......@@ -69,7 +69,6 @@ declare module 'vue' {
VanConfigProvider: typeof import('vant/es')['ConfigProvider']
VanDatePicker: typeof import('vant/es')['DatePicker']
VanDialog: typeof import('vant/es')['Dialog']
VanDivider: typeof import('vant/es')['Divider']
VanDropdownItem: typeof import('vant/es')['DropdownItem']
VanDropdownMenu: typeof import('vant/es')['DropdownMenu']
VanEmpty: typeof import('vant/es')['Empty']
......
<!--
* @Date: 2025-09-30 17:05
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2026-01-24 15:23:44
* @LastEditTime: 2026-01-24 15:32:45
* @FilePath: /mlaj/src/views/checkin/CheckinDetailPage.vue
* @Description: 用户打卡详情页
-->
......@@ -225,22 +225,48 @@ const {
} = useCheckin()
const beforeReadGuard = (file) => {
if (activeType.value !== 'video') return beforeRead(file)
const files = Array.isArray(file) ? file : [file]
const hasMov = files.some(item => {
const fileName = String(item?.name || '').toLowerCase()
const fileType = String(item?.type || '').toLowerCase()
return fileName.endsWith('.mov') || fileType.includes('quicktime')
})
if (activeType.value === 'video') {
const hasMov = files.some(item => {
const fileName = String(item?.name || '').toLowerCase()
const fileType = String(item?.type || '').toLowerCase()
return fileName.endsWith('.mov') || fileType.includes('quicktime')
})
if (hasMov) {
showDialog({
title: '不支持 MOV 格式',
message: 'MOV(QuickTime)在非苹果系统/部分播放器兼容性较差,可能出现无法打开、黑屏、无声等问题。\n\n请将视频导出/转换为 MP4(更通用)后再上传。',
confirmButtonText: '我知道了',
})
return false
}
return beforeRead(file)
}
if (hasMov) {
showDialog({
title: '不支持 MOV 格式',
message: 'MOV(QuickTime)在非苹果系统/部分播放器兼容性较差,可能出现无法打开、黑屏、无声等问题。\n\n请将视频导出/转换为 MP4(更通用)后再上传。',
confirmButtonText: '我知道了',
if (activeType.value === 'audio') {
const supportedExt = ['mp3', 'm4a', 'aac', 'wav']
const unsupportedFiles = files.filter(item => {
const fileName = String(item?.name || '').toLowerCase()
const ext = fileName.includes('.') ? fileName.split('.').pop() : ''
if (supportedExt.includes(ext)) return false
const fileType = String(item?.type || '').toLowerCase()
if (!fileType) return true
if (!fileType.startsWith('audio/')) return true
return true
})
return false
if (unsupportedFiles.length > 0) {
showDialog({
title: '不支持的音频格式',
message: '当前音频播放基于系统浏览器能力,不同机型/系统对音频格式支持差异较大(例如 .wma 等常见无法播放)。\n\n为避免上传后无法播放,请使用 .mp3 或 .m4a(推荐)重新导出/转换后再上传。',
confirmButtonText: '我知道了',
})
return false
}
return beforeRead(file)
}
return beforeRead(file)
......@@ -708,7 +734,7 @@ const getAcceptType = () => {
const acceptMap = {
'image': 'image/*',
'video': '.mp4,video/mp4',
'audio': '.mp3,.wav,.aac,.flac,.ogg,.wma,.m4a'
'audio': '.mp3,.m4a,.aac,.wav'
}
return acceptMap[activeType.value] || '*'
}
......@@ -721,7 +747,7 @@ const getUploadTips = () => {
const tipsMap = {
'image': '支持格式:.jpg/.jpeg/.png',
'video': '支持格式:.mp4(不支持 .mov)',
'audio': '支持格式:.mp3/.wav/.aac/.flac/.ogg/.wma/.m4a'
'audio': '支持格式:.mp3/.m4a/.aac/.wav(不支持 .wma)'
}
return tipsMap[activeType.value] || ''
}
......