feat: 将首页那些改为支持播放视频的和图片
This commit is contained in:
@@ -5,7 +5,27 @@
|
||||
<view v-for="(item, index) in normalizedList" :key="getItemKey(item, index)" class="explore-card"
|
||||
:class="`is-${item.tone}`" hover-class="is-pressed" hover-stay-time="80"
|
||||
@tap="handleCardTap(item.raw, index)">
|
||||
<image v-if="item.coverImage" class="explore-card-image" :src="item.coverImage" mode="aspectFill" />
|
||||
<video
|
||||
v-if="item.coverImage && isMp4Video(item.coverImage)"
|
||||
class="explore-card-image"
|
||||
:src="item.coverImage"
|
||||
autoplay
|
||||
loop
|
||||
muted
|
||||
:controls="false"
|
||||
:show-center-play-btn="false"
|
||||
:show-play-btn="false"
|
||||
:show-fullscreen-btn="false"
|
||||
:show-mute-btn="false"
|
||||
:enable-progress-gesture="false"
|
||||
object-fit="cover"
|
||||
/>
|
||||
<image
|
||||
v-else-if="item.coverImage"
|
||||
class="explore-card-image"
|
||||
:src="item.coverImage"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
|
||||
<view class="explore-card-gradient" />
|
||||
|
||||
@@ -55,6 +75,12 @@ const normalizedList = computed(() =>
|
||||
|
||||
const getItemKey = (item, index) => item.id ?? item.title ?? index;
|
||||
|
||||
const isMp4Video = (url) => {
|
||||
if (typeof url !== "string") return false;
|
||||
const resourcePath = url.trim().split(/[?#]/)[0];
|
||||
return resourcePath.toLowerCase().endsWith(".mp4");
|
||||
};
|
||||
|
||||
const handleCardTap = (item, index) => {
|
||||
emit("didSelectItem", item, index);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user