11<script setup lang="ts">
22import { onKeyStroke , useEventListener , useThrottleFn , useToggle } from ' @vueuse/core'
33import type { Ref } from ' vue'
4+ import { ref } from ' vue'
45
56import type { BewlyAppProvider } from ' ~/composables/useAppProvider'
67import { useDark } from ' ~/composables/useDark'
@@ -16,9 +17,26 @@ import emitter from '~/utils/mitt'
1617
1718import { setupNecessarySettingsWatchers } from ' ./necessarySettingsWatchers'
1819
20+ // Check if current page is festival page
21+ function isFestivalPage(): boolean {
22+ return / https? :\/\/ (?:www\. )? bilibili\. com\/ festival\/ . * / .test (document .URL )
23+ }
24+
1925const mainStore = useMainStore ()
2026const settingsStore = useSettingsStore ()
21- const { isDark } = useDark ()
27+
28+ // Conditionally use dark mode (skip on festival pages)
29+ let isDark: Ref <boolean >
30+ // Always use dark mode if enabled, but let useDark() handle selective application
31+ const shouldUseDark = settings .value .adaptToOtherPageStyles
32+
33+ if (shouldUseDark ) {
34+ const darkResult = useDark ()
35+ isDark = darkResult .isDark
36+ }
37+ else {
38+ isDark = ref (false )
39+ }
2240const [showSettings, toggleSettings] = useToggle (false )
2341
2442// Get the 'page' query parameter from the URL
@@ -114,12 +132,20 @@ useEventListener(window, 'message', ({ data, source }) => {
114132 // 在iframe环境中,只更新DOM样式,不修改用户的主题设置
115133 // 避免覆盖用户设置的"auto"模式
116134 if (isInIframe ()) {
135+ // Check if we should apply selective dark mode (plugin UI only) on festival pages
136+ const isSelectiveDark = isFestivalPage ()
137+
117138 // 立即更新DOM样式,不修改settings.value.theme
118139 if (isDark ) {
119- document .documentElement .classList .add (' dark' )
120- document .body ?.classList .add (' dark' )
140+ // Always apply to plugin container
121141 document .querySelector (' #bewly' )?.classList .add (' dark' )
122142
143+ // Only apply global styles if not on festival pages
144+ if (! isSelectiveDark ) {
145+ document .documentElement .classList .add (' dark' )
146+ document .body ?.classList .add (' dark' )
147+ }
148+
123149 // 如果提供了深色模式基准颜色,则应用它(仅应用到DOM,不修改设置)
124150 if (darkModeBaseColor ) {
125151 document .documentElement .style .setProperty (' --bew-dark-base-color' , darkModeBaseColor )
@@ -132,9 +158,13 @@ useEventListener(window, 'message', ({ data, source }) => {
132158 }
133159 }
134160 else {
135- document .documentElement .classList .remove (' dark' )
136- document .body ?.classList .remove (' dark' )
137161 document .querySelector (' #bewly' )?.classList ?.remove (' dark' )
162+
163+ // Only remove global classes if not in selective mode
164+ if (! isSelectiveDark ) {
165+ document .documentElement .classList .remove (' dark' )
166+ document .body ?.classList .remove (' dark' )
167+ }
138168 }
139169
140170 // 强制重新计算样式
0 commit comments