From a4abe6e229bb4608760c598e30de4125bf028bbe Mon Sep 17 00:00:00 2001 From: Jerry Date: Wed, 4 Jun 2025 18:41:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/App.jsx | 19 ++++--- .../pages/welcome/DashboardCard.jsx | 10 ++++ .../components/pages/welcome/GithubCard.jsx | 14 +++++ .../pages/welcome/WelcomeContent.jsx | 22 ++------ .../src/components/system/layout/AppShell.jsx | 22 ++++++++ .../system/layout/GithubNavTransition.jsx | 53 +++++++++++++++++++ .../system/layout/PageTransition.jsx | 13 +++++ src/frontend/src/constants/keep | 0 src/frontend/src/constants/routes/routes.jsx | 13 +++++ src/frontend/src/index.js | 5 +- src/frontend/src/pages/Welcome.jsx | 4 ++ 11 files changed, 146 insertions(+), 29 deletions(-) create mode 100644 src/frontend/src/components/pages/welcome/DashboardCard.jsx create mode 100644 src/frontend/src/components/pages/welcome/GithubCard.jsx create mode 100644 src/frontend/src/components/system/layout/AppShell.jsx create mode 100644 src/frontend/src/components/system/layout/GithubNavTransition.jsx create mode 100644 src/frontend/src/components/system/layout/PageTransition.jsx delete mode 100644 src/frontend/src/constants/keep create mode 100644 src/frontend/src/constants/routes/routes.jsx diff --git a/src/frontend/src/App.jsx b/src/frontend/src/App.jsx index 5322ded..8bf93dd 100644 --- a/src/frontend/src/App.jsx +++ b/src/frontend/src/App.jsx @@ -1,14 +1,17 @@ -import { Route, Routes } from 'react-router-dom'; -import Welcome from '@/pages/Welcome'; -import Dashboard from '@/pages/Dashboard'; +import { BrowserRouter, Routes, Route } from 'react-router-dom'; +import AppShell from '@/components/system/layout/AppShell'; +import buildRoutes from '@/constants/routes/routes'; const App = () => { return ( - - } /> - } /> - + + + }> + {buildRoutes()} + + + ); }; -export default App; \ No newline at end of file +export default App; diff --git a/src/frontend/src/components/pages/welcome/DashboardCard.jsx b/src/frontend/src/components/pages/welcome/DashboardCard.jsx new file mode 100644 index 0000000..67bed13 --- /dev/null +++ b/src/frontend/src/components/pages/welcome/DashboardCard.jsx @@ -0,0 +1,10 @@ +import manageIcon from '@/resources/welcome/image/setting.svg'; +import MotionCard from '@/components/ui/MotionCard'; +import { useNavigate } from 'react-router-dom'; + +const DashboardCard = () => { + const navigate = useNavigate(); + return navigate('/dashboard')} />; +}; + +export default DashboardCard; diff --git a/src/frontend/src/components/pages/welcome/GithubCard.jsx b/src/frontend/src/components/pages/welcome/GithubCard.jsx new file mode 100644 index 0000000..86f4f77 --- /dev/null +++ b/src/frontend/src/components/pages/welcome/GithubCard.jsx @@ -0,0 +1,14 @@ +import githubIcon from '@/resources/welcome/image/github.svg'; +import MotionCard from '@/components/ui/MotionCard'; + +const GithubCard = () => { + return ( + window.open('https://github.com/Jerryplusy/AI-powered-switches', '_blank')} + /> + ); +}; + +export default GithubCard; diff --git a/src/frontend/src/components/pages/welcome/WelcomeContent.jsx b/src/frontend/src/components/pages/welcome/WelcomeContent.jsx index aa09ef6..48471e5 100644 --- a/src/frontend/src/components/pages/welcome/WelcomeContent.jsx +++ b/src/frontend/src/components/pages/welcome/WelcomeContent.jsx @@ -1,32 +1,20 @@ import { Box, Heading, Text, VStack } from '@chakra-ui/react'; -import githubIcon from '@/resources/welcome/image/github.svg'; -import manageIcon from '@/resources/welcome/image/setting.svg'; -import MotionCard from '@/components/ui/MotionCard'; -import { useNavigate } from 'react-router-dom'; +import DashboardCard from '@/components/pages/welcome/DashboardCard'; const WelcomeContent = () => { - const navigate = useNavigate(); - return ( - + - + 智能网络交换机
管理系统
- + 助力大型网络交换机配置及网络流量管理,方便的管控网络,让网络配置不再困难
- - navigate('/dashboard')} /> - - window.open('https://github.com/Jerryplusy/AI-powered-switches', '_blank')} - /> +
); }; diff --git a/src/frontend/src/components/system/layout/AppShell.jsx b/src/frontend/src/components/system/layout/AppShell.jsx new file mode 100644 index 0000000..c33b395 --- /dev/null +++ b/src/frontend/src/components/system/layout/AppShell.jsx @@ -0,0 +1,22 @@ +import { Outlet, useLocation } from 'react-router-dom'; +import PageTransition from './PageTransition'; +import { Box } from '@chakra-ui/react'; +import { AnimatePresence } from 'framer-motion'; + +const AppShell = () => { + const location = useLocation(); + + return ( + + + + + + + + + + ); +}; + +export default AppShell; diff --git a/src/frontend/src/components/system/layout/GithubNavTransition.jsx b/src/frontend/src/components/system/layout/GithubNavTransition.jsx new file mode 100644 index 0000000..704e275 --- /dev/null +++ b/src/frontend/src/components/system/layout/GithubNavTransition.jsx @@ -0,0 +1,53 @@ +import { useLocation } from 'react-router-dom'; +import { motion, AnimatePresence } from 'framer-motion'; +import { Box, Text, Image } from '@chakra-ui/react'; +import githubIcon from '@/resources/welcome/image/github.svg'; + +const GithubNavTransition = () => { + const { pathname } = useLocation(); + const isDashboard = pathname.startsWith('/dashboard'); + + return ( + + + window.open('https://github.com/Jerryplusy/AI-powered-switches', '_blank')} + > + + {isDashboard && ( + + GitHub 项目主页 + + )} + + + + ); +}; + +export default GithubNavTransition; diff --git a/src/frontend/src/components/system/layout/PageTransition.jsx b/src/frontend/src/components/system/layout/PageTransition.jsx new file mode 100644 index 0000000..e1e84ca --- /dev/null +++ b/src/frontend/src/components/system/layout/PageTransition.jsx @@ -0,0 +1,13 @@ +import { motion } from 'framer-motion'; + +const PageTransition = ({ children }) => ( + + {children} + +); + +export default PageTransition; diff --git a/src/frontend/src/constants/keep b/src/frontend/src/constants/keep deleted file mode 100644 index e69de29..0000000 diff --git a/src/frontend/src/constants/routes/routes.jsx b/src/frontend/src/constants/routes/routes.jsx new file mode 100644 index 0000000..7170259 --- /dev/null +++ b/src/frontend/src/constants/routes/routes.jsx @@ -0,0 +1,13 @@ +import { Route } from 'react-router-dom'; +import Welcome from '@/pages/Welcome'; +import Dashboard from '@/pages/Dashboard'; + +const routeList = [ + { path: '/', element: }, + { path: '/dashboard', element: }, +]; + +const buildRoutes = () => + routeList.map(({ path, element }) => ); + +export default buildRoutes; diff --git a/src/frontend/src/index.js b/src/frontend/src/index.js index aca27d5..d021c8d 100644 --- a/src/frontend/src/index.js +++ b/src/frontend/src/index.js @@ -1,14 +1,11 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import App from '@/App'; -import { BrowserRouter } from 'react-router-dom'; import { Provider } from '@/components/ui/provider'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( - - - + ); diff --git a/src/frontend/src/pages/Welcome.jsx b/src/frontend/src/pages/Welcome.jsx index c14ee59..9d0b659 100644 --- a/src/frontend/src/pages/Welcome.jsx +++ b/src/frontend/src/pages/Welcome.jsx @@ -1,11 +1,15 @@ import { Box } from '@chakra-ui/react'; import BackgroundBlur from '@/components/pages/welcome/BackgroundBlur'; import WelcomeContent from '@/components/pages/welcome/WelcomeContent'; +import GithubCard from '@/components/pages/welcome/GithubCard'; const Welcome = () => { return ( + + +