feat: updates (#1530)

* feat: 支持repeat mode切换

* feat: 歌单页面的播放按钮可以暂停

* fix: 专辑页面播放按钮

考虑私人FM的情况
解决按钮闪烁问题

* fix: SvgName报错

* update
This commit is contained in:
memorydream 2022-04-15 00:34:07 +08:00 committed by GitHub
parent 13281d3f08
commit 24af937e70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 96 additions and 30 deletions

View file

@ -10,6 +10,7 @@ import { resizeImage } from '@/renderer/utils/common'
import {
State as PlayerState,
Mode as PlayerMode,
RepeatMode as PlayerRepeatMode,
} from '@/renderer/utils/player'
const PlayingTrack = () => {
@ -130,25 +131,45 @@ const MediaControls = () => {
const Others = () => {
const playerSnapshot = useSnapshot(player)
const mode = useMemo(() => playerSnapshot.mode, [playerSnapshot.mode])
const switchRepeatMode = () => {
if (playerSnapshot.repeatMode === PlayerRepeatMode.OFF) {
player.repeatMode = PlayerRepeatMode.ON
} else if (playerSnapshot.repeatMode === PlayerRepeatMode.ON) {
player.repeatMode = PlayerRepeatMode.ONE
} else {
player.repeatMode = PlayerRepeatMode.OFF
}
}
return (
<div className='flex items-center justify-end gap-2 pr-2 text-black dark:text-white'>
<IconButton
onClick={() => toast('Work in progress')}
disabled={mode === PlayerMode.FM}
disabled={playerSnapshot.mode === PlayerMode.FM}
>
<SvgIcon className='h-6 w-6' name='playlist' />
</IconButton>
<IconButton
onClick={() => toast('施工中...')}
disabled={mode === PlayerMode.FM}
onClick={switchRepeatMode}
disabled={playerSnapshot.mode === PlayerMode.FM}
>
<SvgIcon className='h-6 w-6' name='repeat' />
<SvgIcon
className={classNames(
'h-6 w-6',
playerSnapshot.repeatMode !== PlayerRepeatMode.OFF &&
'text-brand-500'
)}
name={
playerSnapshot.repeatMode === PlayerRepeatMode.ONE
? 'repeat-1'
: 'repeat'
}
/>
</IconButton>
<IconButton
onClick={() => toast('施工中...')}
disabled={mode === PlayerMode.FM}
disabled={playerSnapshot.mode === PlayerMode.FM}
>
<SvgIcon className='h-6 w-6' name='shuffle' />
</IconButton>