mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-16 13:40:24 +02:00
Update store/routes
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
||||
import { Routes, Route } from 'react-router-dom';
|
||||
import { LibraryAlbumsRoute } from '@/renderer/features/library/routes/LibraryAlbumsRoute';
|
||||
import { LibraryArtistsRoute } from '@/renderer/features/library/routes/LibraryArtistsRoute';
|
||||
import { LibraryRoute } from '@/renderer/features/library/routes/LibraryRoute';
|
||||
import { AuthOutlet } from '@/renderer/router/auth-outlet';
|
||||
import { PrivateOutlet } from '@/renderer/router/private-outlet';
|
||||
import { LoginRoute } from '../features/auth';
|
||||
import { DashboardRoute } from '../features/dashboard';
|
||||
import { LibraryAlbumsRoute } from '../features/library/routes/LibraryAlbumsRoute';
|
||||
import { LibraryArtistsRoute } from '../features/library/routes/LibraryArtistsRoute';
|
||||
import { LibraryRoute } from '../features/library/routes/LibraryRoute';
|
||||
import { ServersRoute } from '../features/servers';
|
||||
import { AuthLayout, DefaultLayout } from '../layouts';
|
||||
import { AuthOutlet } from './outlets/AuthOutlet';
|
||||
import { PrivateOutlet } from './outlets/PrivateOutlet';
|
||||
import { AppRoute } from './utils/routes';
|
||||
import { AppRoute } from './routes';
|
||||
|
||||
export const AppRouter = () => {
|
||||
return (
|
||||
@@ -25,7 +24,6 @@ export const AppRouter = () => {
|
||||
>
|
||||
<Route element={<DefaultLayout />}>
|
||||
<Route element={<DashboardRoute />} path={AppRoute.HOME} />
|
||||
<Route element={<ServersRoute />} path={AppRoute.SERVERS} />
|
||||
<Route element={<></>} path={AppRoute.SEARCH} />
|
||||
|
||||
<Route element={<LibraryRoute />} path={AppRoute.LIBRARY} />
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Navigate, Outlet, useLocation } from 'react-router-dom';
|
||||
import { useAuthStore } from '../../store';
|
||||
import { useAuthStore } from '../store';
|
||||
|
||||
interface AuthOutletProps {
|
||||
redirectTo: string;
|
||||
@@ -7,7 +7,7 @@ interface AuthOutletProps {
|
||||
|
||||
export const AuthOutlet = ({ redirectTo }: AuthOutletProps) => {
|
||||
const location = useLocation();
|
||||
const isAuthenticated = useAuthStore((state) => state.isAuthenticated);
|
||||
const isAuthenticated = useAuthStore((state) => !!state.accessToken);
|
||||
|
||||
if (isAuthenticated) {
|
||||
return <Navigate replace state={{ from: location }} to={redirectTo} />;
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { Navigate, Outlet, useLocation } from 'react-router-dom';
|
||||
import { useAuthStore } from '../../store';
|
||||
import { useAuthStore } from '@/renderer/store';
|
||||
|
||||
interface PrivateOutletProps {
|
||||
redirectTo: string;
|
||||
@@ -7,7 +7,7 @@ interface PrivateOutletProps {
|
||||
|
||||
export const PrivateOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
||||
const location = useLocation();
|
||||
const isAuthenticated = useAuthStore((state) => state.isAuthenticated);
|
||||
const isAuthenticated = useAuthStore((state) => !!state.accessToken);
|
||||
|
||||
if (isAuthenticated) {
|
||||
return <Outlet />;
|
||||
Reference in New Issue
Block a user