fix: safari page blank
This commit is contained in:
@@ -15,13 +15,11 @@ class ErrorBoundary extends Component<
|
||||
};
|
||||
}
|
||||
|
||||
// 捕获错误并更新状态
|
||||
static getDerivedStateFromError(error: any) {
|
||||
console.error('Error caught by Error Boundary:', error);
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
// 记录错误信息(可选)
|
||||
componentDidCatch(error: any, info: any) {
|
||||
console.error('Error caught by Error Boundary:', error);
|
||||
console.error(info);
|
||||
|
||||
+19
-7
@@ -195,13 +195,25 @@ export default (props: any) => {
|
||||
}, [initialize]);
|
||||
|
||||
useEffect(() => {
|
||||
const menuWrap = document.querySelector(
|
||||
'.ant-menu.ant-menu-root'
|
||||
)?.parentElement;
|
||||
if (menuWrap) {
|
||||
initializeMenu(menuWrap);
|
||||
}
|
||||
}, [initializeMenu]);
|
||||
const checkAndInitialize = () => {
|
||||
const menuWrap = window.document.querySelector(
|
||||
'.ant-menu.ant-menu-root'
|
||||
)?.parentElement;
|
||||
if (menuWrap) {
|
||||
try {
|
||||
initializeMenu(menuWrap);
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize menu:', error);
|
||||
}
|
||||
} else {
|
||||
console.warn('Menu wrapper not found.');
|
||||
}
|
||||
};
|
||||
|
||||
const timeout = setTimeout(checkAndInitialize, 500);
|
||||
|
||||
return () => clearTimeout(timeout);
|
||||
}, [initializeMenu, matchedRoute, location]);
|
||||
|
||||
const renderMenuHeader = useCallback(
|
||||
(logo, title) => {
|
||||
|
||||
Reference in New Issue
Block a user