shaogen1995 1 месяц назад
Родитель
Сommit
34a286dbb7
3 измененных файлов с 26 добавлено и 17 удалено
  1. 3 3
      src/pages/A4advanced/A4add/index.tsx
  2. 22 13
      src/pages/B2library/data.ts
  3. 1 1
      src/utils/tableData.ts

+ 3 - 3
src/pages/A4advanced/A4add/index.tsx

@@ -75,7 +75,7 @@ function A4add({ txt, _id, closeFu, addTableFu, editTableFu }: Props) {
 
       // 富文本
       const rtf = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
-      if (rtf.flag && type !== '轮播图') return MessageFu.warning('请输入内容')
+      if (rtf.flag) return MessageFu.warning('请输入内容')
 
       const obj = {
         ...values,
@@ -96,7 +96,7 @@ function A4add({ txt, _id, closeFu, addTableFu, editTableFu }: Props) {
       }
       // console.log("通过校验,点击确定");
     },
-    [type, txt, _id, addTableFu, editTableFu, closeFu]
+    [txt, _id, addTableFu, editTableFu, closeFu]
   )
 
   return (
@@ -183,7 +183,7 @@ function A4add({ txt, _id, closeFu, addTableFu, editTableFu }: Props) {
 
           <div className='formBox'>
             <div className='formBoxll'>
-              <span>{type === '轮播图' ? '' : '* '}</span>内容:
+              <span>* </span>内容:
             </div>
             <div className='formBoxrr'>
               <ZRichTextOne

+ 22 - 13
src/pages/B2library/data.ts

@@ -15,6 +15,9 @@ export const B2typeSelectType = [
  * @param {String} zipName - 生成的ZIP包名称(可选,默认为"download.zip")
  */
 export async function downloadFilesAsZip(fileList: any[], zipName: string, back: () => void) {
+  // 记录下载错误的文件数量
+  let errNum = 0
+
   // 参数校验
   if (!fileList || !Array.isArray(fileList) || fileList.length === 0) {
     MessageFu.warning('至少选择一个文件')
@@ -39,6 +42,7 @@ export async function downloadFilesAsZip(fileList: any[], zipName: string, back:
       // 优先使用对象中指定的文件名
       fileName = fileItem.name || fileUrl.split('/').pop() || `file_${index}`
     } else {
+      errNum++
       MessageFu.warning(`文件项格式错误,已跳过:${fileItem}`)
       return
     }
@@ -47,9 +51,10 @@ export async function downloadFilesAsZip(fileList: any[], zipName: string, back:
     const promise = fetch(fileUrl)
       .then(response => {
         if (!response.ok) {
-          MessageFu.error(`网络响应异常: ${response.status}`)
+          errNum++
+          MessageFu.error(`网络异常或找不到文件: ${fileName}`)
           domShowFu('#AsyncSpinLoding', false)
-          throw new Error(`网络响应异常: ${response.status}`)
+          throw new Error(`网络异常或找不到文件: ${fileName}`)
         }
         return response.blob() // 将响应转换为Blob对象
       })
@@ -58,6 +63,7 @@ export async function downloadFilesAsZip(fileList: any[], zipName: string, back:
         zip.file(fileName, blob)
       })
       .catch(error => {
+        errNum++
         MessageFu.error(`下载文件失败 "${fileName}":${error}`)
         domShowFu('#AsyncSpinLoding', false)
         // 可选:即使某个文件失败,也继续处理其他文件
@@ -71,18 +77,21 @@ export async function downloadFilesAsZip(fileList: any[], zipName: string, back:
     // 等待所有文件下载完成
     await Promise.all(promises)
 
-    // 生成ZIP文件
-    const zipBlob = await zip.generateAsync({
-      type: 'blob',
-      compression: 'DEFLATE', // 使用DEFLATE算法进行压缩
-      compressionOptions: { level: 6 } // 压缩级别,1-9,6是较好的平衡点
-    })
+    if (errNum >= fileList.length) domShowFu('#AsyncSpinLoding', false)
+    else {
+      // 生成ZIP文件
+      const zipBlob = await zip.generateAsync({
+        type: 'blob',
+        compression: 'DEFLATE', // 使用DEFLATE算法进行压缩
+        compressionOptions: { level: 6 } // 压缩级别,1-9,6是较好的平衡点
+      })
 
-    // 使用FileSaver触发下载
-    saveAs(zipBlob, zipName)
-    MessageFu.success('压缩包下载成功')
-    back()
-    domShowFu('#AsyncSpinLoding', false)
+      // 使用FileSaver触发下载
+      saveAs(zipBlob, zipName)
+      MessageFu.success('压缩包下载成功')
+      back()
+      domShowFu('#AsyncSpinLoding', false)
+    }
   } catch (error) {
     MessageFu.error(`生成或下载压缩包过程中出错:${error}`)
     domShowFu('#AsyncSpinLoding', false)

+ 1 - 1
src/utils/tableData.ts

@@ -73,5 +73,5 @@ export const Z2tableC = [
   ['txt', '操作帐号', 'userName'],
   ['txt', '操作日期', 'createTime'],
   ['txt', 'IP记录', 'ip'],
-  ['txt', '操作事件', 'apiDescription']
+  ['text', '操作事件', 'apiDescription', 50]
 ]