mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 10:23:33 +00:00
restructure files onto electron-vite boilerplate
This commit is contained in:
parent
91ce2cd8a1
commit
1cf587bc8f
457 changed files with 9927 additions and 11705 deletions
|
|
@ -1,15 +1,16 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import { SelectItem } from '@mantine/core';
|
||||
import isElectron from 'is-electron';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Select, Slider, Switch, toast } from '/@/renderer/components';
|
||||
import {
|
||||
SettingsSection,
|
||||
SettingOption,
|
||||
SettingsSection,
|
||||
} from '/@/renderer/features/settings/components/settings-section';
|
||||
import { useCurrentStatus, usePlayerStore } from '/@/renderer/store';
|
||||
import { usePlaybackSettings, useSettingsStoreActions } from '/@/renderer/store/settings.store';
|
||||
import { PlaybackType, PlayerStatus, PlaybackStyle, CrossfadeStyle } from '/@/renderer/types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { CrossfadeStyle, PlaybackStyle, PlaybackType, PlayerStatus } from '/@/renderer/types';
|
||||
import { setQueue } from '/@/renderer/utils/set-transcoded-queue-data';
|
||||
|
||||
const getAudioDevice = async () => {
|
||||
|
|
@ -163,10 +164,10 @@ export const AudioSettings = ({ hasFancyAudio }: { hasFancyAudio: boolean }) =>
|
|||
}
|
||||
max={15}
|
||||
min={0}
|
||||
w={100}
|
||||
onChangeEnd={(e) =>
|
||||
setSettings({ playback: { ...settings, crossfadeDuration: e } })
|
||||
}
|
||||
w={100}
|
||||
/>
|
||||
),
|
||||
description: t('setting.crossfadeDuration', {
|
||||
|
|
@ -202,13 +203,13 @@ export const AudioSettings = ({ hasFancyAudio }: { hasFancyAudio: boolean }) =>
|
|||
settings.style !== PlaybackStyle.CROSSFADE ||
|
||||
status === PlayerStatus.PLAYING
|
||||
}
|
||||
width={200}
|
||||
onChange={(e) => {
|
||||
if (!e) return;
|
||||
setSettings({
|
||||
playback: { ...settings, crossfadeStyle: e as CrossfadeStyle },
|
||||
});
|
||||
}}
|
||||
width={200}
|
||||
/>
|
||||
),
|
||||
description: t('setting.crossfadeStyle', {
|
||||
|
|
|
|||
|
|
@ -1,23 +1,24 @@
|
|||
import isElectron from 'is-electron';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { languages } from '/@/i18n/i18n';
|
||||
import { LyricSource } from '/@/renderer/api/types';
|
||||
import {
|
||||
MultiSelect,
|
||||
MultiSelectProps,
|
||||
NumberInput,
|
||||
Select,
|
||||
Switch,
|
||||
TextInput,
|
||||
} from '/@/renderer/components';
|
||||
import {
|
||||
SettingOption,
|
||||
SettingsSection,
|
||||
} from '/@/renderer/features/settings/components/settings-section';
|
||||
import { useLyricsSettings, useSettingsStoreActions } from '/@/renderer/store';
|
||||
import {
|
||||
Select,
|
||||
MultiSelect,
|
||||
MultiSelectProps,
|
||||
TextInput,
|
||||
NumberInput,
|
||||
Switch,
|
||||
} from '/@/renderer/components';
|
||||
import isElectron from 'is-electron';
|
||||
import styled from 'styled-components';
|
||||
import { LyricSource } from '/@/renderer/api/types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { languages } from '/@/i18n/i18n';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
const localSettings = isElectron() ? window.api.localSettings : null;
|
||||
|
||||
const WorkingButtonSelect = styled(MultiSelect)<MultiSelectProps>`
|
||||
& button {
|
||||
|
|
@ -77,11 +78,10 @@ export const LyricSettings = () => {
|
|||
{
|
||||
control: (
|
||||
<WorkingButtonSelect
|
||||
clearable
|
||||
aria-label="Lyric providers"
|
||||
clearable
|
||||
data={Object.values(LyricSource)}
|
||||
defaultValue={settings.sources}
|
||||
width={300}
|
||||
onChange={(e: LyricSource[]) => {
|
||||
localSettings?.set('lyrics', e);
|
||||
setSettings({
|
||||
|
|
@ -91,6 +91,7 @@ export const LyricSettings = () => {
|
|||
},
|
||||
});
|
||||
}}
|
||||
width={300}
|
||||
/>
|
||||
),
|
||||
description: t('setting.lyricFetchProvider', {
|
||||
|
|
@ -104,8 +105,6 @@ export const LyricSettings = () => {
|
|||
control: (
|
||||
<NumberInput
|
||||
defaultValue={settings.delayMs}
|
||||
step={10}
|
||||
width={100}
|
||||
onBlur={(e) => {
|
||||
const value = Number(e.currentTarget.value);
|
||||
setSettings({
|
||||
|
|
@ -115,6 +114,8 @@ export const LyricSettings = () => {
|
|||
},
|
||||
});
|
||||
}}
|
||||
step={10}
|
||||
width={100}
|
||||
/>
|
||||
),
|
||||
description: t('setting.lyricOffset', {
|
||||
|
|
@ -128,10 +129,10 @@ export const LyricSettings = () => {
|
|||
control: (
|
||||
<Select
|
||||
data={languages}
|
||||
value={settings.translationTargetLanguage}
|
||||
onChange={(value) => {
|
||||
setSettings({ lyrics: { ...settings, translationTargetLanguage: value } });
|
||||
}}
|
||||
value={settings.translationTargetLanguage}
|
||||
/>
|
||||
),
|
||||
description: t('setting.translationTargetLanguage', {
|
||||
|
|
@ -145,10 +146,10 @@ export const LyricSettings = () => {
|
|||
control: (
|
||||
<Select
|
||||
data={['Microsoft Azure', 'Google Cloud']}
|
||||
value={settings.translationApiProvider}
|
||||
onChange={(value) => {
|
||||
setSettings({ lyrics: { ...settings, translationApiProvider: value } });
|
||||
}}
|
||||
value={settings.translationApiProvider}
|
||||
/>
|
||||
),
|
||||
description: t('setting.translationApiProvider', {
|
||||
|
|
@ -161,12 +162,12 @@ export const LyricSettings = () => {
|
|||
{
|
||||
control: (
|
||||
<TextInput
|
||||
value={settings.translationApiKey}
|
||||
onChange={(e) => {
|
||||
setSettings({
|
||||
lyrics: { ...settings, translationApiKey: e.currentTarget.value },
|
||||
});
|
||||
}}
|
||||
value={settings.translationApiKey}
|
||||
/>
|
||||
),
|
||||
description: t('setting.translationApiKey', {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import { Group, Stack } from '@mantine/core';
|
||||
import isElectron from 'is-electron';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RiCloseLine, RiRestartLine } from 'react-icons/ri';
|
||||
|
||||
import {
|
||||
FileInput,
|
||||
Textarea,
|
||||
Text,
|
||||
Select,
|
||||
NumberInput,
|
||||
Switch,
|
||||
Button,
|
||||
FileInput,
|
||||
NumberInput,
|
||||
Select,
|
||||
Switch,
|
||||
Text,
|
||||
Textarea,
|
||||
} from '/@/renderer/components';
|
||||
import {
|
||||
SettingsSection,
|
||||
SettingOption,
|
||||
SettingsSection,
|
||||
} from '/@/renderer/features/settings/components/settings-section';
|
||||
import { usePlayerControls, usePlayerStore, useQueueControls } from '/@/renderer/store';
|
||||
import {
|
||||
SettingsState,
|
||||
usePlaybackSettings,
|
||||
|
|
@ -21,12 +25,9 @@ import {
|
|||
useSettingsStoreActions,
|
||||
} from '/@/renderer/store/settings.store';
|
||||
import { PlaybackType } from '/@/renderer/types';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RiCloseLine, RiRestartLine } from 'react-icons/ri';
|
||||
import { usePlayerControls, usePlayerStore, useQueueControls } from '/@/renderer/store';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
const localSettings = isElectron() ? window.api.localSettings : null;
|
||||
const mpvPlayer = isElectron() ? window.api.mpvPlayer : null;
|
||||
|
||||
export const getMpvSetting = (
|
||||
key: keyof SettingsState['playback']['mpvProperties'],
|
||||
|
|
@ -39,12 +40,12 @@ export const getMpvSetting = (
|
|||
return { 'audio-samplerate': value };
|
||||
case 'gaplessAudio':
|
||||
return { 'gapless-audio': value || 'weak' };
|
||||
case 'replayGainMode':
|
||||
return { replaygain: value || 'no' };
|
||||
case 'replayGainClip':
|
||||
return { 'replaygain-clip': value || 'no' };
|
||||
case 'replayGainFallbackDB':
|
||||
return { 'replaygain-fallback': value };
|
||||
case 'replayGainMode':
|
||||
return { replaygain: value || 'no' };
|
||||
case 'replayGainPreampDB':
|
||||
return { 'replaygain-preamp': value || 0 };
|
||||
default:
|
||||
|
|
@ -150,34 +151,34 @@ export const MpvSettings = () => {
|
|||
control: (
|
||||
<Group spacing="sm">
|
||||
<Button
|
||||
onClick={handleReloadMpv}
|
||||
tooltip={{
|
||||
label: t('common.reload', { postProcess: 'titleCase' }),
|
||||
openDelay: 0,
|
||||
}}
|
||||
variant="subtle"
|
||||
onClick={handleReloadMpv}
|
||||
>
|
||||
<RiRestartLine />
|
||||
</Button>
|
||||
<FileInput
|
||||
onChange={handleSetMpvPath}
|
||||
placeholder={mpvPath}
|
||||
rightSection={
|
||||
mpvPath && (
|
||||
<Button
|
||||
compact
|
||||
onClick={() => handleSetMpvPath(null)}
|
||||
tooltip={{
|
||||
label: t('common.clear', { postProcess: 'titleCase' }),
|
||||
openDelay: 0,
|
||||
}}
|
||||
variant="subtle"
|
||||
onClick={() => handleSetMpvPath(null)}
|
||||
>
|
||||
<RiCloseLine />
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
width={200}
|
||||
onChange={handleSetMpvPath}
|
||||
/>
|
||||
</Group>
|
||||
),
|
||||
|
|
@ -196,14 +197,14 @@ export const MpvSettings = () => {
|
|||
autosize
|
||||
defaultValue={settings.mpvExtraParameters.join('\n')}
|
||||
minRows={4}
|
||||
onBlur={(e) => {
|
||||
handleSetExtraParameters(e.currentTarget.value.split('\n'));
|
||||
}}
|
||||
placeholder={`(${t('setting.mpvExtraParameters', {
|
||||
context: 'help',
|
||||
postProcess: 'sentenceCase',
|
||||
})}):\n--gapless-audio=weak\n--prefetch-playlist=yes`}
|
||||
width={225}
|
||||
onBlur={(e) => {
|
||||
handleSetExtraParameters(e.currentTarget.value.split('\n'));
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
),
|
||||
|
|
@ -272,14 +273,14 @@ export const MpvSettings = () => {
|
|||
defaultValue={settings.mpvProperties.audioSampleRateHz || undefined}
|
||||
max={192000}
|
||||
min={0}
|
||||
placeholder="48000"
|
||||
rightSection="Hz"
|
||||
width={100}
|
||||
onBlur={(e) => {
|
||||
const value = Number(e.currentTarget.value);
|
||||
// Setting a value of `undefined` causes an error for MPV. Use 0 instead
|
||||
handleSetMpvProperty('audioSampleRateHz', value >= 8000 ? value : value);
|
||||
}}
|
||||
placeholder="48000"
|
||||
rightSection="Hz"
|
||||
width={100}
|
||||
/>
|
||||
),
|
||||
description: t('setting.sampleRate', {
|
||||
|
|
@ -343,32 +344,32 @@ export const MpvSettings = () => {
|
|||
/>
|
||||
),
|
||||
description: t('setting.replayGainMode', {
|
||||
ReplayGain: 'ReplayGain',
|
||||
context: 'description',
|
||||
postProcess: 'sentenceCase',
|
||||
ReplayGain: 'ReplayGain',
|
||||
}),
|
||||
note: t('common.restartRequired', { postProcess: 'sentenceCase' }),
|
||||
title: t('setting.replayGainMode', {
|
||||
ReplayGain: 'ReplayGain',
|
||||
postProcess: 'sentenceCase',
|
||||
ReplayGain: 'ReplayGain',
|
||||
}),
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<NumberInput
|
||||
defaultValue={settings.mpvProperties.replayGainPreampDB}
|
||||
width={75}
|
||||
onChange={(e) => handleSetMpvProperty('replayGainPreampDB', e)}
|
||||
width={75}
|
||||
/>
|
||||
),
|
||||
description: t('setting.replayGainMode', {
|
||||
ReplayGain: 'ReplayGain',
|
||||
context: 'description',
|
||||
postProcess: 'sentenceCase',
|
||||
ReplayGain: 'ReplayGain',
|
||||
}),
|
||||
title: t('setting.replayGainPreamp', {
|
||||
ReplayGain: 'ReplayGain',
|
||||
postProcess: 'sentenceCase',
|
||||
ReplayGain: 'ReplayGain',
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
|
@ -381,32 +382,32 @@ export const MpvSettings = () => {
|
|||
/>
|
||||
),
|
||||
description: t('setting.replayGainClipping', {
|
||||
ReplayGain: 'ReplayGain',
|
||||
context: 'description',
|
||||
postProcess: 'sentenceCase',
|
||||
ReplayGain: 'ReplayGain',
|
||||
}),
|
||||
title: t('setting.replayGainClipping', {
|
||||
ReplayGain: 'ReplayGain',
|
||||
postProcess: 'sentenceCase',
|
||||
ReplayGain: 'ReplayGain',
|
||||
}),
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<NumberInput
|
||||
defaultValue={settings.mpvProperties.replayGainFallbackDB}
|
||||
width={75}
|
||||
onBlur={(e) =>
|
||||
handleSetMpvProperty('replayGainFallbackDB', Number(e.currentTarget.value))
|
||||
}
|
||||
width={75}
|
||||
/>
|
||||
),
|
||||
description: t('setting.replayGainFallback', {
|
||||
ReplayGain: 'ReplayGain',
|
||||
postProcess: 'sentenceCase',
|
||||
ReplayGain: 'ReplayGain',
|
||||
}),
|
||||
title: t('setting.replayGainFallback', {
|
||||
ReplayGain: 'ReplayGain',
|
||||
postProcess: 'sentenceCase',
|
||||
ReplayGain: 'ReplayGain',
|
||||
}),
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
import { lazy, Suspense, useMemo } from 'react';
|
||||
import { Stack } from '@mantine/core';
|
||||
import { AudioSettings } from '/@/renderer/features/settings/components/playback/audio-settings';
|
||||
import { ScrobbleSettings } from '/@/renderer/features/settings/components/playback/scrobble-settings';
|
||||
import isElectron from 'is-electron';
|
||||
import { lazy, Suspense, useMemo } from 'react';
|
||||
|
||||
import { AudioSettings } from '/@/renderer/features/settings/components/playback/audio-settings';
|
||||
import { LyricSettings } from '/@/renderer/features/settings/components/playback/lyric-settings';
|
||||
import { ScrobbleSettings } from '/@/renderer/features/settings/components/playback/scrobble-settings';
|
||||
import { TranscodeSettings } from '/@/renderer/features/settings/components/playback/transcode-settings';
|
||||
import { useSettingsStore } from '/@/renderer/store';
|
||||
import { PlaybackType } from '/@/renderer/types';
|
||||
import { TranscodeSettings } from '/@/renderer/features/settings/components/playback/transcode-settings';
|
||||
|
||||
const MpvSettings = lazy(() =>
|
||||
import('/@/renderer/features/settings/components/playback/mpv-settings').then((module) => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { SettingOption, SettingsSection } from '../settings-section';
|
||||
|
||||
import { NumberInput, Slider, Switch } from '/@/renderer/components';
|
||||
import { usePlaybackSettings, useSettingsStoreActions } from '/@/renderer/store/settings.store';
|
||||
import { SettingOption, SettingsSection } from '../settings-section';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const ScrobbleSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
|
|
@ -41,7 +43,6 @@ export const ScrobbleSettings = () => {
|
|||
label={`${settings.scrobble.scrobbleAtPercentage}%`}
|
||||
max={90}
|
||||
min={25}
|
||||
w={100}
|
||||
onChange={(e) => {
|
||||
setSettings({
|
||||
playback: {
|
||||
|
|
@ -53,6 +54,7 @@ export const ScrobbleSettings = () => {
|
|||
},
|
||||
});
|
||||
}}
|
||||
w={100}
|
||||
/>
|
||||
),
|
||||
description: t('setting.minimumScrobblePercentage', {
|
||||
|
|
@ -68,7 +70,6 @@ export const ScrobbleSettings = () => {
|
|||
defaultValue={settings.scrobble.scrobbleAtDuration}
|
||||
max={1200}
|
||||
min={0}
|
||||
width={75}
|
||||
onChange={(e) => {
|
||||
if (e === '') return;
|
||||
setSettings({
|
||||
|
|
@ -81,6 +82,7 @@ export const ScrobbleSettings = () => {
|
|||
},
|
||||
});
|
||||
}}
|
||||
width={75}
|
||||
/>
|
||||
),
|
||||
description: t('setting.minimumScrobbleSeconds', {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { SettingOption, SettingsSection } from '../settings-section';
|
||||
|
||||
import { NumberInput, Switch, TextInput } from '/@/renderer/components';
|
||||
import { usePlaybackSettings, useSettingsStoreActions } from '/@/renderer/store/settings.store';
|
||||
import { SettingOption, SettingsSection } from '../settings-section';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const TranscodeSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
|
|
@ -36,7 +38,6 @@ export const TranscodeSettings = () => {
|
|||
aria-label="Transcode bitrate"
|
||||
defaultValue={transcode.bitrate}
|
||||
min={0}
|
||||
w={100}
|
||||
onBlur={(e) => {
|
||||
setTranscodingConfig({
|
||||
...transcode,
|
||||
|
|
@ -45,6 +46,7 @@ export const TranscodeSettings = () => {
|
|||
: undefined,
|
||||
});
|
||||
}}
|
||||
w={100}
|
||||
/>
|
||||
),
|
||||
description: t('setting.transcodeBitrate', {
|
||||
|
|
@ -60,14 +62,14 @@ export const TranscodeSettings = () => {
|
|||
<TextInput
|
||||
aria-label="transcoding format"
|
||||
defaultValue={transcode.format}
|
||||
placeholder="mp3, opus"
|
||||
width={100}
|
||||
onBlur={(e) => {
|
||||
setTranscodingConfig({
|
||||
...transcode,
|
||||
format: e.currentTarget.value || undefined,
|
||||
});
|
||||
}}
|
||||
placeholder="mp3, opus"
|
||||
width={100}
|
||||
/>
|
||||
),
|
||||
description: t('setting.transcodeFormat', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue