feat: 调整注册逻辑

This commit is contained in:
zdl
2025-10-14 16:02:33 +08:00
parent cd50d718fe
commit e0ca328e1c
12 changed files with 1570 additions and 1206 deletions

View File

@@ -9,7 +9,7 @@
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Visionware.
*/
import React, { Suspense } from "react";
import React, { Suspense, useEffect } from "react";
import { ChakraProvider } from '@chakra-ui/react';
import { Routes, Route, Navigate } from "react-router-dom";
@@ -45,6 +45,7 @@ import { AuthProvider } from "contexts/AuthContext";
// Components
import ProtectedRoute from "components/ProtectedRoute";
import ErrorBoundary from "components/ErrorBoundary";
function AppContent() {
const { colorMode } = useColorMode();
@@ -152,11 +153,36 @@ function AppContent() {
}
export default function App() {
// 全局错误处理:捕获未处理的 Promise rejection
useEffect(() => {
const handleUnhandledRejection = (event) => {
console.error('未捕获的 Promise rejection:', event.reason);
// 阻止默认的错误处理(防止崩溃)
event.preventDefault();
};
const handleError = (event) => {
console.error('全局错误:', event.error);
// 阻止默认的错误处理(防止崩溃)
event.preventDefault();
};
window.addEventListener('unhandledrejection', handleUnhandledRejection);
window.addEventListener('error', handleError);
return () => {
window.removeEventListener('unhandledrejection', handleUnhandledRejection);
window.removeEventListener('error', handleError);
};
}, []);
return (
<ChakraProvider theme={theme}>
<AuthProvider>
<AppContent />
</AuthProvider>
<ErrorBoundary>
<AuthProvider>
<AppContent />
</AuthProvider>
</ErrorBoundary>
</ChakraProvider>
);
}