diff --git a/apps/pwa/src/components/tab_list.tsx b/apps/pwa/src/components/tab_list.tsx index 8807a312..16c16271 100644 --- a/apps/pwa/src/components/tab_list.tsx +++ b/apps/pwa/src/components/tab_list.tsx @@ -49,7 +49,7 @@ function TabList({ tabList, onChange, ...props -}: HtmlHTMLAttributes & { +}: Omit, 'onChange'> & { current: TabType; tabList: { tab: TabType; diff --git a/apps/pwa/src/i18n/en_us.ts b/apps/pwa/src/i18n/en_us.ts index 44eb1f37..26004c73 100644 --- a/apps/pwa/src/i18n/en_us.ts +++ b/apps/pwa/src/i18n/en_us.ts @@ -215,4 +215,6 @@ export default { someone_created_at: '%s1 created at %s2', quit_shared_musicbill_question: 'are you sure to quit this shared musicbill ?', + playlist: 'playlist', + playqueue: 'playqueue', }; diff --git a/apps/pwa/src/i18n/zh_hans.ts b/apps/pwa/src/i18n/zh_hans.ts index a271ee7a..b51e28b6 100644 --- a/apps/pwa/src/i18n/zh_hans.ts +++ b/apps/pwa/src/i18n/zh_hans.ts @@ -203,6 +203,8 @@ const zhCN: { unknown_singer: '未知歌手', someone_created_at: '%s1 创建于 %s2', quit_shared_musicbill_question: '确定退出该共享乐单吗?', + playlist: '播放列表', + playqueue: '播放队列', }; export default zhCN; diff --git a/apps/pwa/src/pages/player/pages/exploration/cache.ts b/apps/pwa/src/pages/player/pages/exploration/cache.ts index 6234db88..1e3a4db7 100644 --- a/apps/pwa/src/pages/player/pages/exploration/cache.ts +++ b/apps/pwa/src/pages/player/pages/exploration/cache.ts @@ -1,4 +1,4 @@ -import Cache from '#/utils/cache'; +import Cache from '@/utils/cache'; import { ExplorationItem } from './constants'; export enum CacheKey { diff --git a/apps/pwa/src/pages/player/pages/musicbill/cache.ts b/apps/pwa/src/pages/player/pages/musicbill/cache.ts index 2e0bf5c4..e101e381 100644 --- a/apps/pwa/src/pages/player/pages/musicbill/cache.ts +++ b/apps/pwa/src/pages/player/pages/musicbill/cache.ts @@ -1,4 +1,4 @@ -import Cache from '#/utils/cache'; +import Cache from '@/utils/cache'; export enum CacheKey { MUSICBILL_PAGE_SCROLL_TOP = 'musicbill_page_scroll_top_{{id}}', diff --git a/apps/pwa/src/pages/player/playlist_playqueue_drawer/cache.ts b/apps/pwa/src/pages/player/playlist_playqueue_drawer/cache.ts index 31400011..128e956c 100644 --- a/apps/pwa/src/pages/player/playlist_playqueue_drawer/cache.ts +++ b/apps/pwa/src/pages/player/playlist_playqueue_drawer/cache.ts @@ -1,13 +1,13 @@ -import Cache from '#/utils/cache'; +import Cache from '@/utils/cache'; import { Tab } from './constants'; export enum CacheKey { - TAB = 'tab', + SELECTED_TAB = 'selected_tab', } export default new Cache< CacheKey, { - [CacheKey.TAB]: Tab; + [CacheKey.SELECTED_TAB]: Tab; } >(); diff --git a/apps/pwa/src/pages/player/playlist_playqueue_drawer/content.tsx b/apps/pwa/src/pages/player/playlist_playqueue_drawer/content.tsx index 1e74ab6f..f6c8664a 100644 --- a/apps/pwa/src/pages/player/playlist_playqueue_drawer/content.tsx +++ b/apps/pwa/src/pages/player/playlist_playqueue_drawer/content.tsx @@ -1,50 +1,34 @@ import { useEffect, useState } from 'react'; -import TabList from '@/components/tab_list'; import { useTransition } from 'react-spring'; -import styled from 'styled-components'; import Playqueue from './playqueue'; import Playlist from './playlist'; -import { Tab, TAB_LIST_HEIGHT } from './constants'; +import { Tab } from './constants'; import cache, { CacheKey } from './cache'; - -const TAB_MAP_LABEL: Record = { - [Tab.PLAYLIST]: '播放列表', - [Tab.PLAYQUEUE]: '播放队列', -}; -const TAB_LIST = Object.values(Tab).map((t) => ({ - tab: t, - label: TAB_MAP_LABEL[t], -})); -const StyledTabList = styled(TabList)` - position: absolute; - top: 0; - left: 0; - width: 100%; - height: ${TAB_LIST_HEIGHT}px; - - padding: 0 20px; - - backdrop-filter: blur(5px); -`; +import TabList from './tab_list'; function Content() { - const [tab, setTab] = useState( - () => cache.get(CacheKey.TAB) || Tab.PLAYQUEUE, + const [selectedTab, setSelectedTab] = useState( + () => cache.get(CacheKey.SELECTED_TAB) || Tab.PLAYQUEUE, ); useEffect(() => { - cache.set({ key: CacheKey.TAB, value: tab, ttl: Infinity }); - }, [tab]); - - const transitions = useTransition(tab, { + cache.set({ + key: CacheKey.SELECTED_TAB, + value: selectedTab, + ttl: Infinity, + }); + }, [selectedTab]); + + const transitions = useTransition(selectedTab, { from: { opacity: 0 }, enter: { opacity: 1 }, leave: { opacity: 0 }, }); + return ( <> - {transitions((style, t) => { - switch (t) { + {transitions((style, tab) => { + switch (tab) { case Tab.PLAYLIST: { return ; } @@ -58,11 +42,7 @@ function Content() { } } })} - setTab(t)} - tabList={TAB_LIST} - /> + ); } diff --git a/apps/pwa/src/pages/player/playlist_playqueue_drawer/playlist/index.tsx b/apps/pwa/src/pages/player/playlist_playqueue_drawer/playlist/index.tsx index df028de1..b6b24026 100644 --- a/apps/pwa/src/pages/player/playlist_playqueue_drawer/playlist/index.tsx +++ b/apps/pwa/src/pages/player/playlist_playqueue_drawer/playlist/index.tsx @@ -17,6 +17,7 @@ import Empty from '@/components/empty'; import { flexCenter } from '@/style/flexbox'; import autoScrollbar from '@/style/auto_scrollbar'; import { t } from '@/i18n'; +import useTitlebarArea from '@/utils/use_titlebar_area_rect'; import { TAB_LIST_HEIGHT } from '../constants'; import Context from '../../context'; import TabContent from '../tab_content'; @@ -33,7 +34,6 @@ const Style = styled(TabContent)` > .content { ${absoluteFullSize} - padding-top: ${TAB_LIST_HEIGHT}px; padding-bottom: calc(${FILTER_HEIGHT}px + env(safe-area-inset-bottom, 0)); &.list { @@ -73,6 +73,11 @@ function Playlist({ style }: { style: unknown }) { ); }, [keyword]); + const { height: titlebarAreaHeight } = useTitlebarArea(); + const contentStyle: CSSProperties = { + paddingTop: TAB_LIST_HEIGHT + titlebarAreaHeight, + }; + const filteredPlaylist = playlist.filter((music) => filterMusic(music, keyword), ); @@ -80,7 +85,7 @@ function Playlist({ style }: { style: unknown }) { // @ts-expect-error