Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

显示视频投稿时间适配新版推荐列表 #4960

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions registry/lib/components/video/player/show-upload-time/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Vue from 'vue'
import { defineComponentMetadata } from '@/components/define'
import { urlChange } from '@/core/observer'
import { playerReady, getVue2Data } from '@/core/utils'
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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)
},
Expand All @@ -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)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
// 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;
}
}
Loading