Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…volved into preview-fixes
  • Loading branch information
the1812 committed Oct 22, 2024
2 parents 46c301f + c006153 commit 64279b6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
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;
}
}

0 comments on commit 64279b6

Please sign in to comment.