diff --git a/packages/48tools/src/pages/PlayerWindow/LiveInfo/LiveInfo.tsx b/packages/48tools/src/pages/PlayerWindow/LiveInfo/LiveInfo.tsx index 9b80f8ab..d7251798 100644 --- a/packages/48tools/src/pages/PlayerWindow/LiveInfo/LiveInfo.tsx +++ b/packages/48tools/src/pages/PlayerWindow/LiveInfo/LiveInfo.tsx @@ -1,23 +1,9 @@ import { ipcRenderer } from 'electron'; -import { - Fragment, - useState, - type ReactElement, - type ReactNode, - type Dispatch as D, - type SetStateAction as S, - type MouseEvent -} from 'react'; +import type { ReactElement, ReactNode, MouseEvent } from 'react'; import * as PropTypes from 'prop-types'; -import { Avatar, Button, Tag, Tooltip, Space, message } from 'antd'; -import type { UseMessageReturnType } from '@48tools-types/antd'; -import { - ToolTwoTone as IconToolTwoTone, - UnorderedListOutlined as IconUnorderedListOutlined, - StopOutlined as IconStopOutlined -} from '@ant-design/icons'; +import { Avatar, Button, Tag, Tooltip } from 'antd'; +import { ToolTwoTone as IconToolTwoTone } from '@ant-design/icons'; import { source } from '../../../utils/snh48'; -import { getDanmuLocal, setDanmuLocal } from '../function/danmuLocal'; import type { PlayerInfo } from '../PlayerWindow'; import type { LiveRoomInfo } from '../../48/services/interface'; @@ -29,15 +15,6 @@ interface LiveInfoProps { /* 显示直播信息 */ function LiveInfo(props: LiveInfoProps): ReactElement { const { playerInfo, info }: LiveInfoProps = props; - const [messageApi, messageContextHolder]: UseMessageReturnType = message.useMessage(); - const [dl, setDl]: [boolean, D>] = useState(getDanmuLocal()); - - // 设置弹幕 - function handleDanmuSwitchClick(value: boolean, event: MouseEvent): void { - setDl(value); - setDanmuLocal(value); - messageApi.info(`${ value ? '开启' : '关闭' }弹幕加载,下次观看录播时生效。`); - } // 打开开发者工具 function handleOpenDeveloperToolsClick(event: MouseEvent): void { @@ -59,47 +36,22 @@ function LiveInfo(props: LiveInfoProps): ReactElement { } return ( - -
-

{ playerInfo.title }

- { - playerInfo.liveMode === 1 - ? 录屏 - : (playerInfo.liveType === 2 ? 电台 : 视频) - } -
-
{ infoRender() }
-
- - { - dl ? ( - -
+
+

{ playerInfo.title }

+ { + playerInfo.liveMode === 1 + ? 录屏 + : (playerInfo.liveType === 2 ? 电台 : 视频) + } +
+
{ infoRender() }
+
+ +
-
- { messageContextHolder } - +
+
); } diff --git a/packages/48tools/src/pages/PlayerWindow/Video/RecordVideo.tsx b/packages/48tools/src/pages/PlayerWindow/Video/RecordVideo.tsx index 831362e5..6896f122 100644 --- a/packages/48tools/src/pages/PlayerWindow/Video/RecordVideo.tsx +++ b/packages/48tools/src/pages/PlayerWindow/Video/RecordVideo.tsx @@ -5,7 +5,6 @@ import { source, engineUserAgent } from '../../../utils/snh48'; import { requestDownloadFile } from '../../48/services/pocket48'; import { formatTsUrl } from '../../48/Pocket48/Pocket48Record/Pocket48Record'; import { danmuStore } from '../function/DanmuStore'; -import { getDanmuLocal } from '../function/danmuLocal'; import type { PlayerInfo } from '../PlayerWindow'; import type { LiveRoomInfo } from '../../48/services/interface'; import type { DanmuItem } from '../types'; @@ -63,10 +62,10 @@ function RecordVideo(props: RecordVideoProps): ReactElement { // 生成弹幕文件 function createVideoTrack(): void { - if (videoLoaded && danmuList.length && videoRef.current && getDanmuLocal()) { + if (videoLoaded && danmuList.length && videoRef.current) { const track: TextTrack = videoRef.current.addTextTrack('subtitles', '弹幕', 'zh'); - track.mode = 'showing'; + track.mode = 'hidden'; for (const item of danmuList) { const vttcue: VTTCue = new VTTCue(item.currentTime, item.currentTime + 3, `${ item.nickname }:${ item.message }`); diff --git a/packages/48tools/src/pages/PlayerWindow/function/danmuLocal.ts b/packages/48tools/src/pages/PlayerWindow/function/danmuLocal.ts deleted file mode 100644 index 880c5640..00000000 --- a/packages/48tools/src/pages/PlayerWindow/function/danmuLocal.ts +++ /dev/null @@ -1,18 +0,0 @@ -const KEY: string = 'VIDEO_NATIVE_TRACK'; -const DISABLED_VALUE: string = 'false'; - -/* 读取是否开启弹幕 */ -export function getDanmuLocal(): boolean { - const danmuLocal: string | null = localStorage.getItem(KEY); - - return !(danmuLocal === DISABLED_VALUE); -} - -/* 设置是否开启弹幕 */ -export function setDanmuLocal(value: boolean): void { - if (value) { - localStorage.removeItem(KEY); - } else { - localStorage.setItem(KEY, DISABLED_VALUE); - } -} \ No newline at end of file