From dcb5430b6ce2630f4a62098598db6d7eec8d53be Mon Sep 17 00:00:00 2001 From: eric2788 Date: Sun, 14 Jan 2024 00:24:47 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20[MV3]=20=E5=9C=A8=E5=A4=A7=E6=B5=B7?= =?UTF-8?q?=E6=8A=A5=E7=9B=B4=E6=92=AD=E6=88=BF=E9=97=B4=E4=B8=8B=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E8=BF=90=E4=BD=9C=20#43,=20added=20scrollbar=20and=20?= =?UTF-8?q?max-height=20for=20each=20feature=20fragment=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/bilibili.ts | 8 ++- src/components/PromiseHandler.tsx | 4 +- src/contents/index/App.tsx | 13 ++++- src/contents/index/components/ButtonList.tsx | 8 +-- src/contents/index/components/Footer.tsx | 2 +- src/contents/index/mounter.tsx | 26 +++++---- src/features/jimaku/components/ButtonArea.tsx | 57 ++++++++++++------- .../jimaku/components/ButtonSwitchList.tsx | 31 ++++++++++ src/features/jimaku/components/JimakuArea.tsx | 29 +++++----- .../jimaku/components/JimakuCaptureLayer.tsx | 1 - .../superchat/components/SuperChatArea.tsx | 4 +- .../components/SuperChatFloatingButton.tsx | 2 +- src/features/superchat/index.tsx | 4 +- src/settings/features/jimaku.tsx | 44 -------------- src/settings/features/superchat.tsx | 21 ------- src/settings/fragments/developer.tsx | 2 +- src/settings/fragments/features.tsx | 4 +- src/settings/fragments/listings.tsx | 7 +-- src/tabs/stream.tsx | 12 ++-- src/utils/bilibili.ts | 1 + src/utils/misc.ts | 1 + 21 files changed, 135 insertions(+), 146 deletions(-) create mode 100644 src/features/jimaku/components/ButtonSwitchList.tsx delete mode 100644 src/settings/features/jimaku.tsx delete mode 100644 src/settings/features/superchat.tsx diff --git a/src/api/bilibili.ts b/src/api/bilibili.ts index e4317d6e..7ae7b642 100644 --- a/src/api/bilibili.ts +++ b/src/api/bilibili.ts @@ -5,7 +5,7 @@ import type { NeptuneIsMyWaifu } from "~background/functions/getBLiveCachedData" import func from '~utils/func' import { identifyVup } from './vtb-moe' import { sendMessager } from '~utils/messaging' -import { w_rid } from '~utils/bilibili' +import { isThemePage, w_rid } from '~utils/bilibili' export type StreamInfo = { room: string @@ -15,7 +15,8 @@ export type StreamInfo = { username: string isVtuber: boolean status: 'online' | 'offline' - liveTime: number + liveTime: number, + isTheme: boolean } export async function getStreamInfo(room: string): Promise { @@ -28,7 +29,8 @@ export async function getStreamInfo(room: string): Promise { username: data.anchor_info.base_info.uname, isVtuber: data.room_info.parent_area_id !== 9, // 分區辨識 status: data.room_info.live_status === 1 ? 'online' : 'offline', - liveTime: data.room_info.live_start_time + liveTime: data.room_info.live_start_time, + isTheme: isThemePage() // 目前尚未知道如何在 API 中取得 } } diff --git a/src/components/PromiseHandler.tsx b/src/components/PromiseHandler.tsx index b52971ca..45cef921 100644 --- a/src/components/PromiseHandler.tsx +++ b/src/components/PromiseHandler.tsx @@ -23,7 +23,7 @@ function DefaultErrorMessage({ error }: { error: Error | any }): JSX.Element { }, [error]) return ( -
+
加载错误: {error.message} @@ -34,7 +34,7 @@ function DefaultErrorMessage({ error }: { error: Error | any }): JSX.Element { function DefaultLoading(): JSX.Element { return ( -
+
) diff --git a/src/contents/index/App.tsx b/src/contents/index/App.tsx index 9b7bf5b7..00a4ef85 100644 --- a/src/contents/index/App.tsx +++ b/src/contents/index/App.tsx @@ -12,7 +12,15 @@ import Header from "./components/Header"; function App(): JSX.Element { - const { info, settings } = useContext(StreamInfoContext) + const streamInfo = useContext(StreamInfoContext) + + // i don't know why the hell this got rendered at the top level during HMR, should be the bug for plasmo + if (!streamInfo) { + console.warn('plasmo framework bug: streamInfo is undefined') + return <> + } + + const { info, settings } = streamInfo const { "settings.display": displaySettings } = settings @@ -23,13 +31,12 @@ function App(): JSX.Element { } const screenStatus = useWebScreenChange(settings['settings.developer'].classes) + const { bool: open, setFalse: closeDrawer, toggle } = useToggle(false) if (screenStatus !== 'normal' && !displaySettings.supportWebFullScreen) { return <> } - const { bool: open, setFalse: closeDrawer, toggle } = useToggle(false) - return ( diff --git a/src/contents/index/components/ButtonList.tsx b/src/contents/index/components/ButtonList.tsx index a101cf99..e3979c15 100644 --- a/src/contents/index/components/ButtonList.tsx +++ b/src/contents/index/components/ButtonList.tsx @@ -9,11 +9,6 @@ import { sendMessager } from "~utils/messaging" function ButtonList(): JSX.Element { const streamInfo = useContext(StreamInfoContext) - - if (!streamInfo) { - console.warn('BJF App is not ready.') - return <> - } const { settings, info } = streamInfo const { "settings.display": displaySettings, "settings.features": { common: { enabledPip, monitorWindow }} } = settings @@ -42,6 +37,9 @@ function ButtonList(): JSX.Element { } {monitorWindow && } + {(info.isTheme && displaySettings.themeToNormalButton) && + + }
) } diff --git a/src/contents/index/components/Footer.tsx b/src/contents/index/components/Footer.tsx index 03ac39b6..04f4e784 100644 --- a/src/contents/index/components/Footer.tsx +++ b/src/contents/index/components/Footer.tsx @@ -10,7 +10,7 @@ function Footer(): JSX.Element { return (