This commit is contained in:
Халимов Рустам
2025-12-27 19:25:23 +03:00
parent f296db8297
commit a81e4be8a2

View File

@@ -5,7 +5,7 @@ import * as THREE from 'three';
import JSZip from 'jszip';
import { AppConfig, GeneratedPart, LayoutSplits } from '../types';
import { createBinGeometry, generateSTL, exportSTL } from '../services/geometryGenerator';
import { Download, Package, Info, Loader2, Share2, Check, Ruler, Copy } from 'lucide-react';
import { Download, Package, Info, Loader2, Share2, Check, Ruler } from 'lucide-react';
import { generateShareUrl } from '../utils/share';
// --- DrawerFrame (Каркас) ---
@@ -106,7 +106,7 @@ export const PreviewStep: React.FC<Props> = ({ parts, config, splits }) => {
let success = false;
try {
// 1. Пробуем современный API (работает только на HTTPS или localhost)
// 1. Пробуем современный API
if (navigator.clipboard && navigator.clipboard.writeText) {
await navigator.clipboard.writeText(url);
success = true;
@@ -114,23 +114,18 @@ export const PreviewStep: React.FC<Props> = ({ parts, config, splits }) => {
throw new Error('Clipboard API unavailable');
}
} catch (err) {
// 2. Если не вышло (например, HTTP), используем Fallback метод
// 2. Fallback для HTTP
try {
const textArea = document.createElement("textarea");
textArea.value = url;
// Делаем элемент невидимым, но частью DOM
textArea.style.position = "fixed";
textArea.style.left = "-9999px";
textArea.style.top = "0";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
const result = document.execCommand('copy');
document.body.removeChild(textArea);
if (result) success = true;
} catch (e) {
console.error("Copy failed", e);
@@ -141,8 +136,7 @@ export const PreviewStep: React.FC<Props> = ({ parts, config, splits }) => {
setShareUrlCopied(true);
setTimeout(() => setShareUrlCopied(false), 3000);
} else {
// 3. Если совсем ничего не помогло, показываем промпт
prompt("Не удалось скопировать автоматически. Скопируйте ссылку вручную:", url);
prompt("Скопируйте ссылку вручную:", url);
}
};
@@ -156,15 +150,17 @@ export const PreviewStep: React.FC<Props> = ({ parts, config, splits }) => {
<Ruler className="text-primary" size={20} />
<span className="font-medium text-sm uppercase tracking-wide opacity-70">Размеры ящика:</span>
</div>
{/* ЗДЕСЬ ИЗМЕНЕНИЯ: Ш, Г, В */}
<div className="flex gap-4 font-mono text-lg font-bold text-white">
<div className="flex items-center gap-1">
<span className="text-slate-500 text-xs">W:</span> {config.drawer.width}
<span className="text-slate-500 text-xs">Ш:</span> {config.drawer.width}
</div>
<div className="flex items-center gap-1">
<span className="text-slate-500 text-xs">D:</span> {config.drawer.depth}
<span className="text-slate-500 text-xs">Г:</span> {config.drawer.depth}
</div>
<div className="flex items-center gap-1">
<span className="text-slate-500 text-xs">H:</span> {config.drawer.height}
<span className="text-slate-500 text-xs">В:</span> {config.drawer.height}
</div>
<span className="text-xs text-slate-500 self-end mb-1">мм</span>
</div>