From 43ec347f8635c5b14d31e15aaeb11cb40211063b Mon Sep 17 00:00:00 2001 From: LeonspaceX Date: Fri, 30 Jan 2026 19:32:06 +0800 Subject: [PATCH] Fix 404 layout --- front/src/App.tsx | 5 +- front/src/components/NotFound.tsx | 86 +++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 front/src/components/NotFound.tsx diff --git a/front/src/App.tsx b/front/src/App.tsx index 65f465a..a6cfab2 100644 --- a/front/src/App.tsx +++ b/front/src/App.tsx @@ -11,6 +11,7 @@ import { fetchArticles, reset_identity_token, getSiteNotice, type Article } from import { useLayout } from './context/LayoutContext'; import './App.css'; import { Eye24Regular, EyeOff24Regular, Copy24Regular } from '@fluentui/react-icons'; +import NotFound from './components/NotFound'; import NoticeModal from './components/NoticeModal'; import type { NoticeData } from './components/NoticeModal'; @@ -153,8 +154,6 @@ const Home: React.FC<{ onPreviewImage: (src: string, alt?: string) => void }> = ); }; -const NotFound = () =>

404 Not Found

; - const NoticeOverlay: React.FC = () => { const { settings } = useLayout(); const [noticeData, setNoticeData] = useState(null); @@ -316,8 +315,8 @@ function App() { } /> } /> } /> - } /> + } /> ); diff --git a/front/src/components/NotFound.tsx b/front/src/components/NotFound.tsx new file mode 100644 index 0000000..5321e71 --- /dev/null +++ b/front/src/components/NotFound.tsx @@ -0,0 +1,86 @@ +import React from 'react'; +import { useNavigate } from 'react-router-dom'; +import { makeStyles, tokens, Card, CardHeader, CardPreview, Text, Button, Title1, Subtitle1, FluentProvider, webLightTheme } from '@fluentui/react-components'; +import { ArrowLeft24Regular, Home24Regular } from '@fluentui/react-icons'; + +const useStyles = makeStyles({ + page: { + position: 'fixed', + inset: 0, + width: '100vw', + height: '100vh', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + backgroundColor: tokens.colorNeutralBackground3, + padding: tokens.spacingHorizontalXL, + overflow: 'auto', + boxSizing: 'border-box', + }, + card: { + width: 'min(720px, 92vw)', + borderRadius: tokens.borderRadiusLarge, + overflow: 'hidden', + boxShadow: tokens.shadow8, + }, + header: { + paddingLeft: tokens.spacingHorizontalXL, + paddingRight: tokens.spacingHorizontalXL, + paddingTop: tokens.spacingVerticalM, + paddingBottom: tokens.spacingVerticalM, + }, + preview: { + height: '140px', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + background: `linear-gradient(135deg, ${tokens.colorBrandBackground} 0%, ${tokens.colorBrandBackground2} 50%, ${tokens.colorPaletteBlueBackground2} 100%)`, + color: tokens.colorNeutralForegroundOnBrand, + }, + content: { + paddingLeft: tokens.spacingHorizontalXL, + paddingRight: tokens.spacingHorizontalXL, + paddingTop: tokens.spacingVerticalL, + paddingBottom: tokens.spacingVerticalL, + display: 'flex', + flexDirection: 'column', + gap: tokens.spacingVerticalM, + }, + actions: { + display: 'flex', + gap: tokens.spacingHorizontalM, + marginTop: tokens.spacingVerticalL, + }, +}); + +const NotFound: React.FC = () => { + const styles = useStyles(); + const navigate = useNavigate(); + + return ( + +
+ + 😕 404 Not Found} /> + +
+ +
+ 页面被当成小鱼干吃掉了喵😭 + 请检查链接是否正确,或者点击下方按钮继续浏览 +
+ + +
+
+ +
+ + ); +}; + +export default NotFound;