From ebe4b353a00e786f6b1c3417f49263de101d4a38 Mon Sep 17 00:00:00 2001 From: wisokey <57711857+wisokey@users.noreply.github.com> Date: Fri, 18 Oct 2024 00:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=A7=86=E9=A2=91=E6=8A=95?= =?UTF-8?q?=E7=A8=BF=E6=97=B6=E9=97=B4=E9=80=82=E9=85=8D=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=8E=A8=E8=8D=90=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../video/player/show-upload-time/index.ts | 24 +++++++++++++------ .../show-upload-time/show-upload-time.scss | 12 ++++++++-- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/registry/lib/components/video/player/show-upload-time/index.ts b/registry/lib/components/video/player/show-upload-time/index.ts index 6c1fa4d4bf..56c29c723f 100644 --- a/registry/lib/components/video/player/show-upload-time/index.ts +++ b/registry/lib/components/video/player/show-upload-time/index.ts @@ -1,3 +1,4 @@ +import Vue from 'vue' import { defineComponentMetadata } from '@/components/define' import { urlChange } from '@/core/observer' import { playerReady, getVue2Data } from '@/core/utils' @@ -118,6 +119,8 @@ export const component = defineComponentMetadata({ formatString = options.formatString?.toString() } relist.forEach(async video => { + // 使用临时变量保存视频名称,以避免计算属性导致的问题 + let videoName: string = video.name // 确认存放推荐视频列表的List中的元素是否被更新 if (forceUpdate || !video.item.owner.mark) { video.item.owner.mark = true @@ -134,16 +137,21 @@ export const component = defineComponentMetadata({ if (!video.oldname) { video.oldname = video.name } - video.name = getFormatStr(createTime, formatString, video.oldname) + videoName = getFormatStr(createTime, formatString, video.oldname) + video.name = videoName } // 保存生成后的name - video.item.owner.name = video.name + video.item.owner.name = videoName } }) } const getRecoList = () => { - const reco_list = dq('#reco_list') + let reco_list = dq('#reco_list') + // 2024.10.17 兼容最近的b站前端改动 + if (reco_list == null) { + reco_list = dq('.recommend-list-v1') + } let recoList: RecommendList = getVue2Data(reco_list) if (recoList.isOpen === undefined) { recoList = recoList.$children[0] @@ -156,12 +164,14 @@ export const component = defineComponentMetadata({ return recoList } + const videoClasses = ['video-page-operator-card-small', 'video-page-card-small'] + addComponentListener( `${metadata.name}.formatString`, (value: string) => { const recoList: RecommendList = getRecoList() - const relist: VideoPageCard[] = recoList.$children.filter( - video => video.$el.className.indexOf('special') === -1, + const relist: VideoPageCard[] = recoList.$children.filter(video => + videoClasses.includes(video.$el.className), ) showUploadTime(relist, true, value) }, @@ -180,8 +190,8 @@ export const component = defineComponentMetadata({ 'recListItems', () => { console.debug('recoListItems changed, now url is', document.URL) - const relist = recoList.$children.filter( - video => video.$el.className.indexOf('special') === -1, + const relist = recoList.$children.filter(video => + videoClasses.includes(video.$el.className), ) showUploadTime(relist) }, diff --git a/registry/lib/components/video/player/show-upload-time/show-upload-time.scss b/registry/lib/components/video/player/show-upload-time/show-upload-time.scss index 8a88e217b9..73c6dd06ed 100644 --- a/registry/lib/components/video/player/show-upload-time/show-upload-time.scss +++ b/registry/lib/components/video/player/show-upload-time/show-upload-time.scss @@ -4,11 +4,19 @@ display: flex !important; height: auto !important; } -// 新版css +// 2023.04.30 版本css .video-page-card-small .card-box .info .upname { height: auto !important; a .name { -webkit-line-clamp: unset !important; white-space: pre !important; } -} \ No newline at end of file +} +// 2024.10.17 版本css +.video-page-operator-card-small .card-box .info .upname { + height: auto !important; + a .name { + -webkit-line-clamp: unset !important; + white-space: pre !important; + } +}