From 527b45e299a524f5f63659c97f51f45db7b08e35 Mon Sep 17 00:00:00 2001 From: CNOCM <2436432930@qq.com> Date: Mon, 30 Jun 2025 11:31:17 +0800 Subject: [PATCH 01/24] =?UTF-8?q?refactor(subscribeTimeShow):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/subscribe-time-show/index.ts | 190 ++++++++---------- 1 file changed, 89 insertions(+), 101 deletions(-) diff --git a/registry/lib/components/utils/subscribe-time-show/index.ts b/registry/lib/components/utils/subscribe-time-show/index.ts index 2743ec93a..95151cf9b 100644 --- a/registry/lib/components/utils/subscribe-time-show/index.ts +++ b/registry/lib/components/utils/subscribe-time-show/index.ts @@ -1,6 +1,10 @@ import { defineComponentMetadata } from '@/components/define' import { useScopedConsole } from '@/core/utils/log' import { bilibiliApi, getJsonWithCredentials } from '@/core/ajax' +import { dqa, dq } from '@/core/utils' +import { select } from '@/core/spin-query' +import { allMutations } from '@/core/observer' +import { getUserInfo } from '@/core/user-info' const displayName = '关注时间显示' const console = useScopedConsole(displayName) @@ -22,20 +26,16 @@ type FollowTimeInfo = { const midMap: Record = {} const insertFollowTimeToCard = (mid: number, dateStr: string, label: string) => { - const anchor = document.querySelector( - `${SELECTORS.relationCardAnchor}[href*="/${mid}"]`, - ) + const anchor = dq(`${SELECTORS.relationCardAnchor}[href*="/${mid}"]`) const card = anchor?.closest(SELECTORS.relationCardContainer) - if (!card) { - return - } - if (card.querySelector(`.${SELECTORS.relationCardTimeClass}`)) { + if (!card || card.querySelector(`.${SELECTORS.relationCardTimeClass}`)) { return } const div = document.createElement('div') div.className = SELECTORS.relationCardTimeClass div.textContent = `${label}:${dateStr}` + div.dataset.mid = mid.toString() const sign = card.querySelector(SELECTORS.relationCardSign) if (sign?.parentNode) { @@ -43,57 +43,37 @@ const insertFollowTimeToCard = (mid: number, dateStr: string, label: string) => } } -let fetchWrapped = false -let pendingUpdate = false - -const updateCards = () => { - if (pendingUpdate) { - return - } - pendingUpdate = true - requestAnimationFrame(() => { - pendingUpdate = false - const mids = Array.from( - document.querySelectorAll(SELECTORS.relationCardAnchor), - ) - .map(el => el.href.match(/\/(\d+)/)?.[1]) - .filter(Boolean) - .map(Number) - - mids.forEach(mid => { - const data = midMap[mid] - if (data) { - const dateStr = new Date(data.mtime * 1000).toLocaleString() - insertFollowTimeToCard(mid, dateStr, data.label) - } - }) - }) -} - -const waitForProfileContainer = () => - new Promise(resolve => { - const check = () => document.querySelector(SELECTORS.profileFollowContainer) - let container = check() - if (container) { - resolve(container) - } else { - const observer = new MutationObserver(() => { - container = check() - if (container) { - observer.disconnect() - resolve(container) +const updateCards = (() => { + let scheduled = false + return () => { + if (scheduled) { + return + } + scheduled = true + requestAnimationFrame(() => { + scheduled = false + dqa(SELECTORS.relationCardAnchor).forEach(el => { + const match = (el as HTMLAnchorElement).href.match(/\/(\d+)/) + if (!match) { + return + } + const mid = Number(match[1]) + if (Number.isNaN(mid)) { + return + } + const data = midMap[mid] + if (data) { + const dateStr = new Date(data.mtime * 1000).toLocaleString() + insertFollowTimeToCard(mid, dateStr, data.label) } }) - observer.observe(document.body, { childList: true, subtree: true }) - } - }) + }) + } +})() const insertSubscribeTime = (followTimeStr: string) => { - const container = document.querySelector(SELECTORS.profileFollowContainer) - if (!container) { - return - } - if (container.querySelector(`.${SELECTORS.profileTextClass}`)) { + const container = dq(SELECTORS.profileFollowContainer) + if (!container || container.querySelector(`.${SELECTORS.profileTextClass}`)) { return } @@ -107,25 +87,22 @@ const insertSubscribeTime = (followTimeStr: string) => { container.appendChild(infoEl) } -const entry = async () => { - try { - const { addImportantStyle } = await import('@/core/style') - const { default: style } = await import('./subscribe-time.scss') - addImportantStyle(style, 'subscribe-time-style') - } catch (e) { - console.error('样式加载失败:', e) - } +if (!(unsafeWindow as any).subscribeTimeHooked) { + ;(unsafeWindow as any).subscribeTimeHooked = true + const originalFetch = unsafeWindow.fetch + unsafeWindow.fetch = new Proxy(originalFetch, { + apply(target, thisArg, args) { + const url = typeof args[0] === 'string' ? args[0] : args[0].url + const urlObj = new URL(url, location.origin) - new MutationObserver(updateCards).observe(document.body, { childList: true, subtree: true }) - - if (!fetchWrapped) { - fetchWrapped = true - const originalFetch = unsafeWindow.fetch - unsafeWindow.fetch = new Proxy(originalFetch, { - apply(target, thisArg, args) { - const url = typeof args[0] === 'string' ? args[0] : args[0].url - if (url.includes('/x/relation/fans') || url.includes('/x/relation/followings')) { - return target.apply(thisArg, args).then(res => { + if ( + urlObj.hostname === 'api.bilibili.com' && + (urlObj.pathname.includes('/x/relation/fans') || + urlObj.pathname.includes('/x/relation/followings')) + ) { + return target + .apply(thisArg, args) + .then(res => { res .clone() .json() @@ -137,54 +114,63 @@ const entry = async () => { } list.forEach(user => { if (typeof user.mid === 'number' && typeof user.mtime === 'number') { - const label = url.includes('/x/relation/fans') - ? 'Ta 关注你的时间' - : '你关注 Ta 的时间' + const label = url.includes('/fans') ? 'Ta 关注你的时间' : '你关注 Ta 的时间' midMap[user.mid] = { mtime: user.mtime, label } - insertFollowTimeToCard( - user.mid, - new Date(user.mtime * 1000).toLocaleString(), - label, - ) + const dateStr = new Date(user.mtime * 1000).toLocaleString() + insertFollowTimeToCard(user.mid, dateStr, label) } }) }) - .catch(err => console.warn('JSON 解析失败:', err)) + .catch(err => { + console.warn('JSON 解析失败:', err) + }) return res }) - } - return target.apply(thisArg, args) - }, - }) + .catch(err => { + console.warn('fetch 请求失败:', err) + throw err + }) + } + + return target.apply(thisArg, args) + }, + }) +} + +const entry = async () => { + try { + const { addImportantStyle } = await import('@/core/style') + const { default: style } = await import('./subscribe-time.scss') + addImportantStyle(style, 'subscribe-time-style') + } catch (e) { + console.error('样式加载失败:', e) } + allMutations(updateCards) + + const userMid = (await getUserInfo()).mid const match = location.href.match(/space\.bilibili\.com\/(\d+)/) if (!match) { - console.warn('无法提取 mid') return } + const mid = Number(match[1]) + if (mid === userMid) { + console.log('当前为本人空间,跳过关注时间显示') + return + } const info = await bilibiliApi( getJsonWithCredentials(`https://api.bilibili.com/x/web-interface/relation?mid=${mid}`), ) - if (!info?.relation) { - console.warn('未获取到 relation 信息') - return - } - if (!info.relation.mtime) { - console.log('当前未关注或关注时间无效') + + const mtime = info?.relation?.mtime + if (!mtime) { return } - try { - await waitForProfileContainer() - } catch (e) { - console.warn('等待关注容器超时,跳过插入关注时间') - return - } - - insertSubscribeTime(new Date(info.relation.mtime * 1000).toLocaleString()) + await select(SELECTORS.profileFollowContainer) + insertSubscribeTime(new Date(mtime * 1000).toLocaleString()) } export const component = defineComponentMetadata({ @@ -200,5 +186,7 @@ export const component = defineComponentMetadata({ /https:\/\/space\.bilibili\.com\/\d+/, ], entry, - description: { 'zh-CN': '在粉丝/关注列表及用户主页显示关注的具体时间。' }, + description: { + 'zh-CN': '在粉丝/关注列表及用户主页显示关注的具体时间。', + }, }) From 368cf8dd959de613be7264116e93d717167ad6c9 Mon Sep 17 00:00:00 2001 From: wsgh0202 Date: Mon, 30 Jun 2025 23:21:20 +0800 Subject: [PATCH 02/24] =?UTF-8?q?fix:=20=E9=9A=90=E8=97=8F=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E8=BD=AE=E6=92=AD=E5=9B=BE=E5=A4=B1=E6=95=88=20feat:?= =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E4=BF=9D=E7=95=99=E5=8D=A0=E4=BD=8D?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home-carousel/hide-home-carousel.scss | 3 --- .../style/hide/home-carousel/index.ts | 24 ++++++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) delete mode 100644 registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss diff --git a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss deleted file mode 100644 index 1cbfdea49..000000000 --- a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss +++ /dev/null @@ -1,3 +0,0 @@ -.recommended-swipe.grid-anchor { - display: none !important; -} diff --git a/registry/lib/components/style/hide/home-carousel/index.ts b/registry/lib/components/style/hide/home-carousel/index.ts index 21ed03e90..e50c0c58c 100644 --- a/registry/lib/components/style/hide/home-carousel/index.ts +++ b/registry/lib/components/style/hide/home-carousel/index.ts @@ -1,15 +1,27 @@ import { defineComponentMetadata } from '@/components/define' +import { ComponentEntry } from '@/components/types' +import { select } from '@/core/spin-query' + +const entry: ComponentEntry = async ({ settings }) => { + select('.recommended-swipe').then((e: HTMLElement) => { + if (settings.options.keepPlaceholder) { + e.style.opacity = '0' + } else { + e.style.display = 'none' + } + }) +} export const component = defineComponentMetadata({ name: 'hideHomeCarousel', displayName: '隐藏首页轮播图', - entry: none, + entry, tags: [componentsTags.style], urlInclude: [/^https:\/\/www\.bilibili\.com\/$/, /^https:\/\/www\.bilibili\.com\/index\.html$/], - instantStyles: [ - { - name: 'hide-home-carousel', - style: () => import('./hide-home-carousel.scss'), + options: { + keepPlaceholder: { + displayName: '保留占位', + defaultValue: false, }, - ], + }, }) From b8c8485671fd2a8182913329af22b4a92590a536 Mon Sep 17 00:00:00 2001 From: CNOCM <80609142+CNOCM@users.noreply.github.com> Date: Thu, 3 Jul 2025 14:42:34 +0800 Subject: [PATCH 03/24] Update index.ts --- registry/lib/components/utils/subscribe-time-show/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/registry/lib/components/utils/subscribe-time-show/index.ts b/registry/lib/components/utils/subscribe-time-show/index.ts index 95151cf9b..b90497ddf 100644 --- a/registry/lib/components/utils/subscribe-time-show/index.ts +++ b/registry/lib/components/utils/subscribe-time-show/index.ts @@ -1,7 +1,6 @@ import { defineComponentMetadata } from '@/components/define' import { useScopedConsole } from '@/core/utils/log' import { bilibiliApi, getJsonWithCredentials } from '@/core/ajax' -import { dqa, dq } from '@/core/utils' import { select } from '@/core/spin-query' import { allMutations } from '@/core/observer' import { getUserInfo } from '@/core/user-info' From cb2f2ac859ac2e3a9d20a45ea562469b18a4dc34 Mon Sep 17 00:00:00 2001 From: wsgh0202 Date: Thu, 3 Jul 2025 20:08:49 +0800 Subject: [PATCH 04/24] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E9=80=89=E9=A1=B9=E6=96=B9=E5=BC=8F=E6=9D=A5=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home-carousel/hide-home-carousel.scss | 11 +++++++ .../style/hide/home-carousel/index.ts | 32 +++++++++++++------ 2 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss diff --git a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss new file mode 100644 index 000000000..59588b1f7 --- /dev/null +++ b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss @@ -0,0 +1,11 @@ +body.hide-home-carousel-full { + .recommended-swipe { + display: none !important; + } +} + +body.hide-home-carousel-transparent { + .recommended-swipe { + opacity: 0; + } +} diff --git a/registry/lib/components/style/hide/home-carousel/index.ts b/registry/lib/components/style/hide/home-carousel/index.ts index e50c0c58c..2276cc058 100644 --- a/registry/lib/components/style/hide/home-carousel/index.ts +++ b/registry/lib/components/style/hide/home-carousel/index.ts @@ -1,14 +1,16 @@ import { defineComponentMetadata } from '@/components/define' import { ComponentEntry } from '@/components/types' -import { select } from '@/core/spin-query' +import { addComponentListener } from '@/core/settings' -const entry: ComponentEntry = async ({ settings }) => { - select('.recommended-swipe').then((e: HTMLElement) => { - if (settings.options.keepPlaceholder) { - e.style.opacity = '0' - } else { - e.style.display = 'none' - } +const entry: ComponentEntry = async ({ metadata, settings }) => { + Object.keys(settings.options).forEach(disableType => { + addComponentListener( + `${metadata.name}.${disableType}`, + (value: boolean) => { + document.body.classList.toggle(`hide-home-carousel-${disableType}`, value) + }, + true, + ) }) } @@ -18,9 +20,19 @@ export const component = defineComponentMetadata({ entry, tags: [componentsTags.style], urlInclude: [/^https:\/\/www\.bilibili\.com\/$/, /^https:\/\/www\.bilibili\.com\/index\.html$/], + instantStyles: [ + { + name: 'hide-home-carousel', + style: () => import('./hide-home-carousel.scss'), + }, + ], options: { - keepPlaceholder: { - displayName: '保留占位', + full: { + displayName: '完全隐藏', + defaultValue: true, + }, + transparent: { + displayName: '透明化(保留占位)', defaultValue: false, }, }, From ba9c5e2042e320d16ee117de6d1193be97947f45 Mon Sep 17 00:00:00 2001 From: wsgh0202 Date: Sat, 5 Jul 2025 00:52:27 +0800 Subject: [PATCH 05/24] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=80=8F?= =?UTF-8?q?=E6=98=8E=E5=8C=BA=E5=9F=9F=E5=AE=B9=E6=98=93=E8=AF=AF=E8=A7=A6?= =?UTF-8?q?=E6=89=93=E5=BC=80=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/style/hide/home-carousel/hide-home-carousel.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss index 59588b1f7..9e301baf6 100644 --- a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss +++ b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss @@ -7,5 +7,6 @@ body.hide-home-carousel-full { body.hide-home-carousel-transparent { .recommended-swipe { opacity: 0; + pointer-events: none; } } From 2c1560a3066af08d45cedd2417ee9220bd809ae7 Mon Sep 17 00:00:00 2001 From: wsgh0202 Date: Sat, 12 Jul 2025 01:20:23 +0800 Subject: [PATCH 06/24] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- registry/lib/components/style/hide/home-carousel/index.md | 7 ++++++- registry/lib/components/style/hide/home-carousel/index.ts | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/registry/lib/components/style/hide/home-carousel/index.md b/registry/lib/components/style/hide/home-carousel/index.md index 8a8af0d22..6c546aac7 100644 --- a/registry/lib/components/style/hide/home-carousel/index.md +++ b/registry/lib/components/style/hide/home-carousel/index.md @@ -1 +1,6 @@ -隐藏首页的轮播图区域. +隐藏首页的轮播图区域 + +选项说明: + +- `隐藏占位`:完全隐藏整个轮播区域 +- `透明化`:轮播内容不可见,不可点击 diff --git a/registry/lib/components/style/hide/home-carousel/index.ts b/registry/lib/components/style/hide/home-carousel/index.ts index 2276cc058..98231c1fb 100644 --- a/registry/lib/components/style/hide/home-carousel/index.ts +++ b/registry/lib/components/style/hide/home-carousel/index.ts @@ -28,11 +28,11 @@ export const component = defineComponentMetadata({ ], options: { full: { - displayName: '完全隐藏', + displayName: '隐藏占位', defaultValue: true, }, transparent: { - displayName: '透明化(保留占位)', + displayName: '透明化', defaultValue: false, }, }, From 31d4fbb15ef6ea413e7937dcbfec77746a903058 Mon Sep 17 00:00:00 2001 From: wsgh0202 Date: Sat, 12 Jul 2025 02:11:18 +0800 Subject: [PATCH 07/24] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E5=9B=BE=E7=89=87=E3=80=81=E6=A0=87=E9=A2=98=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../style/hide/home-carousel/hide-home-carousel.scss | 12 ++++++++++++ .../lib/components/style/hide/home-carousel/index.md | 9 +++++++-- .../lib/components/style/hide/home-carousel/index.ts | 12 ++++++++++-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss index 9e301baf6..7cf511f62 100644 --- a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss +++ b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss @@ -10,3 +10,15 @@ body.hide-home-carousel-transparent { pointer-events: none; } } + +body.hide-home-carousel-picture { + .vui_carousel__slide { + display: none !important; + } +} + +body.hide-home-carousel-footerText { + .carousel-footer-text { + display: none !important; + } +} diff --git a/registry/lib/components/style/hide/home-carousel/index.md b/registry/lib/components/style/hide/home-carousel/index.md index 6c546aac7..25309b09b 100644 --- a/registry/lib/components/style/hide/home-carousel/index.md +++ b/registry/lib/components/style/hide/home-carousel/index.md @@ -2,5 +2,10 @@ 选项说明: -- `隐藏占位`:完全隐藏整个轮播区域 -- `透明化`:轮播内容不可见,不可点击 +- `隐藏轮播区域占位`:完全隐藏整个轮播区域 +- `透明化轮播区域`:完全透明化整个轮播区域,同时禁止点击打开链接 +- `隐藏轮播图片`:隐藏轮播图片,同时禁止点击图片打开链接 +- `隐藏图片标题`:隐藏图片标题,同时禁止点击标题打开链接 + +> 注:选项可以同时启用,但是最终显示效果以作用范围大的为准 +> 例如启用 `隐藏轮播区域占位`,由于整个区域都被隐藏,不管 `隐藏轮播图片`、`隐藏图片标题` 等选项是否启用都已经看不见了 diff --git a/registry/lib/components/style/hide/home-carousel/index.ts b/registry/lib/components/style/hide/home-carousel/index.ts index 98231c1fb..dcaa989da 100644 --- a/registry/lib/components/style/hide/home-carousel/index.ts +++ b/registry/lib/components/style/hide/home-carousel/index.ts @@ -28,11 +28,19 @@ export const component = defineComponentMetadata({ ], options: { full: { - displayName: '隐藏占位', + displayName: '隐藏轮播区域占位', defaultValue: true, }, transparent: { - displayName: '透明化', + displayName: '透明化轮播区域', + defaultValue: false, + }, + picture: { + displayName: '隐藏轮播图片', + defaultValue: false, + }, + footerText: { + displayName: '隐藏图片标题', defaultValue: false, }, }, From 29e304f0334e38ba9c22058965f2b5e869ed2a63 Mon Sep 17 00:00:00 2001 From: wsgh0202 Date: Sat, 12 Jul 2025 04:00:34 +0800 Subject: [PATCH 08/24] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E4=B8=BAswitch=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home-carousel/hide-home-carousel.scss | 24 +++++----- .../style/hide/home-carousel/index.ts | 44 +++++++------------ 2 files changed, 26 insertions(+), 42 deletions(-) diff --git a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss index 7cf511f62..3f707ef44 100644 --- a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss +++ b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss @@ -1,24 +1,20 @@ -body.hide-home-carousel-full { - .recommended-swipe { +$prefix: 'hideHomeCarousel-switch'; + +.#{$prefix} { + &-full .recommended-swipe { display: none !important; } -} -body.hide-home-carousel-transparent { - .recommended-swipe { + &-transparent .recommended-swipe { opacity: 0; pointer-events: none; } -} -body.hide-home-carousel-picture { - .vui_carousel__slide { - display: none !important; - } -} - -body.hide-home-carousel-footerText { - .carousel-footer-text { + &-picture .vui_carousel__slide { + display: none !important; + } + + &-footerText .carousel-footer-text { display: none !important; } } diff --git a/registry/lib/components/style/hide/home-carousel/index.ts b/registry/lib/components/style/hide/home-carousel/index.ts index dcaa989da..925080ed9 100644 --- a/registry/lib/components/style/hide/home-carousel/index.ts +++ b/registry/lib/components/style/hide/home-carousel/index.ts @@ -1,32 +1,8 @@ -import { defineComponentMetadata } from '@/components/define' -import { ComponentEntry } from '@/components/types' -import { addComponentListener } from '@/core/settings' +import { wrapSwitchOptions } from '@/components/switch-options' -const entry: ComponentEntry = async ({ metadata, settings }) => { - Object.keys(settings.options).forEach(disableType => { - addComponentListener( - `${metadata.name}.${disableType}`, - (value: boolean) => { - document.body.classList.toggle(`hide-home-carousel-${disableType}`, value) - }, - true, - ) - }) -} - -export const component = defineComponentMetadata({ - name: 'hideHomeCarousel', - displayName: '隐藏首页轮播图', - entry, - tags: [componentsTags.style], - urlInclude: [/^https:\/\/www\.bilibili\.com\/$/, /^https:\/\/www\.bilibili\.com\/index\.html$/], - instantStyles: [ - { - name: 'hide-home-carousel', - style: () => import('./hide-home-carousel.scss'), - }, - ], - options: { +export const component = wrapSwitchOptions({ + name: 'hideHomeCarouselOptions', + switches: { full: { displayName: '隐藏轮播区域占位', defaultValue: true, @@ -44,4 +20,16 @@ export const component = defineComponentMetadata({ defaultValue: false, }, }, +})({ + name: 'hideHomeCarousel', + displayName: '隐藏首页轮播图', + entry: null, + tags: [componentsTags.style], + urlInclude: [/^https:\/\/www\.bilibili\.com\/$/, /^https:\/\/www\.bilibili\.com\/index\.html$/], + instantStyles: [ + { + name: 'hide-home-carousel', + style: () => import('./hide-home-carousel.scss'), + }, + ], }) From f934904a2fb4af5b6d2d3646c1fd02713d0d2722 Mon Sep 17 00:00:00 2001 From: wsgh0202 Date: Sat, 12 Jul 2025 04:29:06 +0800 Subject: [PATCH 09/24] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E8=BD=AE=E6=92=AD=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../style/hide/home-carousel/index.md | 14 +++--- .../style/hide/home-carousel/index.ts | 46 ++++++++++++++++++- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/registry/lib/components/style/hide/home-carousel/index.md b/registry/lib/components/style/hide/home-carousel/index.md index 25309b09b..db35ffef5 100644 --- a/registry/lib/components/style/hide/home-carousel/index.md +++ b/registry/lib/components/style/hide/home-carousel/index.md @@ -2,10 +2,12 @@ 选项说明: -- `隐藏轮播区域占位`:完全隐藏整个轮播区域 -- `透明化轮播区域`:完全透明化整个轮播区域,同时禁止点击打开链接 -- `隐藏轮播图片`:隐藏轮播图片,同时禁止点击图片打开链接 -- `隐藏图片标题`:隐藏图片标题,同时禁止点击标题打开链接 +- `禁用轮播`:禁用图片轮播,可以手动切换 +- `样式开关`: + - `隐藏轮播区域占位`:完全隐藏整个轮播区域 + - `透明化轮播区域`:完全透明化整个轮播区域,同时禁止点击打开链接 + - `隐藏轮播图片`:隐藏轮播图片,同时禁止点击图片打开链接 + - `隐藏图片标题`:隐藏图片标题,同时禁止点击标题打开链接 -> 注:选项可以同时启用,但是最终显示效果以作用范围大的为准 -> 例如启用 `隐藏轮播区域占位`,由于整个区域都被隐藏,不管 `隐藏轮播图片`、`隐藏图片标题` 等选项是否启用都已经看不见了 + > 注:样式开关可以同时启用,但是最终显示效果以作用范围大的为准 + > 例如启用 `隐藏轮播区域占位`,由于整个区域都被隐藏,不管 `隐藏轮播图片`、`隐藏图片标题` 等选项是否启用都已经看不见了 diff --git a/registry/lib/components/style/hide/home-carousel/index.ts b/registry/lib/components/style/hide/home-carousel/index.ts index 925080ed9..6119b3024 100644 --- a/registry/lib/components/style/hide/home-carousel/index.ts +++ b/registry/lib/components/style/hide/home-carousel/index.ts @@ -1,4 +1,42 @@ import { wrapSwitchOptions } from '@/components/switch-options' +import { ComponentEntry } from '@/components/types' +import { addComponentListener } from '@/core/settings' +import { select } from '@/core/spin-query' +import { useScopedConsole } from '@/core/utils/log' + +const logger = useScopedConsole('hideHomeCarousel') + +// 轮播容器 mouseleave 事件拦截 +const onCarouselMouseLeaveHandler = (event: MouseEvent) => { + event.stopPropagation() +} + +const entry: ComponentEntry = async ({ metadata }) => { + // 监听【禁用轮播】选项 + addComponentListener( + `${metadata.name}.disableCarousel`, + async (value: boolean) => { + const node = (await select('.vui_carousel')) as HTMLElement + if (!node) { + logger.error('找不到轮播容器节点') + return + } + + if (value) { + node.addEventListener('mouseleave', onCarouselMouseLeaveHandler, true) + // 触发事件停止轮播 + const event = new MouseEvent('mouseenter') + node.dispatchEvent(event) + } else { + node.removeEventListener('mouseleave', onCarouselMouseLeaveHandler, true) + // 触发事件恢复轮播 + const event = new MouseEvent('mouseleave') + node.dispatchEvent(event) + } + }, + true, + ) +} export const component = wrapSwitchOptions({ name: 'hideHomeCarouselOptions', @@ -23,7 +61,7 @@ export const component = wrapSwitchOptions({ })({ name: 'hideHomeCarousel', displayName: '隐藏首页轮播图', - entry: null, + entry, tags: [componentsTags.style], urlInclude: [/^https:\/\/www\.bilibili\.com\/$/, /^https:\/\/www\.bilibili\.com\/index\.html$/], instantStyles: [ @@ -32,4 +70,10 @@ export const component = wrapSwitchOptions({ style: () => import('./hide-home-carousel.scss'), }, ], + options: { + disableCarousel: { + displayName: '禁用轮播', + defaultValue: false, + }, + }, }) From 10be10e09b18dc059a8f965050fc88e77206b5ff Mon Sep 17 00:00:00 2001 From: wsgh0202 Date: Sat, 12 Jul 2025 04:51:38 +0800 Subject: [PATCH 10/24] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=A8=A1=E7=B3=8A=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home-carousel/hide-home-carousel.scss | 4 +++ .../style/hide/home-carousel/index.md | 1 + .../style/hide/home-carousel/index.ts | 28 ++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss index 3f707ef44..96adb7a63 100644 --- a/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss +++ b/registry/lib/components/style/hide/home-carousel/hide-home-carousel.scss @@ -18,3 +18,7 @@ $prefix: 'hideHomeCarousel-switch'; display: none !important; } } + +.vui_carousel__slide { + filter: blur(var(--blur-amount, 0px)); +} diff --git a/registry/lib/components/style/hide/home-carousel/index.md b/registry/lib/components/style/hide/home-carousel/index.md index db35ffef5..273e4f9b1 100644 --- a/registry/lib/components/style/hide/home-carousel/index.md +++ b/registry/lib/components/style/hide/home-carousel/index.md @@ -3,6 +3,7 @@ 选项说明: - `禁用轮播`:禁用图片轮播,可以手动切换 +- `图片模糊`:模糊轮播图片,为0时不模糊 - `样式开关`: - `隐藏轮播区域占位`:完全隐藏整个轮播区域 - `透明化轮播区域`:完全透明化整个轮播区域,同时禁止点击打开链接 diff --git a/registry/lib/components/style/hide/home-carousel/index.ts b/registry/lib/components/style/hide/home-carousel/index.ts index 6119b3024..57d4b4a5d 100644 --- a/registry/lib/components/style/hide/home-carousel/index.ts +++ b/registry/lib/components/style/hide/home-carousel/index.ts @@ -1,7 +1,7 @@ import { wrapSwitchOptions } from '@/components/switch-options' import { ComponentEntry } from '@/components/types' import { addComponentListener } from '@/core/settings' -import { select } from '@/core/spin-query' +import { select, selectAll } from '@/core/spin-query' import { useScopedConsole } from '@/core/utils/log' const logger = useScopedConsole('hideHomeCarousel') @@ -36,6 +36,23 @@ const entry: ComponentEntry = async ({ metadata }) => { }, true, ) + + // 监听【图片模糊】选项 + addComponentListener( + `${metadata.name}.blur`, + async (value: number) => { + const nodes = (await selectAll('.vui_carousel__slide')) as HTMLElement[] + if (!nodes || nodes.length === 0) { + logger.error('找不到轮播图片节点') + return + } + + nodes.forEach(node => { + node.style.setProperty('--blur-amount', `${value}px`) + }) + }, + true, + ) } export const component = wrapSwitchOptions({ @@ -75,5 +92,14 @@ export const component = wrapSwitchOptions({ displayName: '禁用轮播', defaultValue: false, }, + blur: { + displayName: '图片模糊', + defaultValue: 0, + slider: { + min: 0, + max: 100, + step: 1, + }, + }, }, }) From 32dbb937580fa15ddf6eaa80943ce18698fa09e0 Mon Sep 17 00:00:00 2001 From: the1812 Date: Tue, 15 Jul 2025 08:20:52 +0800 Subject: [PATCH 11/24] Convert to Vue3 syntax --- .../feeds/filter/FeedsFilterCard.vue | 235 +++++++++--------- 1 file changed, 120 insertions(+), 115 deletions(-) diff --git a/registry/lib/components/feeds/filter/FeedsFilterCard.vue b/registry/lib/components/feeds/filter/FeedsFilterCard.vue index 698a48268..2260de787 100644 --- a/registry/lib/components/feeds/filter/FeedsFilterCard.vue +++ b/registry/lib/components/feeds/filter/FeedsFilterCard.vue @@ -37,10 +37,12 @@ v-for="[id, type] of Object.entries(allSideCards)" :key="id" class="filter-side-card-switch feeds-filter-switch" - @click="toggleBlockSide(id)" + @click="toggleBlockSide(parseInt(id))" > -