From 8d3841ae1fa837096a2202733fd98d2f8862f2c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B0=D0=BB=D0=B8=D0=BC=D0=BE=D0=B2=20=D0=A0=D1=83?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BC?= Date: Sat, 10 Jan 2026 19:54:16 +0300 Subject: [PATCH] 1 --- src/App.tsx | 88 +++++------------------ src/components/LayoutStep.tsx | 111 ++++++++++++++++++++---------- src/services/geometryGenerator.ts | 11 +-- src/types.ts | 5 +- 4 files changed, 97 insertions(+), 118 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index fb01df7..bec8a84 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,47 +7,8 @@ import { PreviewStep } from './components/PreviewStep'; import { parseShareUrl } from './utils/share'; import { ChevronRight, ChevronLeft, Box, AlertTriangle } from 'lucide-react'; -// --- ERROR BOUNDARY (Ловец ошибок) --- -class ErrorBoundary extends React.Component<{children: React.ReactNode}, {hasError: boolean, error: string}> { - constructor(props: any) { - super(props); - this.state = { hasError: false, error: '' }; - } - - static getDerivedStateFromError(error: any) { - return { hasError: true, error: error.toString() }; - } - - componentDidCatch(error: any, errorInfo: any) { - console.error("CRITICAL UI ERROR:", error, errorInfo); - } - - render() { - if (this.state.hasError) { - return ( -
-

- Что-то сломалось в этом компоненте -

-
-            {this.state.error}
-          
- -
- ); - } - return this.props.children; - } -} - const App = () => { const [step, setStep] = useState(1); - const [isLoadedFromUrl, setIsLoadedFromUrl] = useState(false); const [config, setConfig] = useState({ drawer: { width: 300, depth: 400, height: 80 }, @@ -62,16 +23,10 @@ const App = () => { partitions: {} }); - // Логируем состояние при каждом изменении - useEffect(() => { - console.log("APP STATE UPDATE:", { step, splits, config }); - }, [step, splits, config]); - useEffect(() => { try { const sharedData = parseShareUrl(); if (sharedData) { - console.log("Loaded from URL:", sharedData); setConfig(sharedData.config); setSplits({ x: Array.isArray(sharedData.splits.x) ? sharedData.splits.x : [], @@ -79,23 +34,32 @@ const App = () => { partitions: sharedData.splits.partitions || {} }); setStep(3); - setIsLoadedFromUrl(true); window.history.replaceState({}, '', window.location.pathname); } } catch (e) { - console.error("Url Parse Error", e); + console.error("URL load error", e); } }, []); const parts: GeneratedPart[] = useMemo(() => { try { return calculateParts(config, splits); - } catch(e) { - console.error("Geometry Calc Error:", e); + } catch (e) { + console.error("Geometry calculation failed", e); return []; } }, [config, splits]); + // Error Boundary component for safety + class ErrorBoundary extends React.Component<{children: React.ReactNode}, {hasError: boolean}> { + state = { hasError: false }; + static getDerivedStateFromError() { return { hasError: true }; } + render() { + if (this.state.hasError) return
Ошибка отрисовки. Нажмите "Новый проект".
; + return this.props.children; + } + } + return (
@@ -120,32 +84,18 @@ const App = () => {
-
- {step === 1 && ( -
- -
- )} - +
+ {step === 1 &&
} + {step === 2 && ( -
- {/* Оборачиваем LayoutStep в ErrorBoundary */} +
- +
)} - {step === 3 && ( -
- -
- )} + {step === 3 &&
}