瀏覽代碼

feat(eds): 优化媒体图库缩略图、悬浮提示和分页样式

- 图片缩略图统一为 150px 高度、object-fit: cover,修复高度参差
- 悬浮提示中的存储 URL 强制换行,避免横向撑破气泡
- 分页改用 AnalysisPagination 并对齐案件数据表格的 26px 紧凑样式
- 非图片文件长名称截断,后缀单独以标签展示,无后缀时明确提示
cc 3 周之前
父節點
當前提交
753459268e
共有 1 個文件被更改,包括 114 次插入 和 19 次删除
  1. 114 19
      ai-electron/frontend/src/eds/components/EdsMediaGallery.vue

+ 114 - 19
ai-electron/frontend/src/eds/components/EdsMediaGallery.vue

@@ -12,11 +12,11 @@
         <Tooltip v-for="(item, index) in list" :key="`${item.mediaSmallPath}-${index}`" placement="right">
           <template #title>
             <div class="eds-media-gallery__tip">
-              <p><span>文件名称: </span>{{ item.mediaName || '未知' }}</p>
-              <p><span>文件大小: </span>{{ formatEdsBytes(item.mediaSize) }}</p>
-              <p><span>创建时间: </span>{{ item.createTime || '未知' }}</p>
-              <p><span>删除状态: </span>{{ String(item.deleteStatus ?? '0') === '1' ? '已删除' : '未删除' }}</p>
-              <p><span>存储位置: </span>{{ item.mediaPath || '未知' }}</p>
+              <p><span>文件名称: </span><span class="eds-media-gallery__value">{{ item.mediaName || '未知' }}</span></p>
+              <p><span>文件大小: </span><span class="eds-media-gallery__value">{{ formatEdsBytes(item.mediaSize) }}</span></p>
+              <p><span>创建时间: </span><span class="eds-media-gallery__value">{{ item.createTime || '未知' }}</span></p>
+              <p><span>删除状态: </span><span class="eds-media-gallery__value">{{ String(item.deleteStatus ?? '0') === '1' ? '已删除' : '未删除' }}</span></p>
+              <p><span>存储位置: </span><span class="eds-media-gallery__value">{{ item.mediaPath || '未知' }}</span></p>
             </div>
           </template>
 
@@ -34,7 +34,17 @@
             <template v-else>
               <div class="eds-media-gallery__file">
                 <component :is="fileIcon" class="eds-media-gallery__file-icon" />
-                <div class="eds-media-gallery__name">{{ item.mediaName || '未知' }}</div>
+                <div class="eds-media-gallery__file-info">
+                  <span class="eds-media-gallery__file-base" :title="item.mediaName || '未知'">
+                    {{ fileBaseName(item) }}
+                  </span>
+                  <span
+                    class="eds-media-gallery__file-ext"
+                    :class="{ 'eds-media-gallery__file-ext--empty': !fileExtension(item) }"
+                  >
+                    {{ fileExtension(item) ? `.${fileExtension(item)}` : '无后缀' }}
+                  </span>
+                </div>
               </div>
             </template>
 
@@ -54,13 +64,11 @@
     </div>
 
     <div class="eds-media-gallery__footer">
-      <span class="eds-media-gallery__total">共 {{ total }} 条</span>
-      <Pagination
+      <AnalysisPagination
+        :total="total"
         :current="pageIndex"
         :page-size="pageSize"
-        :total="total"
         :page-size-options="['20', '50', '100', '200']"
-        show-size-changer
         @change="handlePageChange"
       />
     </div>
@@ -79,10 +87,11 @@
 
 <script setup lang="ts">
   import { computed, onMounted, ref } from 'vue';
-  import { Button, Image, Pagination, Select, Tooltip } from 'ant-design-vue';
+  import { Button, Image, Select, Tooltip } from 'ant-design-vue';
   import { AudioOutlined, FileOutlined, VideoCameraOutlined } from '@ant-design/icons-vue';
   import { BasicModal } from '@/core/components/Modal';
   import { EmptyState } from '@/core/components/EmptyState';
+  import AnalysisPagination from '@/core/components/AnalysisPagination/src/AnalysisPagination.vue';
   import EdsMediaPreview from './EdsMediaPreview.vue';
   import type { EdsMediaFile } from '../api/edsDto';
   import { downloadEdsRemoteFile, formatEdsBytes } from '../utils/edsFormatters';
@@ -120,6 +129,30 @@
     return FileOutlined;
   });
 
+  /** 拆分文件名与扩展名:只把最后一个点后的 ASCII 后缀当作扩展名 */
+  const parseMediaName = (name?: string) => {
+    const value = String(name ?? '');
+    const dot = value.lastIndexOf('.');
+    if (dot > 0 && dot < value.length - 1) {
+      const ext = value.slice(dot + 1);
+      if (/^[A-Za-z0-9]{1,10}$/.test(ext)) {
+        return { base: value.slice(0, dot), ext: ext.toLowerCase() };
+      }
+    }
+    return { base: value, ext: '' };
+  };
+
+  const fileBaseName = (item: EdsMediaFile) => parseMediaName(item.mediaName).base || '未知';
+
+  /** 优先用后端 suffixName,缺失时从文件名解析,保证长文件名截断后后缀仍可见 */
+  const fileExtension = (item: EdsMediaFile) => {
+    const suffix = String(item.suffixName ?? '').trim();
+    if (/^[A-Za-z0-9]{1,10}$/.test(suffix)) {
+      return suffix.toLowerCase();
+    }
+    return parseMediaName(item.mediaName).ext;
+  };
+
   const fetchData = async () => {
     const res = await props.fetchApi({
       suffixName: suffixName.value,
@@ -217,10 +250,14 @@
       background: #fafafa;
     }
 
-    &__picture {
+    // Ant Image 把 class 透传到内部 <img>,没有父组件的 scoped 属性,必须用 :deep 命中
+    :deep(.eds-media-gallery__picture) {
       display: block;
-      max-height: 150px;
-      object-fit: contain;
+      width: 100%;
+      height: 150px;
+      object-fit: cover;
+      border-radius: 6px;
+      background: #eef2f7;
     }
 
     &__file {
@@ -230,6 +267,8 @@
       align-items: center;
       justify-content: center;
       gap: 10px;
+      width: 100%;
+      min-width: 0;
     }
 
     &__file-icon {
@@ -237,6 +276,40 @@
       color: #2a50ec;
     }
 
+    &__file-info {
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      gap: 4px;
+      width: 100%;
+      min-width: 0;
+    }
+
+    &__file-base {
+      min-width: 0;
+      overflow: hidden;
+      text-overflow: ellipsis;
+      white-space: nowrap;
+      font-size: 13px;
+      color: #374151;
+    }
+
+    &__file-ext {
+      flex: 0 0 auto;
+      padding: 0 4px;
+      border-radius: 4px;
+      background: #eef2ff;
+      color: #2a50ec;
+      font-size: 11px;
+      line-height: 18px;
+      white-space: nowrap;
+    }
+
+    &__file-ext--empty {
+      background: #f1f5f9;
+      color: #94a3b8;
+    }
+
     &__name {
       margin-top: 8px;
       overflow: hidden;
@@ -267,18 +340,40 @@
       }
     }
 
+    // 存储位置是完整 URL,没有空格;不强制换行会横向撑破气泡
+    &__value {
+      min-width: 0;
+      overflow-wrap: anywhere;
+      word-break: break-word;
+    }
+
     &__footer {
       display: flex;
       align-items: center;
       justify-content: flex-end;
-      gap: 12px;
       padding: 12px 20px;
       border-top: 1px solid #e2e8f0;
-    }
 
-    &__total {
-      font-size: 12px;
-      color: #6b7280;
+      // 与案件数据表格的分页保持同一套紧凑尺寸与选中色
+      :deep(.ant-pagination-item),
+      :deep(.ant-pagination-prev),
+      :deep(.ant-pagination-next) {
+        min-width: 26px;
+        height: 26px;
+        border-radius: 6px;
+        border-color: #e7ebf3;
+        line-height: 24px;
+      }
+
+      :deep(.ant-pagination-item-active) {
+        border-color: #2a50ec;
+        background: #eef2ff;
+      }
+
+      :deep(.ant-pagination-item-active a) {
+        color: #2a50ec;
+        font-weight: 600;
+      }
     }
   }
 </style>