From 4ec6faec2bcfcc7c3c6a2e893e15993d02ca5e5a Mon Sep 17 00:00:00 2001 From: wsgh0202 Date: Fri, 25 Jul 2025 19:01:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0debug=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/components/utils/remove-promotions/index.md | 9 ++++++--- .../lib/components/utils/remove-promotions/index.ts | 11 +++++++++++ .../utils/remove-promotions/remove-promotions.scss | 9 +++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/registry/lib/components/utils/remove-promotions/index.md b/registry/lib/components/utils/remove-promotions/index.md index 20824b933..ea2c748f1 100644 --- a/registry/lib/components/utils/remove-promotions/index.md +++ b/registry/lib/components/utils/remove-promotions/index.md @@ -1,4 +1,7 @@ -删除站内的各种广告. 包括首页的推广模块, 手机 app 推荐, 视频页面右侧的广告等. 注意: 首页推广模块删除后留下空白区域是正常现象, 如果觉得怪可以开启 \`占位文本\` 选项. +删除站内的各种广告. 包括首页的推广模块, 手机 app 推荐, 视频页面右侧的广告等. -- \`占位文本\`: 删除首页推广模块的广告后显示"🚫已屏蔽广告"来替代空白区域. -- \`保留活动横幅\`: 保留视频页面的活动横幅. +>注意: 首页推广模块删除后留下空白区域是正常现象, 如果觉得怪可以开启 `占位文本` 选项. + +- `占位文本`: 删除首页推广模块的广告后显示"🚫已屏蔽广告"来替代空白区域. +- `保留活动横幅`: 保留视频页面的活动横幅. +- `debug`: 调试模式,用于查看是否正确屏蔽广告 diff --git a/registry/lib/components/utils/remove-promotions/index.ts b/registry/lib/components/utils/remove-promotions/index.ts index f8d3662a2..e06aa7ef4 100644 --- a/registry/lib/components/utils/remove-promotions/index.ts +++ b/registry/lib/components/utils/remove-promotions/index.ts @@ -88,6 +88,13 @@ const entry: ComponentEntry = async ({ settings, metadata }) => { }, true, ) + addComponentListener( + `${metadata.name}.debug`, + (value: boolean) => { + document.body.classList.toggle('debug', value) + }, + true, + ) } export const component = defineComponentMetadata({ name: 'removePromotions', @@ -113,5 +120,9 @@ export const component = defineComponentMetadata({ displayName: '保留动态商品推荐', defaultValue: false, }, + debug: { + displayName: 'debug', + defaultValue: false, + }, }, }) diff --git a/registry/lib/components/utils/remove-promotions/remove-promotions.scss b/registry/lib/components/utils/remove-promotions/remove-promotions.scss index 2b2e711dd..ee3a6c667 100644 --- a/registry/lib/components/utils/remove-promotions/remove-promotions.scss +++ b/registry/lib/components/utils/remove-promotions/remove-promotions.scss @@ -117,5 +117,14 @@ body:not(.preserve-feed-goods) .bili-dyn-content__orig__additional:has(.dyn-good body.promotion-show-placeholder & { visibility: visible; } + + body.debug & { + visibility: hidden !important; + } + } + + body.debug & { + visibility: visible; + border: red 1px solid; } }