From 08eff67d2f462b5b99f25260e856a502966b2722 Mon Sep 17 00:00:00 2001 From: 22 <60903333+nini22P@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:30:44 +0800 Subject: [PATCH 1/6] improve interface --- src/hooks/ui/useCustomTheme.ts | 6 +++ src/hooks/ui/useThemeColor.ts | 2 +- src/index.css | 11 ++--- src/pages/NavBar.tsx | 11 ++++- src/pages/Player/Audio/Audio.tsx | 4 +- src/pages/Player/PlayQueue.tsx | 24 +++++------ src/pages/Player/Player.tsx | 38 ++++++++++------- src/pages/Player/PlayerControl.tsx | 16 ++++--- src/pages/Player/VideoPlayer.tsx | 31 -------------- src/pages/Player/VideoPlayerTopbar.tsx | 58 ++++++++++++++++++++++++++ src/pages/Search.tsx | 10 ++--- 11 files changed, 130 insertions(+), 81 deletions(-) create mode 100644 src/pages/Player/VideoPlayerTopbar.tsx diff --git a/src/hooks/ui/useCustomTheme.ts b/src/hooks/ui/useCustomTheme.ts index 1ab45a8..82fb40d 100644 --- a/src/hooks/ui/useCustomTheme.ts +++ b/src/hooks/ui/useCustomTheme.ts @@ -176,6 +176,12 @@ const useCustomTheme = () => { paper: { border: `${prefersDarkMode ? '#f7f7f722' : '#3b3b3b22'} solid 1px`, boxShadow: `5px 5px 10px 0px ${prefersDarkMode ? '#f7f7f722' : '#3b3b3b22'}`, + }, + root: { + ' .MuiBackdrop-root': { + background: `${prefersDarkMode ? '#121212' : '#ffffff'}33`, + backdropFilter: 'blur(0.5px)', + }, } } }, diff --git a/src/hooks/ui/useThemeColor.ts b/src/hooks/ui/useThemeColor.ts index 13d83da..a36c1b3 100644 --- a/src/hooks/ui/useThemeColor.ts +++ b/src/hooks/ui/useThemeColor.ts @@ -33,7 +33,7 @@ const useThemeColor = () => { themeColorLight.content = customTheme.palette.background.default themeColorDark.content = customTheme.palette.background.default } - else if (audioViewIsShow && audioViewTheme === 'classic' || videoViewIsShow) { + else if (audioViewIsShow && audioViewTheme === 'classic') { themeColorLight.content = '#1e1e1e' themeColorDark.content = '#1e1e1e' } diff --git a/src/index.css b/src/index.css index 3e22567..0738147 100644 --- a/src/index.css +++ b/src/index.css @@ -23,6 +23,9 @@ html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; font-family: Roboto, Helvetica, Arial, sans-serif; + --custom-titlebar-height: 32px; + --titlebar-height: env(titlebar-area-height, var(--custom-titlebar-height)); + --titlebar-center-safe-width: calc((50dvw - (100dvw - env(titlebar-area-x) - env(titlebar-area-width))) * 2) } :root[data-theme="light"] { @@ -50,13 +53,7 @@ a { } .pt-titlebar-area-height { - padding-top: 0 !important; -} - -@media (display-mode: window-controls-overlay) { - .pt-titlebar-area-height { - padding-top: env(titlebar-area-height, 32) !important; - } + padding-top: env(titlebar-area-height, 0) !important; } .show-scrollbar::-webkit-scrollbar-thumb { diff --git a/src/pages/NavBar.tsx b/src/pages/NavBar.tsx index 45705af..76f9c79 100644 --- a/src/pages/NavBar.tsx +++ b/src/pages/NavBar.tsx @@ -54,7 +54,14 @@ const NavBar = () => { justifyContent: { xs: 'flex-end', sm: windowControlsOverlayOpen ? 'flex-end' : 'center', md: 'center' } }} > - + @@ -90,7 +97,7 @@ const NavBar = () => { /> OMP diff --git a/src/pages/Player/Audio/Audio.tsx b/src/pages/Player/Audio/Audio.tsx index 5b16381..8be144d 100644 --- a/src/pages/Player/Audio/Audio.tsx +++ b/src/pages/Player/Audio/Audio.tsx @@ -75,9 +75,10 @@ const Audio = ({ player }: { player: HTMLVideoElement | null }) => { { {audioViewTheme === 'classic' && } {audioViewTheme === 'modern' && } - ) } diff --git a/src/pages/Player/PlayQueue.tsx b/src/pages/Player/PlayQueue.tsx index e8d9714..b5806c0 100644 --- a/src/pages/Player/PlayQueue.tsx +++ b/src/pages/Player/PlayQueue.tsx @@ -1,5 +1,4 @@ -import { Button, Drawer } from '@mui/material' -import Grid from '@mui/material/Unstable_Grid2' +import { Box, Button, Drawer, useTheme } from '@mui/material' import KeyboardArrowRightRoundedIcon from '@mui/icons-material/KeyboardArrowRightRounded' import usePlayQueueStore from '@/store/usePlayQueueStore' import useUiStore from '@/store/useUiStore' @@ -10,6 +9,7 @@ import useCustomTheme from '@/hooks/ui/useCustomTheme' const PlayQueue = () => { const { scrollbarStyle } = useCustomTheme() + const theme = useTheme() const [ currentIndex, @@ -54,18 +54,13 @@ const PlayQueue = () => { onClose={() => updatePlayQueueIsShow(false)} sx={{ '& .MuiDrawer-paper': { - width: { xs: 'calc(100vw - 0.5rem)', sm: '400px', md: '500px' } + width: { xs: 'calc(100vw - 0.5rem)', sm: '400px' } }, ...scrollbarStyle }} > - - - - - + + { playQueue && { func={{ open, remove }} /> } - - + + + + + ) } diff --git a/src/pages/Player/Player.tsx b/src/pages/Player/Player.tsx index a510ee7..932a3bb 100644 --- a/src/pages/Player/Player.tsx +++ b/src/pages/Player/Player.tsx @@ -1,5 +1,5 @@ import { useRef } from 'react' -import { Box, Container } from '@mui/material' +import { Box } from '@mui/material' import useUiStore from '@/store/useUiStore' import useMediaSession from '@/hooks/player/useMediaSession' import usePlayerCore from '@/hooks/player/usePlayerCore' @@ -7,10 +7,17 @@ import VideoPlayer from './VideoPlayer' import Audio from './Audio/Audio' import PlayerControl from './PlayerControl' import PlayQueue from './PlayQueue' +import VideoPlayerTopbar from './VideoPlayerTopbar' const Player = () => { - const controlIsShow = useUiStore((state) => state.controlIsShow) + const [ + controlIsShow, + ] = useUiStore( + (state) => [ + state.controlIsShow, + ] + ) const playerRef = useRef(null) const player = playerRef.current // 声明播放器对象 @@ -23,20 +30,21 @@ const Player = () => { return ( <> - - - - - - + + + +