Selaa lähdekoodia

feat: 修改脚本照片相关bug

tangning 1 vuosi sitten
vanhempi
commit
edcdd9cdbd
3 muutettua tiedostoa jossa 30 lisäystä ja 7 poistoa
  1. 25 5
      src/app/mirror/App.vue
  2. 1 1
      src/view/case/addPhotoFile.vue
  3. 4 1
      src/view/case/addPhotoFileAll.vue

+ 25 - 5
src/app/mirror/App.vue

@@ -84,9 +84,11 @@
               ref="upload"
               v-model:file-list="row.fileList"
               class="list-upload-style"
+              :accept="DrawFormats.toString()"
               :class="{
                 activefileList: row.fileList && row.fileList.length == 1,
               }"
+            :before-upload="beforeUpload"
               list-type="picture-card"
               :action="uploadFileUrl"
               :on-success="handleUploadSuccess"
@@ -197,7 +199,7 @@ const caseId = ref(null);
 const project = reactive({
   title: "",
 });
-
+const DrawFormats = [".jpg", ".jpeg", ".png",".mp4",".m4v",".mp3",".aac", ".wav"]
 const isNotFound = ref(false);
 
 const dialogImageUrl = ref("");
@@ -253,11 +255,22 @@ const columns = ref([
   { prop: "words", label: "台词文案" },
   { prop: "marks", label: "备注" },
 ]);
+const beforeUpload = async (file: File) => {
+    const fileType = file.name
+      .substring(file.name.lastIndexOf("."))
+      .toUpperCase();
+    if (!DrawFormats.some((type) => type.toUpperCase() === fileType)) {
+      ElMessage.error(`请上传${DrawFormats}`);
+      return false;
+    } else {
+      return true;
+    }
+  };
 const checkSourceIsVideo = computed(() => (url: string) => {
-  return url.includes(".mp4");
+  return url.includes(".mp4") || url.includes(".m4v");
 });
 const checkSourceIsAudio = computed(() => (url: string) => {
-  return url.includes(".mp3");
+  return url.includes(".mp3") || url.includes(".aac") || url.includes(".wav");
 });
 const checkSourceIsImage = computed(() => (url: string) => {
   return url.includes(".jpg") || url.includes(".png") || url.includes(".gif");
@@ -269,7 +282,7 @@ const getCoverUrl = computed(() => (url: string) => {
     //   return (
     //     url + "?x-oss-process=video/snapshot,t_0,f_jpg,w_0,h_0,m_fast,ar_auto"
     //   );
-    case url.includes(".mp3") || url.includes(".wmv"):
+    case url.includes(".mp3") ||  url.includes(".aac") || url.includes(".wmv"):
       return musicHeadphones;
     default:
       return url;
@@ -366,11 +379,18 @@ const handlePictureCardPreview = (file: UploadFile) => {
 
 const saveProject = () => {
   // let content = sortList.value.map((index) => data.list[index]);
+  let apiDataList = data.newSortList.map((item) => {
+    let asData = data.list.find(ele => ele.id === item.id) || {};
+    return {
+      ...item,
+      ...asData,
+    }
+  });
   console.log("saveProject", data.list, data.newSortList);
   CaseScriptSaveOrUpdate({
     caseId: caseId.value,
     name: project.title,
-    content: data.newSortList,
+    content: apiDataList,
   }).then((res) => {
     console.log("saveProject");
     ElMessage.success("保存成功");

+ 1 - 1
src/view/case/addPhotoFile.vue

@@ -30,7 +30,7 @@
               <el-icon><Document /></el-icon>
               <span class="name">{{ file.name }}</span>
             </div>
-            <el-icon @click.stop="removeFile()"><Close /></el-icon>
+            <el-icon v-if="!caseFile.id" @click.stop="removeFile()"><Close /></el-icon>
           </div>
         </template>
       </el-upload>

+ 4 - 1
src/view/case/addPhotoFileAll.vue

@@ -14,6 +14,7 @@
         v-model:file-list="fileList"
         :http-request="httpsApi"
         :on-preview="previewFile"
+        :on-exceed="handleExceed"
         :accept="photoFormats"
         :on-remove="handleRemove"
       >
@@ -88,7 +89,9 @@ const { size, previewFile, file, accept, percentage, format } = useUpload({
   maxSize: maxFileSize,
   formats: DrawFormats,
 });
-
+const handleExceed = () => {
+  return ElMessage.error(`最大上传数量为10个`);
+}
 const upload = async (file: File) => {
     const fileType = file.name
       .substring(file.name.lastIndexOf("."))