mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 02:13:33 +00:00
Remove "disable mpv" setting and desktop requirement
This commit is contained in:
parent
eb4d099804
commit
ff4ce89bc9
5 changed files with 5 additions and 70 deletions
|
|
@ -1,44 +1,22 @@
|
|||
import { useMemo } from 'react';
|
||||
import { Center, Group, Stack } from '@mantine/core';
|
||||
import isElectron from 'is-electron';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RiCheckFill } from 'react-icons/ri';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Button, PageHeader, Text } from '/@/renderer/components';
|
||||
import { ActionRequiredContainer } from '/@/renderer/features/action-required/components/action-required-container';
|
||||
import { MpvRequired } from '/@/renderer/features/action-required/components/mpv-required';
|
||||
import { ServerCredentialRequired } from '/@/renderer/features/action-required/components/server-credential-required';
|
||||
import { ServerRequired } from '/@/renderer/features/action-required/components/server-required';
|
||||
import { AnimatedPage } from '/@/renderer/features/shared';
|
||||
import { AppRoute } from '/@/renderer/router/routes';
|
||||
import { useCurrentServer } from '/@/renderer/store';
|
||||
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
|
||||
const ActionRequiredRoute = () => {
|
||||
const { t } = useTranslation();
|
||||
const currentServer = useCurrentServer();
|
||||
const isServerRequired = !currentServer;
|
||||
const isCredentialRequired = false;
|
||||
|
||||
const isMpvRequired = useMemo(() => {
|
||||
if (!localSettings) return false;
|
||||
|
||||
const mpvPath = localSettings.get('mpv_path');
|
||||
if (mpvPath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const mpvDisabled = localSettings.get('disable_mpv');
|
||||
return !mpvDisabled;
|
||||
}, []);
|
||||
|
||||
const checks = [
|
||||
{
|
||||
component: <MpvRequired />,
|
||||
title: t('error.mpvRequired', { postProcess: 'sentenceCase' }),
|
||||
valid: !isMpvRequired,
|
||||
},
|
||||
{
|
||||
component: <ServerCredentialRequired />,
|
||||
title: t('error.credentialsRequired', { postProcess: 'sentenceCase' }),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
import { SelectItem } from '@mantine/core';
|
||||
import isElectron from 'is-electron';
|
||||
import { Checkbox, Select, Slider, toast } from '/@/renderer/components';
|
||||
import { Select, Slider, toast } from '/@/renderer/components';
|
||||
import {
|
||||
SettingsSection,
|
||||
SettingOption,
|
||||
|
|
@ -12,15 +12,12 @@ import { PlaybackType, PlayerStatus, PlaybackStyle, CrossfadeStyle } from '/@/re
|
|||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const mpvPlayer = isElectron() ? window.electron.mpvPlayer : null;
|
||||
const localSettings = isElectron() ? window.electron.localSettings : null;
|
||||
|
||||
const getAudioDevice = async () => {
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
return (devices || []).filter((dev: MediaDeviceInfo) => dev.kind === 'audiooutput');
|
||||
};
|
||||
|
||||
const initialDisable = (localSettings?.get('disable_mpv') as boolean | undefined) ?? false;
|
||||
|
||||
export const AudioSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const settings = usePlaybackSettings();
|
||||
|
|
@ -28,18 +25,6 @@ export const AudioSettings = () => {
|
|||
const status = useCurrentStatus();
|
||||
|
||||
const [audioDevices, setAudioDevices] = useState<SelectItem[]>([]);
|
||||
const [disableMpv, setDisableMpv] = useState(initialDisable);
|
||||
|
||||
const handleSetDisableMpv = (disabled: boolean) => {
|
||||
setDisableMpv(disabled);
|
||||
localSettings?.set('disable_mpv', disabled);
|
||||
|
||||
if (disabled) {
|
||||
setSettings({
|
||||
playback: { ...settings, type: disabled ? PlaybackType.WEB : PlaybackType.LOCAL },
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const getAudioDevices = () => {
|
||||
|
|
@ -60,18 +45,6 @@ export const AudioSettings = () => {
|
|||
}, [settings.type, t]);
|
||||
|
||||
const audioOptions: SettingOption[] = [
|
||||
{
|
||||
control: (
|
||||
<Checkbox
|
||||
defaultChecked={disableMpv}
|
||||
onChange={(e) => handleSetDisableMpv(e.currentTarget.checked)}
|
||||
/>
|
||||
),
|
||||
description: t('setting.disableMpv', { context: 'description' }),
|
||||
isHidden: !isElectron(),
|
||||
note: t('common.restartRequired', { postProcess: 'sentenceCase' }),
|
||||
title: t('setting.disableMpv'),
|
||||
},
|
||||
{
|
||||
control: (
|
||||
<Select
|
||||
|
|
@ -98,7 +71,7 @@ export const AudioSettings = () => {
|
|||
context: 'description',
|
||||
postProcess: 'sentenceCase',
|
||||
}),
|
||||
isHidden: !isElectron() || initialDisable || disableMpv,
|
||||
isHidden: !isElectron(),
|
||||
note:
|
||||
status === PlayerStatus.PLAYING
|
||||
? t('common.playerMustBePaused', { postProcess: 'sentenceCase' })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue