mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 10:23:33 +00:00
only show translation when api key and provider are picked, and fix eslint vscode
This commit is contained in:
parent
c81bd93d04
commit
2cf0027419
4 changed files with 19 additions and 9 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -13,10 +13,9 @@
|
||||||
".prettierrc": "jsonc",
|
".prettierrc": "jsonc",
|
||||||
".eslintignore": "ignore"
|
".eslintignore": "ignore"
|
||||||
},
|
},
|
||||||
"eslint.validate": ["typescript"],
|
"eslint.validate": ["typescript", "typescriptreact"],
|
||||||
"eslint.workingDirectories": [
|
"eslint.workingDirectories": [
|
||||||
{ "directory": "./", "changeProcessCWD": true },
|
{ "directory": "./", "changeProcessCWD": true },
|
||||||
{ "directory": "./server", "changeProcessCWD": true }
|
|
||||||
],
|
],
|
||||||
"typescript.tsserver.experimental.enableProjectDiagnostics": false,
|
"typescript.tsserver.experimental.enableProjectDiagnostics": false,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ interface LyricsActionsProps {
|
||||||
onRemoveLyric: () => void;
|
onRemoveLyric: () => void;
|
||||||
onResetLyric: () => void;
|
onResetLyric: () => void;
|
||||||
onSearchOverride: (params: LyricsOverride) => void;
|
onSearchOverride: (params: LyricsOverride) => void;
|
||||||
onTranslateLyric: () => void;
|
onTranslateLyric?: () => void;
|
||||||
setIndex: (idx: number) => void;
|
setIndex: (idx: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +135,7 @@ export const LyricsActions = ({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ position: 'absolute', right: 0, top: -50 }}>
|
<div style={{ position: 'absolute', right: 0, top: -50 }}>
|
||||||
{isDesktop && sources.length ? (
|
{isDesktop && sources.length && onTranslateLyric ? (
|
||||||
<Button
|
<Button
|
||||||
disabled={isActionsDisabled}
|
disabled={isActionsDisabled}
|
||||||
onClick={onTranslateLyric}
|
onClick={onTranslateLyric}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ import { FullLyricsMetadata, LyricSource, LyricsOverride } from '/@/shared/types
|
||||||
|
|
||||||
export const Lyrics = () => {
|
export const Lyrics = () => {
|
||||||
const currentSong = useCurrentSong();
|
const currentSong = useCurrentSong();
|
||||||
const lyricsSettings = useLyricsSettings();
|
const { translationApiKey, translationApiProvider, translationTargetLanguage } =
|
||||||
|
useLyricsSettings();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [index, setIndex] = useState(0);
|
const [index, setIndex] = useState(0);
|
||||||
const [translatedLyrics, setTranslatedLyrics] = useState<null | string>(null);
|
const [translatedLyrics, setTranslatedLyrics] = useState<null | string>(null);
|
||||||
|
|
@ -97,8 +98,6 @@ export const Lyrics = () => {
|
||||||
const originalLyrics = Array.isArray(lyrics.lyrics)
|
const originalLyrics = Array.isArray(lyrics.lyrics)
|
||||||
? lyrics.lyrics.map(([, line]) => line).join('\n')
|
? lyrics.lyrics.map(([, line]) => line).join('\n')
|
||||||
: lyrics.lyrics;
|
: lyrics.lyrics;
|
||||||
const { translationApiKey, translationApiProvider, translationTargetLanguage } =
|
|
||||||
lyricsSettings;
|
|
||||||
const TranslatedText: null | string = await translateLyrics(
|
const TranslatedText: null | string = await translateLyrics(
|
||||||
originalLyrics,
|
originalLyrics,
|
||||||
translationApiKey,
|
translationApiKey,
|
||||||
|
|
@ -107,7 +106,14 @@ export const Lyrics = () => {
|
||||||
);
|
);
|
||||||
setTranslatedLyrics(TranslatedText);
|
setTranslatedLyrics(TranslatedText);
|
||||||
setShowTranslation(true);
|
setShowTranslation(true);
|
||||||
}, [lyrics, lyricsSettings, translatedLyrics, showTranslation]);
|
}, [
|
||||||
|
translatedLyrics,
|
||||||
|
lyrics,
|
||||||
|
translationApiKey,
|
||||||
|
translationApiProvider,
|
||||||
|
translationTargetLanguage,
|
||||||
|
showTranslation,
|
||||||
|
]);
|
||||||
|
|
||||||
const { isInitialLoading: isOverrideLoading } = useSongLyricsByRemoteId({
|
const { isInitialLoading: isOverrideLoading } = useSongLyricsByRemoteId({
|
||||||
options: {
|
options: {
|
||||||
|
|
@ -194,7 +200,11 @@ export const Lyrics = () => {
|
||||||
onRemoveLyric={handleOnRemoveLyric}
|
onRemoveLyric={handleOnRemoveLyric}
|
||||||
onResetLyric={handleOnResetLyric}
|
onResetLyric={handleOnResetLyric}
|
||||||
onSearchOverride={handleOnSearchOverride}
|
onSearchOverride={handleOnSearchOverride}
|
||||||
onTranslateLyric={handleOnTranslateLyric}
|
onTranslateLyric={
|
||||||
|
translationApiProvider && translationApiKey
|
||||||
|
? handleOnTranslateLyric
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
setIndex={setIndex}
|
setIndex={setIndex}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -181,6 +181,7 @@ export const LyricSettings = () => {
|
||||||
{
|
{
|
||||||
control: (
|
control: (
|
||||||
<Select
|
<Select
|
||||||
|
clearable
|
||||||
data={['Microsoft Azure', 'Google Cloud']}
|
data={['Microsoft Azure', 'Google Cloud']}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
setSettings({ lyrics: { ...settings, translationApiProvider: value } });
|
setSettings({ lyrics: { ...settings, translationApiProvider: value } });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue