118118 <a-card class =" video-info-card" :class =" { 'collapsed-when-playing': showVideoPlayer || showBookReader }" >
119119 <div class =" video-header" >
120120 <div class =" video-poster" @click =" showImageModal" >
121- <img :src =" videoDetail.vod_pic " :alt =" videoDetail.vod_name" @error =" handleImageError" />
121+ <img :src =" finalPosterImage " :alt =" videoDetail.vod_name" @error =" handleImageError" />
122122 <div class =" poster-overlay" >
123123 <icon-eye class =" view-icon" />
124124 <span >查看大图</span >
@@ -318,6 +318,7 @@ const descriptionExpanded = ref(false)
318318const currentRoute = ref (0 )
319319const currentEpisode = ref (0 )
320320const favoriteLoading = ref (false )
321+ const imageErrorCount = ref (0 ) // 图片加载失败计数器
321322// 当前使用的站源信息(可能是全局站源或临时站源)
322323const currentSiteInfo = ref ({
323324 name: ' ' ,
@@ -413,6 +414,20 @@ const viewerOptions = ref({
413414})
414415
415416// 计算属性
417+ // 最终显示的海报图片
418+ const finalPosterImage = computed (() => {
419+ // 优先使用详情页接口返回的图片
420+ if (videoDetail .value ? .vod_pic ) {
421+ return videoDetail .value .vod_pic
422+ }
423+ // 其次使用来源页面传递的图片
424+ if (originalVideoInfo .value ? .sourcePic ) {
425+ return originalVideoInfo .value .sourcePic
426+ }
427+ // 最后使用默认图片
428+ return ' /src/assets/default-poster.svg'
429+ })
430+
416431const playRoutes = computed (() => {
417432 if (! videoDetail .value ? .vod_play_from || ! videoDetail .value ? .vod_play_url ) {
418433 return []
@@ -491,6 +506,9 @@ const loadVideoDetail = async () => {
491506 return
492507 }
493508
509+ // 重置图片错误计数器
510+ imageErrorCount .value = 0
511+
494512 // 从路由参数中获取原始视频信息
495513 originalVideoInfo .value = {
496514 id: route .params .id ,
@@ -503,7 +521,8 @@ const loadVideoDetail = async () => {
503521 remarks: route .query .remarks || ' ' ,
504522 content: route .query .content || ' ' ,
505523 actor: route .query .actor || ' ' ,
506- director: route .query .director || ' '
524+ director: route .query .director || ' ' ,
525+ sourcePic: route .query .sourcePic || ' ' // 来源页面的图片,用于备用
507526 }
508527
509528 // 检查是否有当前站点
@@ -753,20 +772,32 @@ const handleImageError = (event) => {
753772 if (event .target .src .includes (' default-poster.svg' )) {
754773 return
755774 }
756- // 使用BASE_URL确保在任何路由层级和部署环境下都能正确访问
775+
776+ imageErrorCount .value ++
777+
778+ // 第一次失败:如果当前显示的是详情页接口返回的图片,尝试使用来源页面的图片
779+ if (imageErrorCount .value === 1 && originalVideoInfo .value ? .sourcePic &&
780+ videoDetail .value ? .vod_pic && event .target .src === videoDetail .value .vod_pic ) {
781+ event .target .src = originalVideoInfo .value .sourcePic
782+ return
783+ }
784+
785+ // 第二次失败或没有备用图片:使用默认图片
757786 const basePath = import .meta.env.BASE_URL || ' /'
758787 event .target .src = ` ${ basePath} default-poster.svg`
759788 event .target .style .objectFit = ' contain'
760789 event .target .style .backgroundColor = ' #f7f8fa'
761790}
762791
763792const showImageModal = () => {
764- if (videoDetail .value ? .vod_pic ) {
793+ const currentImage = finalPosterImage .value
794+ // 只有当不是默认图片时才显示大图查看
795+ if (currentImage && ! currentImage .includes (' default-poster.svg' )) {
765796 // 设置当前图片到 viewer,包含图片URL和名称
766- viewerImages .value = [videoDetail . value . vod_pic ]
797+ viewerImages .value = [currentImage ]
767798 viewerImageData .value = [{
768- src: videoDetail . value . vod_pic ,
769- name: videoDetail .value .vod_name || ' 未知标题'
799+ src: currentImage ,
800+ name: videoDetail .value ? .vod_name || originalVideoInfo . value ? . name || ' 未知标题'
770801 }]
771802
772803 // 等待下一个 tick 后显示 viewer
0 commit comments