fix(shopGoods): 修复编辑弹窗视频裂图问题

- 新增 isVideo() 函数判断视频文件类型
- 编辑弹窗预览区域分支渲染,视频显示 <video> 组件
- 视频预览添加 PlayCircleOutlined 播放图标覆盖层
- 保持图片预览使用原有 <a-image> 组件
- 引入并使用 PlayCircleOutlined 图标组件
This commit is contained in:
2026-07-12 22:34:58 +08:00
parent 239b9fea44
commit 59678f7ddd
2 changed files with 41 additions and 1 deletions

View File

@@ -127,10 +127,31 @@
<!-- @done="chooseImage"-->
<!-- @del="onDeleteItem"-->
<!-- />-->
<!-- 视频预览 -->
<div
v-if="form.image && isVideo(form.image)"
class="relative"
style="width: 100px; height: 100px; margin-right: 10px; border-radius: 6px; overflow: hidden; border: 1px solid #434343; background: #1a1a1a;"
>
<video
:src="form.image"
style="width: 100%; height: 100%; object-fit: cover;"
preload="metadata"
muted
/>
<!-- 播放图标覆盖层 -->
<div
class="absolute inset-0 flex items-center justify-center"
style="background: rgba(0,0,0,0.25);"
>
<PlayCircleOutlined style="font-size: 28px; color: rgba(255,255,255,0.85);" />
</div>
</div>
<!-- 图片预览 -->
<a-image
v-else-if="form.image"
width="100px"
height="100px"
v-if="form.image"
:src="form.image"
style="margin-right: 10px"
/>
@@ -677,6 +698,7 @@ import {
CloseCircleOutlined,
DeleteOutlined,
InfoCircleOutlined,
PlayCircleOutlined,
SettingOutlined,
UploadOutlined
} from '@ant-design/icons-vue';
@@ -1956,6 +1978,14 @@ const getRoleList = async () => {
}
};
// 判断是否为视频文件(支持 mp4/webm/mov/avi 等常见格式)
const isVideo = (url: string): boolean => {
if (!url) return false;
const videoExts = ['.mp4', '.webm', '.mov', '.avi', '.m3u8', '.ogg'];
const lowerUrl = url.toLowerCase().split('?')[0]; // 去掉查询参数
return videoExts.some((ext) => lowerUrl.endsWith(ext));
};
const onUploadImage = (item) => {
const {file} = item;
if (file.size / 1024 / 1024 > 10) {