diff --git a/src/_locales/cmn-CN.yml b/src/_locales/cmn-CN.yml index 51b8586d..b89e1e4c 100644 --- a/src/_locales/cmn-CN.yml +++ b/src/_locales/cmn-CN.yml @@ -383,8 +383,8 @@ video_card: copy_av_number: 复制 AV 号 view_the_original_cover: 查看封面 - view_this_user_channel: 查看该用户频道 + group_contribution: '{firstAuthor} 等 {num} 人联合创作' video_removed: 视频已移除 home: diff --git a/src/_locales/cmn-TW.yml b/src/_locales/cmn-TW.yml index fde12495..3bdc95a6 100644 --- a/src/_locales/cmn-TW.yml +++ b/src/_locales/cmn-TW.yml @@ -384,8 +384,8 @@ video_card: copy_av_number: 複製 AV 號 view_the_original_cover: 檢視封面 - view_this_user_channel: 檢視該用戶頻道 + group_contribution: '{firstAuthor} 等 {num} 人共同創作' video_removed: 影片已移除 home: diff --git a/src/_locales/en.yml b/src/_locales/en.yml index 0f219187..cc63c47b 100644 --- a/src/_locales/en.yml +++ b/src/_locales/en.yml @@ -386,8 +386,8 @@ video_card: copy_av_number: Copy AV Number view_the_original_cover: View the Original Cover - view_this_user_channel: View This User Channel + group_contribution: '{firstAuthor} and {num} others contributed' video_removed: Video removed home: diff --git a/src/_locales/jyut.yml b/src/_locales/jyut.yml index e1d35e24..bd902cae 100644 --- a/src/_locales/jyut.yml +++ b/src/_locales/jyut.yml @@ -383,8 +383,8 @@ video_card: copy_av_number: 複製 AV 號 view_the_original_cover: 睇吓封面 - view_this_user_channel: 睇下呢位用戶嘅頻道 + group_contribution: '{firstAuthor} 等 {num} 人一齊創作' video_removed: 經已鏟咗條片 home: diff --git a/src/components/VideoCard/VideoCard.vue b/src/components/VideoCard/VideoCard.vue index d338af5b..8f42335c 100644 --- a/src/components/VideoCard/VideoCard.vue +++ b/src/components/VideoCard/VideoCard.vue @@ -6,7 +6,6 @@ import { useToast } from 'vue-toastification' import Button from '~/components/Button.vue' import { useBewlyApp } from '~/composables/useAppProvider' import { accessKey, settings } from '~/logic' -import type { ThreePointV2 } from '~/models/video/appForYou' import type { VideoPreviewResult } from '~/models/video/videoPreview' import api from '~/utils/api' import { getTvSign, TVAppKey } from '~/utils/authProvider' @@ -14,6 +13,10 @@ import { calcCurrentTime, calcTimeSince, numFormatter } from '~/utils/dataFormat import { getCSRF, removeHttpFromUrl } from '~/utils/main' import Tooltip from '../Tooltip.vue' +import type { Video } from './types' +import { getCurrentTime, getCurrentVideoUrl } from './utils' +import VideoCardAuthorAvatar from './VideoCardAuthor/components/VideoCardAuthorAvatar.vue' +import VideoCardAuthorName from './VideoCardAuthor/components/VideoCardAuthorName.vue' import VideoCardContextMenu from './VideoCardContextMenu/VideoCardContextMenu.vue' import VideoCardSkeleton from './VideoCardSkeleton.vue' @@ -34,53 +37,6 @@ interface Props { moreBtn?: boolean } -export interface Video { - id: number - duration?: number - durationStr?: string - title: string - desc?: string - cover: string - author?: string - authorFace?: string - /** After set the `authorUrl`, clicking the author's name or avatar will navigate to this url. It won't be affected by mid */ - authorUrl?: string - mid?: number - view?: number - viewStr?: string - danmaku?: number - danmakuStr?: string - - publishedTimestamp?: number - capsuleText?: string - - bvid?: string - aid?: number - // used for live - roomid?: number - epid?: number - goto?: string - /** After set the `url`, clicking the video will navigate to this url. It won't be affected by aid, bvid or epid */ - url?: string - /** If you want to show preview video, you should set the cid value */ - cid?: number - - followed?: boolean - liveStatus?: number - - tag?: string - rank?: number - type?: 'horizontal' | 'vertical' | 'bangumi' - threePointV2: ThreePointV2[] - - badge?: { - bgColor: string - color: string - iconUrl?: string - text: string - } -} - const toast = useToast() const { mainAppRef, openIframeDrawer } = useBewlyApp() const showVideoOptions = ref(false) @@ -95,12 +51,6 @@ const selectedDislikeOpt = ref<{ dislikeReasonId: number }>() const videoCurrentTime = ref(null) -function getCurrentVideoUrl(video: Video) { - const baseUrl = `https://www.bilibili.com/video/${video.bvid ?? `av${video.aid}`}` - const currentTime = videoCurrentTime.value - return currentTime && currentTime > 5 ? `${baseUrl}/?t=${currentTime}` : baseUrl -} - const videoUrl = computed(() => { if (removed.value || !props.video) return undefined @@ -108,7 +58,7 @@ const videoUrl = computed(() => { if (props.video.url) return props.video.url else if (props.video.bvid || props.video.aid) - return getCurrentVideoUrl(props.video) + return getCurrentVideoUrl(props.video, videoCurrentTime) else if (props.video.epid) return `https://www.bilibili.com/bangumi/play/ep${props.video.epid}` else if (props.video.roomid) @@ -117,18 +67,6 @@ const videoUrl = computed(() => { return '' }) -const authorJumpUrl = computed(() => { - if (!props.video) - return - - if (props.video.authorUrl) - return props.video.authorUrl - else if (props.video.mid) - return `//space.bilibili.com/${props.video.mid}` - else - return '' -}) - const wValue = computed((): string => { if (props.horizontal) return 'xl:280px lg:250px md:200px 200px' @@ -144,14 +82,6 @@ const previewVideoUrl = ref('') const contentVisibility = ref<'auto' | 'visible'>('auto') const videoElement = ref(null) -function getCurrentTime() { - if (videoElement.value) { - const currentTime = videoElement.value.currentTime - return currentTime - } - return null -} - watch(() => isHover.value, (newValue) => { if (!props.video || !newValue) return @@ -218,8 +148,8 @@ function handelMouseLeave() { clearTimeout(mouseLeaveTimeOut.value) } -async function handleClick(event: MouseEvent) { - videoCurrentTime.value = getCurrentTime() +function handleClick(event: MouseEvent) { + videoCurrentTime.value = getCurrentTime(videoElement) if (settings.value.videoCardLinkOpenMode === 'drawer' && videoUrl.value && !event.ctrlKey && !event.metaKey) { event.preventDefault() @@ -468,36 +398,10 @@ provide('getVideoType', () => props.type!) flex="~" > -
- - - - - +

props.type!) }" flex="inline items-center" > - @@ -632,7 +505,6 @@ provide('getVideoType', () => props.type!) :video="{ ...video, url: videoUrl, - authorUrl: authorJumpUrl, }" :context-menu-styles="videoOptionsFloatingStyles" @close="showVideoOptions = false" diff --git a/src/components/VideoCard/VideoCardAuthor/components/VideoCardAuthorAvatar.vue b/src/components/VideoCard/VideoCardAuthor/components/VideoCardAuthorAvatar.vue new file mode 100644 index 00000000..06acf2a1 --- /dev/null +++ b/src/components/VideoCard/VideoCardAuthor/components/VideoCardAuthorAvatar.vue @@ -0,0 +1,83 @@ + + + diff --git a/src/components/VideoCard/VideoCardAuthor/components/VideoCardAuthorName.vue b/src/components/VideoCard/VideoCardAuthor/components/VideoCardAuthorName.vue new file mode 100644 index 00000000..3ed1de76 --- /dev/null +++ b/src/components/VideoCard/VideoCardAuthor/components/VideoCardAuthorName.vue @@ -0,0 +1,29 @@ + + + diff --git a/src/components/VideoCard/VideoCardContextMenu/VideoCardContextMenu.vue b/src/components/VideoCard/VideoCardContextMenu/VideoCardContextMenu.vue index 01c25808..bfc2db50 100644 --- a/src/components/VideoCard/VideoCardContextMenu/VideoCardContextMenu.vue +++ b/src/components/VideoCard/VideoCardContextMenu/VideoCardContextMenu.vue @@ -6,7 +6,7 @@ import { useBewlyApp } from '~/composables/useAppProvider' import { Type as ThreePointV2Type } from '~/models/video/appForYou' import { openLinkInBackground } from '~/utils/tabs' -import type { Video } from '../VideoCard.vue' +import type { Video } from '../types' import DislikeDialog from './components/DislikeDialog.vue' const props = defineProps<{ @@ -65,7 +65,6 @@ const commonOptions = computed((): { command: VideoOption, name: string, icon: s [ { command: VideoOption.ViewTheOriginalCover, name: t('video_card.operation.view_the_original_cover'), icon: 'i-solar:gallery-minimalistic-bold-duotone' }, - // { command: VideoOption.ViewThisUserChannel, name: t('video_card.operation.view_this_user_channel'), icon: 'i-solar:user-bold-duotone' }, ], ] if (getVideoType() === 'bangumi' || getVideoType() === 'live') { @@ -131,10 +130,6 @@ function handleCommonCommand(command: VideoOption) { window.open(props.video.cover, '_blank') handleClose() break - case VideoOption.ViewThisUserChannel: - window.open(`https://space.bilibili.com/${props.video.mid}`, '_blank') - handleClose() - break } } diff --git a/src/components/VideoCard/VideoCardContextMenu/components/DislikeDialog.vue b/src/components/VideoCard/VideoCardContextMenu/components/DislikeDialog.vue index c10eeb54..ad0cdb51 100644 --- a/src/components/VideoCard/VideoCardContextMenu/components/DislikeDialog.vue +++ b/src/components/VideoCard/VideoCardContextMenu/components/DislikeDialog.vue @@ -4,7 +4,7 @@ import { onKeyStroke } from '@vueuse/core' import { useI18n } from 'vue-i18n' import { useToast } from 'vue-toastification' -import type { Video } from '~/components/VideoCard/VideoCard.vue' +import type { Video } from '~/components/VideoCard/types' import { accessKey } from '~/logic' import { Type as ThreePointV2Type } from '~/models/video/appForYou' import api from '~/utils/api' diff --git a/src/components/VideoCard/VideoCardSkeleton.vue b/src/components/VideoCard/VideoCardSkeleton.vue index 7f93cbe6..e367f940 100644 --- a/src/components/VideoCard/VideoCardSkeleton.vue +++ b/src/components/VideoCard/VideoCardSkeleton.vue @@ -20,7 +20,7 @@ const wValue = computed((): string => {
@@ -69,7 +69,7 @@ const wValue = computed((): string => {
diff --git a/src/components/VideoCard/types.ts b/src/components/VideoCard/types.ts new file mode 100644 index 00000000..7356f3e7 --- /dev/null +++ b/src/components/VideoCard/types.ts @@ -0,0 +1,56 @@ +import type { ThreePointV2 } from '~/models/video/appForYou' + +export interface Video { + id: number + duration?: number + durationStr?: string + title: string + desc?: string + cover: string + + /** `author` for individual submissions by UP; `authorList` for collaborative submissions by UP */ + author?: Author | Author[] + + view?: number + viewStr?: string + danmaku?: number + danmakuStr?: string + + publishedTimestamp?: number + capsuleText?: string + + bvid?: string + aid?: number + // used for live + roomid?: number + epid?: number + goto?: string + /** After set the `url`, clicking the video will navigate to this url. It won't be affected by aid, bvid or epid */ + url?: string + /** If you want to show preview video, you should set the cid value */ + cid?: number + + followed?: boolean + liveStatus?: number + + tag?: string + rank?: number + type?: 'horizontal' | 'vertical' | 'bangumi' + threePointV2: ThreePointV2[] + + badge?: { + bgColor: string + color: string + iconUrl?: string + text: string + } +} + +export interface Author { + name?: string + /** After set the `authorUrl`, clicking the author's name or avatar will navigate to this url. It won't be affected by mid */ + authorUrl?: string + authorFace: string + followed?: boolean | undefined + mid?: number +} diff --git a/src/components/VideoCard/utils.ts b/src/components/VideoCard/utils.ts new file mode 100644 index 00000000..47933fb1 --- /dev/null +++ b/src/components/VideoCard/utils.ts @@ -0,0 +1,21 @@ +import type { Author, Video } from './types' + +export function getAuthorJumpUrl(author?: Author) { + if (!author) + return '' + + return author.authorUrl || (author.mid ? `//space.bilibili.com/${author.mid}` : '') +} + +export function getCurrentTime(videoElement: Ref) { + if (videoElement.value) { + return videoElement.value.currentTime + } + return null +} + +export function getCurrentVideoUrl(video: Video, videoCurrentTime: Ref) { + const baseUrl = `https://www.bilibili.com/video/${video.bvid ?? `av${video.aid}`}` + const currentTime = videoCurrentTime.value + return currentTime && currentTime > 5 ? `${baseUrl}/?t=${currentTime}` : baseUrl +} diff --git a/src/contentScripts/views/Favorites/Favorites.vue b/src/contentScripts/views/Favorites/Favorites.vue index 53346915..bc0457bd 100644 --- a/src/contentScripts/views/Favorites/Favorites.vue +++ b/src/contentScripts/views/Favorites/Favorites.vue @@ -223,9 +223,11 @@ function isMusic(item: FavoriteResource) { duration: item.duration, title: item.title, cover: item.cover, - author: item.upper.name, - authorFace: item.upper.face, - mid: item.upper.mid, + author: { + name: item.upper.name, + authorFace: item.upper.face, + mid: item.upper.mid, + }, view: item.cnt_info.play, danmaku: item.cnt_info.danmaku, publishedTimestamp: item.pubtime, diff --git a/src/contentScripts/views/Home/components/Following.vue b/src/contentScripts/views/Home/components/Following.vue index cd55a95c..579f0f8e 100644 --- a/src/contentScripts/views/Home/components/Following.vue +++ b/src/contentScripts/views/Home/components/Following.vue @@ -1,6 +1,7 @@