mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
Fix action required for mpv
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import isElectron from 'is-electron';
|
import isElectron from 'is-electron';
|
||||||
import { FileInput, Text, Button } from '@/renderer/components';
|
import { FileInput, Text, Button } from '@/renderer/components';
|
||||||
import { settings } from '@/renderer/features/settings';
|
import { localSettings } from '@/renderer/features/settings';
|
||||||
|
|
||||||
export const MpvRequired = () => {
|
export const MpvRequired = () => {
|
||||||
const [mpvPath, setMpvPath] = useState('');
|
const [mpvPath, setMpvPath] = useState('');
|
||||||
const handleSetMpvPath = (e: File) => {
|
const handleSetMpvPath = (e: File) => {
|
||||||
settings.set('mpv_path', e.path);
|
localSettings.set('mpv_path', e.path);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getMpvPath = async () => {
|
const getMpvPath = async () => {
|
||||||
if (!isElectron()) return setMpvPath('');
|
if (!isElectron()) return setMpvPath('');
|
||||||
const mpvPath = await settings.get('mpv_path');
|
const mpvPath = await localSettings.get('mpv_path');
|
||||||
return setMpvPath(mpvPath);
|
return setMpvPath(mpvPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ export const MpvRequired = () => {
|
|||||||
below.
|
below.
|
||||||
</Text>
|
</Text>
|
||||||
<FileInput placeholder={mpvPath} onChange={handleSetMpvPath} />
|
<FileInput placeholder={mpvPath} onChange={handleSetMpvPath} />
|
||||||
<Button onClick={() => settings.restart()}>Restart</Button>
|
<Button onClick={() => localSettings.restart()}>Restart</Button>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { ActionRequiredContainer } from '@/renderer/features/action-required/com
|
|||||||
import { MpvRequired } from '@/renderer/features/action-required/components/mpv-required';
|
import { MpvRequired } from '@/renderer/features/action-required/components/mpv-required';
|
||||||
import { ServerCredentialRequired } from '@/renderer/features/action-required/components/server-credential-required';
|
import { ServerCredentialRequired } from '@/renderer/features/action-required/components/server-credential-required';
|
||||||
import { ServerRequired } from '@/renderer/features/action-required/components/server-required';
|
import { ServerRequired } from '@/renderer/features/action-required/components/server-required';
|
||||||
import { settings } from '@/renderer/features/settings';
|
import { localSettings } from '@/renderer/features/settings';
|
||||||
import { AnimatedPage, useServerCredential } from '@/renderer/features/shared';
|
import { AnimatedPage, useServerCredential } from '@/renderer/features/shared';
|
||||||
import { AppRoute } from '@/renderer/router/routes';
|
import { AppRoute } from '@/renderer/router/routes';
|
||||||
import { useAuthStore } from '@/renderer/store';
|
import { useAuthStore } from '@/renderer/store';
|
||||||
@@ -23,7 +23,7 @@ export const ActionRequiredRoute = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getMpvPath = async () => {
|
const getMpvPath = async () => {
|
||||||
if (!isElectron()) return setIsMpvRequired(false);
|
if (!isElectron()) return setIsMpvRequired(false);
|
||||||
const mpvPath = await settings.get('mpv_path');
|
const mpvPath = await localSettings.get('mpv_path');
|
||||||
return setIsMpvRequired(!mpvPath);
|
return setIsMpvRequired(!mpvPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import isElectron from 'is-electron';
|
import isElectron from 'is-electron';
|
||||||
import { Navigate, Outlet, useLocation } from 'react-router-dom';
|
import { Navigate, Outlet, useLocation } from 'react-router-dom';
|
||||||
import { settings } from '@/renderer/features/settings';
|
import { localSettings } from '@/renderer/features/settings';
|
||||||
import { useServerCredential } from '@/renderer/features/shared';
|
import { useServerCredential } from '@/renderer/features/shared';
|
||||||
import { AppRoute } from '@/renderer/router/routes';
|
import { AppRoute } from '@/renderer/router/routes';
|
||||||
import { useAuthStore } from '@/renderer/store';
|
import { useAuthStore } from '@/renderer/store';
|
||||||
@@ -24,7 +24,7 @@ export const AppOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getMpvPath = async () => {
|
const getMpvPath = async () => {
|
||||||
if (!isElectron()) return setIsMpvRequired(false);
|
if (!isElectron()) return setIsMpvRequired(false);
|
||||||
const mpvPath = await settings.get('mpv_path');
|
const mpvPath = await localSettings.get('mpv_path');
|
||||||
return setIsMpvRequired(!mpvPath);
|
return setIsMpvRequired(!mpvPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -34,10 +34,6 @@ export const AppOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
|||||||
const actions = [isServerRequired, isCredentialRequired, isMpvRequired];
|
const actions = [isServerRequired, isCredentialRequired, isMpvRequired];
|
||||||
const actionRequired = actions.some((c) => c);
|
const actionRequired = actions.some((c) => c);
|
||||||
|
|
||||||
if (isAuthenticated) {
|
|
||||||
return <Outlet />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isAuthenticated && actionRequired) {
|
if (isAuthenticated && actionRequired) {
|
||||||
return (
|
return (
|
||||||
<Navigate
|
<Navigate
|
||||||
@@ -48,6 +44,10 @@ export const AppOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isAuthenticated) {
|
||||||
|
return <Outlet />;
|
||||||
|
}
|
||||||
|
|
||||||
logout();
|
logout();
|
||||||
return <Navigate replace state={{ from: location }} to={redirectTo} />;
|
return <Navigate replace state={{ from: location }} to={redirectTo} />;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user