diff --git a/src/App.js b/src/App.js index bb7b11fb..c5a9da3e 100755 --- a/src/App.js +++ b/src/App.js @@ -9,36 +9,14 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Visionware. */ -import React, { Suspense, useEffect } from "react"; +import React, { useEffect } from "react"; import { ChakraProvider } from '@chakra-ui/react'; -import { Routes, Route, Navigate } from "react-router-dom"; - -// Chakra imports -import { Box, useColorMode } from '@chakra-ui/react'; // Core Components import theme from "theme/theme.js"; -// Loading Component -import PageLoader from "components/Loading/PageLoader"; - -// Layouts - 保持同步导入(需要立即加载) -import Auth from "layouts/Auth"; -import HomeLayout from "layouts/Home"; -import MainLayout from "layouts/MainLayout"; - -// ⚡ 使用 React.lazy() 实现路由懒加载 -// 首屏不需要的组件按需加载,大幅减少初始 JS 包大小 -const Community = React.lazy(() => import("views/Community")); -const LimitAnalyse = React.lazy(() => import("views/LimitAnalyse")); -const ForecastReport = React.lazy(() => import("views/Company/ForecastReport")); -const ConceptCenter = React.lazy(() => import("views/Concept")); -const FinancialPanorama = React.lazy(() => import("views/Company/FinancialPanorama")); -const CompanyIndex = React.lazy(() => import("views/Company")); -const MarketDataView = React.lazy(() => import("views/Company/MarketDataView")); -const StockOverview = React.lazy(() => import("views/StockOverview")); -const EventDetail = React.lazy(() => import("views/EventDetail")); -const TradingSimulation = React.lazy(() => import("views/TradingSimulation")); +// Routes +import AppRoutes from './routes'; // Redux import { Provider as ReduxProvider } from 'react-redux'; @@ -46,11 +24,10 @@ import { store } from './store'; // Contexts import { AuthProvider } from "contexts/AuthContext"; +import { AuthModalProvider } from "contexts/AuthModalContext"; import { NotificationProvider, useNotification } from "contexts/NotificationContext"; // Components -import ProtectedRoute from "components/ProtectedRoute"; -import ProtectedRouteRedirect from "components/ProtectedRouteRedirect"; import ErrorBoundary from "components/ErrorBoundary"; import AuthModalManager from "components/Auth/AuthModalManager"; import NotificationContainer from "components/NotificationContainer"; @@ -109,7 +86,6 @@ function ConnectionStatusBarWrapper() { } function AppContent() { - const { colorMode } = useColorMode(); const dispatch = useDispatch(); // 🎯 PostHog Redux 初始化 @@ -119,157 +95,16 @@ function AppContent() { }, [dispatch]); return ( - + <> {/* Socket 连接状态条 */} {/* 路由切换时自动滚动到顶部 */} - - {/* 带导航栏的主布局 - 所有需要导航栏的页面都在这里 */} - {/* MainLayout 内部有 Suspense,确保导航栏始终可见 */} - }> - {/* 首页路由 */} - } /> - {/* Community页面路由 - 需要登录 */} - - - - } - /> - - {/* 概念中心路由 - 需要登录 */} - - - - } - /> - - - - } - /> - - {/* 股票概览页面路由 - 需要登录 */} - - - - } - /> - - - - } - /> - - {/* Limit Analyse页面路由 - 需要登录 */} - - - - } - /> - - {/* 模拟盘交易系统路由 - 需要登录 */} - - - - } - /> - - {/* 事件详情独立页面路由 - 需要登录(跳转模式) */} - - - - } - /> - - {/* 公司相关页面 */} - {/* 财报预测 - 需要登录(跳转模式) */} - - - - } - /> - - {/* 财务全景 - 需要登录(弹窗模式) */} - - - - } - /> - - {/* 公司页面 - 需要登录(弹窗模式) */} - - - - } - /> - - {/* 公司详情 - 需要登录(跳转模式) */} - - - - } - /> - - {/* 市场数据 - 需要登录(弹窗模式) */} - - - - } - /> - - - {/* 认证页面路由 - 不使用 MainLayout */} - } /> - - {/* 默认重定向到首页 */} - } /> - - {/* 404 页面 */} - } /> - - + {/* 应用路由 - 从 routes/index.js 导入 */} + + ); }