restructure files onto electron-vite boilerplate

This commit is contained in:
jeffvli 2025-05-18 14:03:18 -07:00
parent 91ce2cd8a1
commit 1cf587bc8f
457 changed files with 9927 additions and 11705 deletions

View file

@ -1,9 +1,10 @@
import { useEffect, useState } from 'react';
import { useHotkeys } from '@mantine/hooks';
import { useQueryClient } from '@tanstack/react-query';
import formatDuration from 'format-duration';
import isElectron from 'is-electron';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { BsDice3 } from 'react-icons/bs';
import { IoIosPause } from 'react-icons/io';
import {
RiPlayFill,
@ -16,29 +17,30 @@ import {
RiSpeedFill,
RiStopFill,
} from 'react-icons/ri';
import { BsDice3 } from 'react-icons/bs';
import styled from 'styled-components';
import { Text } from '/@/renderer/components';
import { useCenterControls } from '../hooks/use-center-controls';
import { PlayerButton } from './player-button';
import { openShuffleAllModal } from './shuffle-all-modal';
import { Text } from '/@/renderer/components';
import { PlayerbarSlider } from '/@/renderer/features/player/components/playerbar-slider';
import { usePlayQueueAdd } from '/@/renderer/features/player/hooks/use-playqueue-add';
import {
useCurrentPlayer,
useCurrentSong,
useCurrentStatus,
useCurrentPlayer,
useSetCurrentTime,
useRepeatStatus,
useShuffleStatus,
useCurrentTime,
useRepeatStatus,
useSetCurrentTime,
useShuffleStatus,
} from '/@/renderer/store';
import {
useHotkeySettings,
usePlaybackType,
useSettingsStore,
} from '/@/renderer/store/settings.store';
import { PlayerStatus, PlaybackType, PlayerShuffle, PlayerRepeat } from '/@/renderer/types';
import { PlayerbarSlider } from '/@/renderer/features/player/components/playerbar-slider';
import { openShuffleAllModal } from './shuffle-all-modal';
import { usePlayQueueAdd } from '/@/renderer/features/player/hooks/use-playqueue-add';
import { PlaybackType, PlayerRepeat, PlayerShuffle, PlayerStatus } from '/@/renderer/types';
interface CenterControlsProps {
playersRef: any;
@ -111,16 +113,16 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
const {
handleNextTrack,
handlePause,
handlePlay,
handlePlayPause,
handlePrevTrack,
handleSeekSlider,
handleSkipBackward,
handleSkipForward,
handleStop,
handleToggleRepeat,
handleToggleShuffle,
handleStop,
handlePause,
handlePlay,
} = useCenterControls({ playersRef });
const handlePlayQueueAdd = usePlayQueueAdd();
@ -174,15 +176,16 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
<ButtonsContainer>
<PlayerButton
icon={<RiStopFill size={buttonSize} />}
onClick={handleStop}
tooltip={{
label: t('player.stop', { postProcess: 'sentenceCase' }),
}}
variant="tertiary"
onClick={handleStop}
/>
<PlayerButton
$isActive={shuffle !== PlayerShuffle.NONE}
icon={<RiShuffleFill size={buttonSize} />}
onClick={handleToggleShuffle}
tooltip={{
label:
shuffle === PlayerShuffle.NONE
@ -193,19 +196,19 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
: t('player.shuffle', { postProcess: 'sentenceCase' }),
}}
variant="tertiary"
onClick={handleToggleShuffle}
/>
<PlayerButton
icon={<RiSkipBackFill size={buttonSize} />}
onClick={handlePrevTrack}
tooltip={{
label: t('player.previous', { postProcess: 'sentenceCase' }),
}}
variant="secondary"
onClick={handlePrevTrack}
/>
{skip?.enabled && (
<PlayerButton
icon={<RiRewindFill size={buttonSize} />}
onClick={() => handleSkipBackward(skip?.skipBackwardSeconds)}
tooltip={{
label: t('player.skip', {
context: 'back',
@ -213,7 +216,6 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
}),
}}
variant="secondary"
onClick={() => handleSkipBackward(skip?.skipBackwardSeconds)}
/>
)}
<PlayerButton
@ -225,6 +227,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
<IoIosPause size={buttonSize} />
)
}
onClick={handlePlayPause}
tooltip={{
label:
status === PlayerStatus.PAUSED
@ -232,11 +235,11 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
: t('player.pause', { postProcess: 'sentenceCase' }),
}}
variant="main"
onClick={handlePlayPause}
/>
{skip?.enabled && (
<PlayerButton
icon={<RiSpeedFill size={buttonSize} />}
onClick={() => handleSkipForward(skip?.skipForwardSeconds)}
tooltip={{
label: t('player.skip', {
context: 'forward',
@ -244,16 +247,15 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
}),
}}
variant="secondary"
onClick={() => handleSkipForward(skip?.skipForwardSeconds)}
/>
)}
<PlayerButton
icon={<RiSkipForwardFill size={buttonSize} />}
onClick={handleNextTrack}
tooltip={{
label: t('player.next', { postProcess: 'sentenceCase' }),
}}
variant="secondary"
onClick={handleNextTrack}
/>
<PlayerButton
$isActive={repeat !== PlayerRepeat.NONE}
@ -264,6 +266,7 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
<RiRepeat2Line size={buttonSize} />
)
}
onClick={handleToggleRepeat}
tooltip={{
label: `${
repeat === PlayerRepeat.NONE
@ -283,21 +286,20 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
}`,
}}
variant="tertiary"
onClick={handleToggleRepeat}
/>
<PlayerButton
icon={<BsDice3 size={buttonSize} />}
tooltip={{
label: t('player.playRandom', { postProcess: 'sentenceCase' }),
}}
variant="tertiary"
onClick={() =>
openShuffleAllModal({
handlePlayQueueAdd,
queryClient,
})
}
tooltip={{
label: t('player.playRandom', { postProcess: 'sentenceCase' }),
}}
variant="tertiary"
/>
</ButtonsContainer>
</ControlsContainer>
@ -317,9 +319,6 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
label={(value) => formatDuration(value * 1000)}
max={songDuration}
min={0}
size={6}
value={!isSeeking ? currentTime : seekValue}
w="100%"
onChange={(e) => {
setIsSeeking(true);
setSeekValue(e);
@ -333,6 +332,9 @@ export const CenterControls = ({ playersRef }: CenterControlsProps) => {
setIsSeeking(false);
}, 50);
}}
size={6}
value={!isSeeking ? currentTime : seekValue}
w="100%"
/>
</SliderWrapper>
<SliderValueWrapper $position="right">