tangning il y a 4 mois
Parent
commit
19c8cba97f
2 fichiers modifiés avec 9 ajouts et 6 suppressions
  1. 2 2
      src/hook/upload.ts
  2. 7 4
      src/view/originalPhoto/addLibrary.vue

+ 2 - 2
src/hook/upload.ts

@@ -20,7 +20,7 @@ const defaultUpload = (
 
 export const useUpload = <T>(props: UploadProps<T>) => {
   const percentage = ref<number>();
-  const size = computed(() => Math.floor(props.maxSize / 1024 / 1024) + "M");
+  const size = computed(() => Math.floor(props.maxSize / 1024 / 1024) + "MB");
   const format = computed(
     () =>
       `${props.formats.join("、")}${
@@ -56,7 +56,7 @@ export const useUpload = <T>(props: UploadProps<T>) => {
     const fileType = file.name
       .substring(file.name.lastIndexOf("."))
       .toUpperCase();
-    console.log('props.formats', props.formats, format.value);
+    console.log('props.formats', props.maxSize, props.formats, format.value);
     if (!props.formats.some((type) => type.toUpperCase() === fileType)) {
       let newformat = format.value.replaceAll('.', "") as string;
       ElMessage.error(`请上传${newformat}`);

+ 7 - 4
src/view/originalPhoto/addLibrary.vue

@@ -46,7 +46,7 @@
         :before-remove="isAnimation?removeFile5:removeFile"
       >
         <div type="primary" :disabled="!!file">
-          <div>点击或拖拽文件上传 {{ isAnimation?size5:size }}</div>
+          <div>点击或拖拽文件上传 {{ isAnimation?'2GB':'5MB' }}</div>
           <div class="">以内的{{ formatDesc }}</div>
         </div>
         <template v-slot:file="{ file }: { file: UploadFile }">
@@ -107,12 +107,12 @@ const { size, fileList, upload, removeFile, previewFile, file, accept } = useUpl
 });
 
 const { size:size5, fileList:fileLists, upload:upload5, removeFile:removeFile5, previewFile:previewFile5, file:file5, accept:accept5 } = useUpload({
-  maxSize: 5 * 1024 * 1024,
+  maxSize: 2000 * 1024 * 1024,
   formats: [".zip",".glb"],
 });
 const formatDesc = computed(() =>
 {
-  return isAnimation.value?'zip、glp上传':'jpg、png、jpeg、mp4、wav、mp3、shp上传'
+  return isAnimation.value?'zip、glb上传':'jpg、png、jpeg、mp4、wav、mp3、shp上传'
 }
 );
 
@@ -135,11 +135,14 @@ watchEffect(() => {
   if (file.value?.name) {
     caseFile.value.filesTitle = file.value?.name.substring(0, 50);
   }
+  if (file5.value?.name) {
+    caseFile.value.filesTitle = file5.value?.name.substring(0, 50);
+  }
 });
 
 defineExpose<QuiskExpose>({
   async submit() {
-    if (!file.value) {
+    if ((!file.value && !isAnimation.value) || (!file5.value && isAnimation.value)) {
       ElMessage.error("请上传附件");
       throw "请上传附件";
     } else if (!caseFile.value.filesTitle.trim()) {