Просмотр исходного кода

fix(choiceQuestionDetailDialog): 修复批量下载图片后缀固定为jpg的问题

根据图片真实url提取文件后缀,不再强制使用jpg格式
lsc 2 дней назад
Родитель
Сommit
6d219c0dae
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      src/views/Student/components/choiceQuestionDetailDialog.vue

+ 3 - 2
src/views/Student/components/choiceQuestionDetailDialog.vue

@@ -2708,9 +2708,10 @@ const downloadAll = async () => {
       // 遍历学生的所有照片
       for (let i = 0; i < student.content.fileList.length; i++) {
         const file = student.content.fileList[i]
+        const ext = (file.url.split('?')[0].split('.').pop() || 'jpg').toLowerCase()
         const fileName = student.content.fileList.length > 1
-          ? `${student.name}${String(i + 1).padStart(2, '0')}.jpg`
-          : `${student.name}.jpg`
+          ? `${student.name}${String(i + 1).padStart(2, '0')}.${ext}`
+          : `${student.name}.${ext}`
 
         try {
           // 获取图片数据