mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 04:20:07 +02:00
split lyrics settings by key (#1389)
This commit is contained in:
@@ -21,20 +21,22 @@ export const LyricSettings = () => {
|
||||
const settings = useLyricsSettings();
|
||||
const { setSettings } = useSettingsStoreActions();
|
||||
|
||||
const updateSetting = (updates: Partial<typeof settings>) => {
|
||||
setSettings({
|
||||
lyrics: {
|
||||
...settings,
|
||||
...updates,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const lyricOptions: SettingOption[] = [
|
||||
{
|
||||
control: (
|
||||
<Switch
|
||||
aria-label="Follow lyrics"
|
||||
defaultChecked={settings.follow}
|
||||
onChange={(e) => {
|
||||
setSettings({
|
||||
lyrics: {
|
||||
...settings,
|
||||
follow: e.currentTarget.checked,
|
||||
},
|
||||
});
|
||||
}}
|
||||
onChange={(e) => updateSetting({ follow: e.currentTarget.checked })}
|
||||
/>
|
||||
),
|
||||
description: t('setting.followLyric', {
|
||||
@@ -48,14 +50,7 @@ export const LyricSettings = () => {
|
||||
<Switch
|
||||
aria-label="Prefer local lyrics"
|
||||
defaultChecked={settings.preferLocalLyrics}
|
||||
onChange={(e) => {
|
||||
setSettings({
|
||||
lyrics: {
|
||||
...settings,
|
||||
preferLocalLyrics: e.currentTarget.checked,
|
||||
},
|
||||
});
|
||||
}}
|
||||
onChange={(e) => updateSetting({ preferLocalLyrics: e.currentTarget.checked })}
|
||||
/>
|
||||
),
|
||||
description: t('setting.preferLocalLyrics', {
|
||||
@@ -70,14 +65,7 @@ export const LyricSettings = () => {
|
||||
<Switch
|
||||
aria-label="Enable fetching lyrics"
|
||||
defaultChecked={settings.fetch}
|
||||
onChange={(e) => {
|
||||
setSettings({
|
||||
lyrics: {
|
||||
...settings,
|
||||
fetch: e.currentTarget.checked,
|
||||
},
|
||||
});
|
||||
}}
|
||||
onChange={(e) => updateSetting({ fetch: e.currentTarget.checked })}
|
||||
/>
|
||||
),
|
||||
description: t('setting.lyricFetch', {
|
||||
@@ -96,12 +84,7 @@ export const LyricSettings = () => {
|
||||
defaultValue={settings.sources}
|
||||
onChange={(e: string[]) => {
|
||||
localSettings?.set('lyrics', e);
|
||||
setSettings({
|
||||
lyrics: {
|
||||
...settings,
|
||||
sources: e.map((source) => source as LyricSource),
|
||||
},
|
||||
});
|
||||
updateSetting({ sources: e.map((source) => source as LyricSource) });
|
||||
}}
|
||||
width={300}
|
||||
/>
|
||||
@@ -120,12 +103,7 @@ export const LyricSettings = () => {
|
||||
defaultChecked={settings.enableNeteaseTranslation}
|
||||
onChange={(e) => {
|
||||
const isChecked = e.currentTarget.checked;
|
||||
setSettings({
|
||||
lyrics: {
|
||||
...settings,
|
||||
enableNeteaseTranslation: e.currentTarget.checked,
|
||||
},
|
||||
});
|
||||
updateSetting({ enableNeteaseTranslation: isChecked });
|
||||
localSettings?.set('enableNeteaseTranslation', isChecked);
|
||||
}}
|
||||
/>
|
||||
@@ -143,12 +121,7 @@ export const LyricSettings = () => {
|
||||
defaultValue={settings.delayMs}
|
||||
onBlur={(e) => {
|
||||
const value = Number(e.currentTarget.value);
|
||||
setSettings({
|
||||
lyrics: {
|
||||
...settings,
|
||||
delayMs: value,
|
||||
},
|
||||
});
|
||||
updateSetting({ delayMs: value });
|
||||
}}
|
||||
step={10}
|
||||
width={100}
|
||||
@@ -166,7 +139,7 @@ export const LyricSettings = () => {
|
||||
<Select
|
||||
data={languages}
|
||||
onChange={(value) => {
|
||||
setSettings({ lyrics: { ...settings, translationTargetLanguage: value } });
|
||||
updateSetting({ translationTargetLanguage: value });
|
||||
}}
|
||||
value={settings.translationTargetLanguage}
|
||||
/>
|
||||
@@ -184,7 +157,7 @@ export const LyricSettings = () => {
|
||||
clearable
|
||||
data={['Microsoft Azure', 'Google Cloud']}
|
||||
onChange={(value) => {
|
||||
setSettings({ lyrics: { ...settings, translationApiProvider: value } });
|
||||
updateSetting({ translationApiProvider: value });
|
||||
}}
|
||||
value={settings.translationApiProvider}
|
||||
/>
|
||||
@@ -200,9 +173,7 @@ export const LyricSettings = () => {
|
||||
control: (
|
||||
<TextInput
|
||||
onChange={(e) => {
|
||||
setSettings({
|
||||
lyrics: { ...settings, translationApiKey: e.currentTarget.value },
|
||||
});
|
||||
updateSetting({ translationApiKey: e.currentTarget.value });
|
||||
}}
|
||||
value={settings.translationApiKey}
|
||||
/>
|
||||
@@ -219,14 +190,9 @@ export const LyricSettings = () => {
|
||||
<Switch
|
||||
aria-label="Enable auto translation"
|
||||
defaultChecked={settings.enableAutoTranslation}
|
||||
onChange={(e) => {
|
||||
setSettings({
|
||||
lyrics: {
|
||||
...settings,
|
||||
enableAutoTranslation: e.currentTarget.checked,
|
||||
},
|
||||
});
|
||||
}}
|
||||
onChange={(e) =>
|
||||
updateSetting({ enableAutoTranslation: e.currentTarget.checked })
|
||||
}
|
||||
/>
|
||||
),
|
||||
description: t('setting.enableAutoTranslation', {
|
||||
|
||||
Reference in New Issue
Block a user