mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Merge branch 'preview-fixes' into preview-features
This commit is contained in:
commit
a10555f76f
@ -1,5 +1,6 @@
|
||||
import { defineComponentMetadata } from '@/components/define'
|
||||
import { getUID } from '@/core/utils'
|
||||
import { liveUrls } from '@/core/utils/urls'
|
||||
|
||||
export const component = defineComponentMetadata({
|
||||
name: 'badgeKeepalive',
|
||||
@ -16,5 +17,5 @@ export const component = defineComponentMetadata({
|
||||
component: () => import('./BadgeKeepalive.vue').then(m => m.default),
|
||||
condition: () => Boolean(getUID()),
|
||||
},
|
||||
urlInclude: ['//live.bilibili.com'],
|
||||
urlInclude: liveUrls,
|
||||
})
|
||||
|
||||
@ -3,7 +3,11 @@ import { getCsrf, getUID } from '@/core/utils'
|
||||
|
||||
// 获取当前直播间号
|
||||
export function getLiveRoomId(): string {
|
||||
const matched = location.href.match(/live.bilibili.com\/(\d+)/)
|
||||
let matched = location.href.match(/live.bilibili.com\/(\d+)/)
|
||||
if (matched) {
|
||||
return matched[1]
|
||||
}
|
||||
matched = location.href.match(/live.bilibili.com\/blanc\/(\d+)/)
|
||||
return matched ? matched[1] : ''
|
||||
}
|
||||
|
||||
|
||||
@ -33,8 +33,8 @@ export const compactRankListCssVars = {
|
||||
export const PGCSeasonTypeMap = {
|
||||
anime: 1,
|
||||
movie: 2,
|
||||
guochuang: 3,
|
||||
documentary: 4,
|
||||
documentary: 3,
|
||||
guochuang: 4,
|
||||
tv: 5,
|
||||
}
|
||||
export const getDefaultRankListCards = (json: any): RankListCard[] => {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { CommentItem } from '@/components/utils/comment-apis'
|
||||
import { CommentReplyItem } from '@/components/utils/comment/reply-item'
|
||||
|
||||
export interface CommentContentReplaceContext {
|
||||
commentItem: CommentItem
|
||||
commentItem: CommentReplyItem
|
||||
content: Node[]
|
||||
}
|
||||
export type CommentContentReplaceHandler = (
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { defineComponentMetadata } from '@/components/define'
|
||||
import { forEachCommentItem } from '@/components/utils/comment-apis'
|
||||
import { select } from '@/core/spin-query'
|
||||
import { CommentReplyItem, forEachCommentItem } from '@/components/utils/comment-apis'
|
||||
import { sq } from '@/core/spin-query'
|
||||
import { getData } from '@/plugins/data'
|
||||
import type { CommentContentReplaceHandler } from './handlers/types'
|
||||
import { commentContentReplaceOptions } from './options'
|
||||
@ -14,21 +14,33 @@ export const component = defineComponentMetadata({
|
||||
forEachCommentItem({
|
||||
added: async commentItem => {
|
||||
const { CommentContentReplaceHandlers } = await import('./handlers')
|
||||
if (commentItem.shadowDomEntry === undefined) {
|
||||
return
|
||||
const replaceContent = async (item: CommentReplyItem) => {
|
||||
if (item.shadowDomEntry === undefined) {
|
||||
return
|
||||
}
|
||||
const content = await sq(
|
||||
() => item.shadowDomEntry.querySelector(':host(bili-rich-text) #contents'),
|
||||
contents => contents.childNodes.length > 0,
|
||||
{ queryInterval: 100 },
|
||||
)
|
||||
if (content === null) {
|
||||
return
|
||||
}
|
||||
const [handlers] = getData(CommentContentReplaceHandlers) as [
|
||||
CommentContentReplaceHandler[],
|
||||
]
|
||||
handlers.forEach(h => h({ commentItem: item, content: Array.from(content.childNodes) }))
|
||||
}
|
||||
const content = await select(
|
||||
() => commentItem.shadowDomEntry.querySelector(':host(bili-rich-text) #contents'),
|
||||
{ queryInterval: 200 },
|
||||
)
|
||||
if (content === null) {
|
||||
return
|
||||
}
|
||||
content.childNodes
|
||||
const [handlers] = getData(CommentContentReplaceHandlers) as [
|
||||
CommentContentReplaceHandler[],
|
||||
]
|
||||
handlers.forEach(h => h({ commentItem, content: Array.from(content.childNodes) }))
|
||||
await replaceContent(commentItem)
|
||||
commentItem.replies.forEach(reply => {
|
||||
replaceContent(reply)
|
||||
})
|
||||
commentItem.addEventListener('repliesUpdate', e => {
|
||||
const replies = (e as CustomEvent).detail as CommentReplyItem[]
|
||||
replies.forEach(reply => {
|
||||
replaceContent(reply)
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
@ -23,8 +23,7 @@ export default Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
downloading: false,
|
||||
midRegex: /mid=(\d+)/,
|
||||
roomIdRegex: /^https:\/\/live\.bilibili\.com\/(\d+)(?:\?.*)?$/,
|
||||
roomIdRegex: /^https:\/\/live\.bilibili\.com\/(?:blanc\/)?(\d+)(?:\?\.*?)?$/,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { defineComponentMetadata } from '@/components/define'
|
||||
import { liveUrls } from '@/core/utils/urls'
|
||||
|
||||
export const component = defineComponentMetadata({
|
||||
name: 'downloadEmoticons',
|
||||
@ -12,5 +13,5 @@ export const component = defineComponentMetadata({
|
||||
widget: {
|
||||
component: () => import('./Widget.vue').then(m => m.default),
|
||||
},
|
||||
urlInclude: [/^https:\/\/live\.bilibili\.com\/(\d+)/],
|
||||
urlInclude: liveUrls,
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user