@@ -3,6 +3,7 @@ import { ConfigProvider } from 'antd'
33import '@ant-design/v5-patch-for-react-19'
44
55import type { Route } from './+types/root'
6+ import { config } from './config'
67import './app.css'
78import './style/icon.scss'
89
@@ -24,17 +25,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
2425 < Links />
2526 </ head >
2627 < body >
27- < ConfigProvider
28- theme = { {
29- token : {
30- colorPrimary : '#2B7FFF' ,
31- colorInfo : '#2B7FFF' ,
32- // colorSuccess: '#67c23a',
33- // colorWarning: '#e6a23c',
34- // colorError: '#f05659',
35- wireframe : false
36- }
37- } } >
28+ < ConfigProvider theme = { config . theme } >
3829 { children }
3930 </ ConfigProvider >
4031 < ScrollRestoration />
@@ -48,112 +39,4 @@ export default function App() {
4839 return < Outlet />
4940}
5041
51- export function ErrorBoundary ( { error } : Route . ErrorBoundaryProps ) {
52- let message = '故障'
53- let stack : string | undefined
54- let is404 = false
55-
56- if ( isRouteErrorResponse ( error ) ) {
57- is404 = error . status === 404
58- message = is404 ? '404' : '错误'
59-
60- // 过滤 Chrome DevTools 的请求,不显示错误页面
61- if ( is404 && error . data && typeof error . data === 'string' &&
62- error . data . includes ( '.well-known/appspecific/com.chrome.devtools.json' ) ) {
63- return null ; // 不显示错误页面
64- }
65- } else if ( import . meta. env . DEV && error && error instanceof Error ) {
66- stack = error . stack
67- }
68-
69- return (
70- < ConfigProvider
71- theme = { {
72- token : {
73- colorPrimary : '#409eff' ,
74- colorInfo : '#409eff' ,
75- colorSuccess : '#67c23a' ,
76- colorWarning : '#e6a23c' ,
77- colorError : '#f05659' ,
78- wireframe : false
79- }
80- } } >
81- < main className = 'min-h-screen bg-gradient-to-br from-blue-50 via-white to-indigo-50 flex items-center justify-center px-4' >
82- < div className = 'max-w-2xl w-full text-center' >
83- { /* 404 图标和标题 */ }
84- < div className = 'mb-8' >
85- < div className = 'text-8xl md:text-9xl font-bold bg-gradient-to-r from-blue-500 via-purple-500 to-indigo-600 text-transparent bg-clip-text mb-4' >
86- { message }
87- </ div >
88- < p className = 'text-gray-600 text-lg mb-8' > { is404 ? '页面开始了他的自由旅行…' : '页面某乱了,自我反思中…' } </ p >
89- </ div >
90-
91- { /* 404 特殊提示 */ }
92- { is404 && (
93- < div className = 'bg-blue-50 border border-blue-200 rounded-2xl p-6 mb-8' >
94- < div className = 'flex items-center justify-center mb-4' >
95- < div className = 'w-12 h-12 bg-blue-500 rounded-full flex items-center justify-center' >
96- < svg className = 'w-6 h-6 text-white' fill = 'none' stroke = 'currentColor' viewBox = '0 0 24 24' >
97- < path strokeLinecap = 'round' strokeLinejoin = 'round' strokeWidth = { 2 } d = 'M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z' />
98- </ svg >
99- </ div >
100- </ div >
101- < h3 className = 'text-lg font-semibold text-blue-800 mb-2' > 📝 博客已迁移</ h3 >
102- < p className = 'text-blue-700 mb-4' > 我的博客内容已迁移至新地址,欢迎访问获取最新文章和技术分享</ p >
103- < a
104- href = 'https://note.weizwz.com'
105- target = '_blank'
106- rel = 'noopener noreferrer'
107- className = 'inline-flex items-center px-6 py-3 bg-blue-500 text-white font-medium rounded-full hover:bg-blue-600 transition-colors duration-200' >
108- < svg className = 'w-5 h-5 mr-2' fill = 'none' stroke = 'currentColor' viewBox = '0 0 24 24' >
109- < path
110- strokeLinecap = 'round'
111- strokeLinejoin = 'round'
112- strokeWidth = { 2 }
113- d = 'M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14'
114- />
115- </ svg >
116- 访问新博客 note.weizwz.com
117- </ a >
118- </ div >
119- ) }
120-
121- { /* 操作按钮 */ }
122- < div className = 'flex flex-col sm:flex-row gap-4 justify-center items-center' >
123- < a
124- href = '/'
125- className = 'inline-flex items-center px-8 py-4 bg-gradient-to-r from-blue-500 to-indigo-600 text-white font-semibold rounded-full hover:from-blue-600 hover:to-indigo-700 transition-all duration-200 shadow-lg hover:shadow-xl transform hover:-translate-y-0.5' >
126- < svg className = 'w-5 h-5 mr-2' fill = 'none' stroke = 'currentColor' viewBox = '0 0 24 24' >
127- < path
128- strokeLinecap = 'round'
129- strokeLinejoin = 'round'
130- strokeWidth = { 2 }
131- d = 'M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6'
132- />
133- </ svg >
134- 返回首页
135- </ a >
136- </ div >
137-
138- { /* 开发环境错误堆栈 */ }
139- { stack && (
140- < div className = 'mt-8 text-left' >
141- < details className = 'bg-red-50 border border-red-200 rounded-lg p-4' >
142- < summary className = 'cursor-pointer text-red-800 font-medium mb-2' > 开发调试信息</ summary >
143- < pre className = 'text-sm text-red-700 overflow-x-auto' >
144- < code > { stack } </ code >
145- </ pre >
146- </ details >
147- </ div >
148- ) }
149-
150- { /* 装饰元素 */ }
151- < div className = 'absolute top-10 left-10 w-20 h-20 bg-blue-200 rounded-full opacity-20 animate-pulse' > </ div >
152- < div className = 'absolute top-20 right-20 w-16 h-16 bg-purple-200 rounded-full opacity-20 animate-pulse' style = { { animationDelay : '1s' } } > </ div >
153- < div className = 'absolute bottom-20 left-20 w-12 h-12 bg-indigo-200 rounded-full opacity-20 animate-pulse' style = { { animationDelay : '2s' } } > </ div >
154- < div className = 'absolute bottom-10 right-10 w-24 h-24 bg-blue-100 rounded-full opacity-20 animate-pulse' style = { { animationDelay : '0.5s' } } > </ div >
155- </ div >
156- </ main >
157- </ ConfigProvider >
158- )
159- }
42+ export { ErrorBoundary } from './components/ErrorBoundary'
0 commit comments