实现快传,完善快传和网盘的功能,实现文件的互传等一系列功能

This commit is contained in:
yoyuzh
2026-03-20 14:16:18 +08:00
parent 944ab6dbf8
commit 43358e29d7
109 changed files with 5237 additions and 2465 deletions

View File

@@ -1,19 +1,34 @@
import React, { Suspense } from 'react';
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import { BrowserRouter, HashRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom';
import { Layout } from './components/layout/Layout';
import { useAuth } from './auth/AuthProvider';
import Login from './pages/Login';
import Overview from './pages/Overview';
import Files from './pages/Files';
import School from './pages/School';
import Transfer from './pages/Transfer';
import FileShare from './pages/FileShare';
import Games from './pages/Games';
import { FILE_SHARE_ROUTE_PREFIX } from './lib/file-share';
import {
getTransferRouterMode,
LEGACY_PUBLIC_TRANSFER_ROUTE,
PUBLIC_TRANSFER_ROUTE,
} from './lib/transfer-links';
const PortalAdminApp = React.lazy(() => import('./admin/AdminApp'));
function LegacyTransferRedirect() {
const location = useLocation();
return <Navigate to={`${PUBLIC_TRANSFER_ROUTE}${location.search}`} replace />;
}
function AppRoutes() {
const { ready, session } = useAuth();
const location = useLocation();
const isPublicTransferRoute = location.pathname === PUBLIC_TRANSFER_ROUTE || location.pathname === LEGACY_PUBLIC_TRANSFER_ROUTE;
const isPublicFileShareRoute = location.pathname.startsWith(`${FILE_SHARE_ROUTE_PREFIX}/`);
if (!ready) {
if (!ready && !isPublicTransferRoute && !isPublicFileShareRoute) {
return (
<div className="min-h-screen flex items-center justify-center bg-[#07101D] text-slate-300">
...
@@ -25,6 +40,12 @@ function AppRoutes() {
return (
<Routes>
<Route
path={PUBLIC_TRANSFER_ROUTE}
element={isAuthenticated ? <Layout><Transfer /></Layout> : <Transfer />}
/>
<Route path={`${FILE_SHARE_ROUTE_PREFIX}/:token`} element={<FileShare />} />
<Route path={LEGACY_PUBLIC_TRANSFER_ROUTE} element={<LegacyTransferRedirect />} />
<Route
path="/login"
element={isAuthenticated ? <Navigate to="/overview" replace /> : <Login />}
@@ -36,7 +57,6 @@ function AppRoutes() {
<Route index element={<Navigate to="/overview" replace />} />
<Route path="overview" element={<Overview />} />
<Route path="files" element={<Files />} />
<Route path="school" element={<School />} />
<Route path="games" element={<Games />} />
</Route>
<Route
@@ -66,9 +86,11 @@ function AppRoutes() {
}
export default function App() {
const Router = getTransferRouterMode() === 'hash' ? HashRouter : BrowserRouter;
return (
<BrowserRouter>
<Router>
<AppRoutes />
</BrowserRouter>
</Router>
);
}