Spaces:
Sleeping
Sleeping
Delete index.html
Browse files- index.html +0 -588
index.html
DELETED
|
@@ -1,588 +0,0 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="ko" class="dark">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
-
<title>SPAO AI 룩북 생성기</title>
|
| 7 |
-
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
-
<script>
|
| 9 |
-
tailwind.config = { darkMode: 'class', theme: { extend: { colors: { brand: { blue: '#3B82F6', hover: '#2563EB' } } } } }
|
| 10 |
-
</script>
|
| 11 |
-
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin />
|
| 12 |
-
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css" />
|
| 13 |
-
<style>
|
| 14 |
-
* { font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
|
| 15 |
-
body { -webkit-font-smoothing: antialiased; background: #1a1a1a; color: #f9fafb; margin: 0; overflow: hidden; }
|
| 16 |
-
::-webkit-scrollbar { width: 6px; height: 6px; }
|
| 17 |
-
::-webkit-scrollbar-track { background: #1a1a1a; }
|
| 18 |
-
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
|
| 19 |
-
::-webkit-scrollbar-thumb:hover { background: #4b5563; }
|
| 20 |
-
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
| 21 |
-
@keyframes shimmer { 0% { background-position: -600px 0; } 100% { background-position: 600px 0; } }
|
| 22 |
-
@keyframes pulseRing { 0% { transform: scale(0.85); opacity: .9; } 100% { transform: scale(1.6); opacity: 0; } }
|
| 23 |
-
.animate-fadeIn { animation: fadeIn .25s ease-out; }
|
| 24 |
-
.shimmer { background: linear-gradient(90deg, #232323 0%, #2c2c2c 40%, #232323 80%); background-size: 600px 100%; animation: shimmer 1.6s linear infinite; }
|
| 25 |
-
.pulse-ring::before { content: ''; position: absolute; inset: -6px; border-radius: 9999px; border: 2px solid #3B82F6; animation: pulseRing 1.4s ease-out infinite; }
|
| 26 |
-
.ai-label-overlay { position: absolute; top: 12pt; right: 12pt; font-weight: 300; font-size: 10pt; color: #3c3c3c; pointer-events: none; z-index: 2; letter-spacing: -0.02em; }
|
| 27 |
-
.drop-active { border-color: #3B82F6 !important; background: rgba(59,130,246,.08) !important; }
|
| 28 |
-
textarea { resize: vertical; }
|
| 29 |
-
</style>
|
| 30 |
-
<script type="importmap">
|
| 31 |
-
{ "imports": {
|
| 32 |
-
"react": "https://esm.sh/react@19.1.0",
|
| 33 |
-
"react/": "https://esm.sh/react@19.1.0/",
|
| 34 |
-
"react-dom/": "https://esm.sh/react-dom@19.1.0/",
|
| 35 |
-
"lucide-react": "https://esm.sh/lucide-react@0.462.0?external=react"
|
| 36 |
-
} }
|
| 37 |
-
</script>
|
| 38 |
-
</head>
|
| 39 |
-
<body>
|
| 40 |
-
<div id="root"></div>
|
| 41 |
-
<script type="module">
|
| 42 |
-
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
| 43 |
-
import ReactDOM from 'react-dom/client';
|
| 44 |
-
import { Download, X, Upload, Sparkles, RefreshCw, AlertTriangle, Clock, Check, ImagePlus, User, Maximize2 } from 'lucide-react';
|
| 45 |
-
|
| 46 |
-
const h = React.createElement;
|
| 47 |
-
|
| 48 |
-
// ═══════════════════════════════════════════════════════════
|
| 49 |
-
// Constants — 워크플로우(SPAO.json) CustomCombo 옵션과 1:1
|
| 50 |
-
// ═══════════════════════════════════════════════════════════
|
| 51 |
-
const SHOT_OPTIONS = ['전신컷', '상반신컷', '하반신컷', '레퍼런스 구도 그대로'];
|
| 52 |
-
const ANGLE_OPTIONS = ['정면', '반측면', '측면', '로우앵글', '하이앵글', '후면'];
|
| 53 |
-
const GAZE_OPTIONS = ['카메라 응시', '자연스러운 시선'];
|
| 54 |
-
const AGE_OPTIONS = ['성인', '키즈'];
|
| 55 |
-
const DETAIL_GROUPS = [
|
| 56 |
-
{ key: 'outer', label: '아우터', length: 'outer_length', fit: 'outer_fit' },
|
| 57 |
-
{ key: 'top', label: '상의', length: 'top_length', fit: 'top_fit' },
|
| 58 |
-
{ key: 'bottom', label: '하의', length: 'bottom_length', fit: 'bottom_fit' },
|
| 59 |
-
];
|
| 60 |
-
const DETAIL_OPTIONS = {
|
| 61 |
-
outer_length: { label: '아우터 길이', options: ['허리', '골반', '허벅지'], def: '골반' },
|
| 62 |
-
outer_fit: { label: '아우터 핏', options: ['슬림', '표준', '오버'], def: '표준' },
|
| 63 |
-
top_length: { label: '상의 길이', options: ['허리', '골반', '허벅지'], def: '골반' },
|
| 64 |
-
top_fit: { label: '상의 핏', options: ['슬림', '표준', '오버'], def: '오버' },
|
| 65 |
-
bottom_length: { label: '하의 길이', options: ['허벅지', '무릎', '종아리', '발목', '신발'], def: '신발' },
|
| 66 |
-
bottom_fit: { label: '하의 핏', options: ['슬림', '표준', '오버'], def: '오버' },
|
| 67 |
-
};
|
| 68 |
-
|
| 69 |
-
const ADULT_FACE_PRESETS = [
|
| 70 |
-
{ id: 'preset_9', label: '여성 1', url: '/face_preset_9.png' },
|
| 71 |
-
{ id: 'preset_16', label: '여성 2', url: '/face_preset_16.png' },
|
| 72 |
-
{ id: 'preset_15', label: '남성', url: '/face_preset_15.png' },
|
| 73 |
-
];
|
| 74 |
-
const KIDS_FACE_PRESETS = [
|
| 75 |
-
{ id: 'preset_kids_1', label: '키즈 A', url: '/face_preset_kids_1.png' },
|
| 76 |
-
{ id: 'preset_kids_2', label: '키즈 B', url: '/face_preset_kids_2.png' },
|
| 77 |
-
{ id: 'preset_kids_3', label: '키즈 C', url: '/face_preset_kids_3.png' },
|
| 78 |
-
{ id: 'preset_kids_7', label: '키즈 G', url: '/face_preset_kids_7.png' },
|
| 79 |
-
{ id: 'preset_kids_4', label: '키즈 D', url: '/face_preset_kids_4.png' },
|
| 80 |
-
{ id: 'preset_kids_5', label: '키즈 E', url: '/face_preset_kids_5.png' },
|
| 81 |
-
{ id: 'preset_kids_6', label: '키즈 F', url: '/face_preset_kids_6.png' },
|
| 82 |
-
];
|
| 83 |
-
|
| 84 |
-
const IMAGE_SLOTS = [
|
| 85 |
-
{ key: 'outer', label: '아우터', required: false },
|
| 86 |
-
{ key: 'top', label: '상의', required: false },
|
| 87 |
-
{ key: 'bottom', label: '하의', required: false, hint: '원피스도 여기' },
|
| 88 |
-
{ key: 'shoes', label: '신발', required: false },
|
| 89 |
-
{ key: 'inner', label: '이너웨어', required: false },
|
| 90 |
-
{ key: 'belt', label: '벨트', required: false },
|
| 91 |
-
{ key: 'background', label: '배경', required: false, hint: '비우면 기본 스튜디오' },
|
| 92 |
-
{ key: 'pose', label: '레퍼런스 포즈', required: false, hint: "'레퍼런스 구도 그대로' 선택 시 필수" },
|
| 93 |
-
];
|
| 94 |
-
|
| 95 |
-
// 디테일 참조: 조직감/로고 클로즈업을 생성 모델에 직접 참조로 전달 (전체 최대 4장)
|
| 96 |
-
const DETAIL_MAX = 4;
|
| 97 |
-
const DETAIL_KINDS = [{ key: 'texture', label: '조직감' }, { key: 'logo', label: '로고·프린트' }];
|
| 98 |
-
const DETAIL_GARMENTS = [
|
| 99 |
-
{ key: 'outer', label: '아우터' }, { key: 'top', label: '상의' }, { key: 'bottom', label: '하의' },
|
| 100 |
-
{ key: 'shoes', label: '신발' }, { key: 'inner', label: '이너웨어' }, { key: 'belt', label: '벨트' },
|
| 101 |
-
];
|
| 102 |
-
|
| 103 |
-
// AI 표기 — 저장 시 캔버스에 삽입 (기존 앱과 동일 규격)
|
| 104 |
-
const AI_LABEL_TEXT = 'AI 생성 이미지';
|
| 105 |
-
const AI_LABEL_FONT_PT = 28;
|
| 106 |
-
const AI_LABEL_MARGIN_PT = 12 * (28 / 10);
|
| 107 |
-
|
| 108 |
-
// ═══════════════════════════════════════════════════════════
|
| 109 |
-
// Helpers
|
| 110 |
-
// ═══════════════════════════════════════════════════════════
|
| 111 |
-
const fileToDataUrl = (file, maxSide = 1536) => new Promise((resolve, reject) => {
|
| 112 |
-
const reader = new FileReader();
|
| 113 |
-
reader.onerror = reject;
|
| 114 |
-
reader.onload = () => {
|
| 115 |
-
const img = new Image();
|
| 116 |
-
img.onerror = reject;
|
| 117 |
-
img.onload = () => {
|
| 118 |
-
const scale = Math.min(1, maxSide / Math.max(img.width, img.height));
|
| 119 |
-
const w = Math.round(img.width * scale), hgt = Math.round(img.height * scale);
|
| 120 |
-
const canvas = document.createElement('canvas');
|
| 121 |
-
canvas.width = w; canvas.height = hgt;
|
| 122 |
-
const ctx = canvas.getContext('2d');
|
| 123 |
-
const keepPng = /png|webp/i.test(file.type);
|
| 124 |
-
if (!keepPng) { ctx.fillStyle = '#fff'; ctx.fillRect(0, 0, w, hgt); }
|
| 125 |
-
ctx.drawImage(img, 0, 0, w, hgt);
|
| 126 |
-
resolve(keepPng ? canvas.toDataURL('image/png') : canvas.toDataURL('image/jpeg', 0.92));
|
| 127 |
-
};
|
| 128 |
-
img.src = reader.result;
|
| 129 |
-
};
|
| 130 |
-
reader.readAsDataURL(file);
|
| 131 |
-
});
|
| 132 |
-
|
| 133 |
-
const drawAiDisclosureOnCanvas = (ctx, width, height) => {
|
| 134 |
-
ctx.save();
|
| 135 |
-
ctx.textAlign = 'right'; ctx.textBaseline = 'top'; ctx.fillStyle = '#3c3c3c';
|
| 136 |
-
ctx.font = `300 ${AI_LABEL_FONT_PT}pt 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif`;
|
| 137 |
-
const ptToPx = 96 / 72;
|
| 138 |
-
const m = Math.max(AI_LABEL_MARGIN_PT * ptToPx, Math.min(width, height) * 0.028, 18);
|
| 139 |
-
ctx.fillText(AI_LABEL_TEXT, width - m, m);
|
| 140 |
-
ctx.restore();
|
| 141 |
-
};
|
| 142 |
-
|
| 143 |
-
async function downloadWithLabel(imageUrl, filename, withLabel = true) {
|
| 144 |
-
const img = new Image();
|
| 145 |
-
await new Promise((res, rej) => { img.onload = res; img.onerror = rej; img.src = imageUrl; });
|
| 146 |
-
const canvas = document.createElement('canvas');
|
| 147 |
-
canvas.width = img.naturalWidth; canvas.height = img.naturalHeight;
|
| 148 |
-
const ctx = canvas.getContext('2d');
|
| 149 |
-
ctx.drawImage(img, 0, 0);
|
| 150 |
-
if (withLabel) drawAiDisclosureOnCanvas(ctx, canvas.width, canvas.height);
|
| 151 |
-
const a = document.createElement('a');
|
| 152 |
-
a.href = canvas.toDataURL('image/png'); a.download = filename; a.click();
|
| 153 |
-
}
|
| 154 |
-
|
| 155 |
-
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
| 156 |
-
|
| 157 |
-
// 비로그인 사용자도 작업을 다시 불러올 수 있도록 브라우저별 ID를 보관 (로그인 시엔 서버가 계정명으로 묶음)
|
| 158 |
-
const CLIENT_ID = (() => {
|
| 159 |
-
try {
|
| 160 |
-
let id = localStorage.getItem('spao_client_id');
|
| 161 |
-
if (!id) { id = crypto.randomUUID(); localStorage.setItem('spao_client_id', id); }
|
| 162 |
-
return id;
|
| 163 |
-
} catch { return 'c-' + Math.random().toString(36).slice(2); }
|
| 164 |
-
})();
|
| 165 |
-
const apiHeaders = (json = false) => ({ 'X-Client-Id': CLIENT_ID, ...(json ? { 'Content-Type': 'application/json' } : {}) });
|
| 166 |
-
|
| 167 |
-
// 제출 → jobId → 폴링. 긴 HTTP 연결을 잡고 있지 않으므로 Space 프록시 타임아웃과 무관.
|
| 168 |
-
async function submitToComfy(payload) {
|
| 169 |
-
const res = await fetch('/api/comfy/generate', { method: 'POST', headers: apiHeaders(true), body: JSON.stringify(payload) });
|
| 170 |
-
if (!res.ok) { const e = await res.json().catch(() => ({})); throw new Error(e.detail || `HTTP ${res.status}`); }
|
| 171 |
-
return (await res.json()).jobId;
|
| 172 |
-
}
|
| 173 |
-
async function pollComfyJob(jobId, onProgress) {
|
| 174 |
-
let misses = 0;
|
| 175 |
-
while (true) {
|
| 176 |
-
await sleep(3000);
|
| 177 |
-
let r;
|
| 178 |
-
try { r = await fetch(`/api/comfy/jobs/${jobId}`, { headers: apiHeaders() }); } catch { if (++misses > 10) throw new Error('서버 응답이 없습니다.'); continue; }
|
| 179 |
-
if (r.status === 404) throw new Error('작업 정보를 잃어버렸습니다 (서버 재시작). 다시 시도해주세요.');
|
| 180 |
-
if (!r.ok) { if (++misses > 10) throw new Error(`HTTP ${r.status}`); continue; }
|
| 181 |
-
misses = 0;
|
| 182 |
-
const j = await r.json();
|
| 183 |
-
onProgress?.(j);
|
| 184 |
-
if (j.status === 'done') return j;
|
| 185 |
-
if (j.status === 'error') throw new Error(j.error || '생성 실패');
|
| 186 |
-
}
|
| 187 |
-
}
|
| 188 |
-
|
| 189 |
-
const fmtSec = (s) => { s = Math.round(s || 0); return s >= 60 ? `${Math.floor(s / 60)}분 ${s % 60}초` : `${s}초`; };
|
| 190 |
-
|
| 191 |
-
// ═══════════════════════════════════════════════════════════
|
| 192 |
-
// UI atoms
|
| 193 |
-
// ═══════════════════════════════════════════════════════════
|
| 194 |
-
const SectionTitle = ({ children, right }) => h('div', { className: 'flex items-center justify-between mb-2.5' },
|
| 195 |
-
h('h3', { className: 'text-[13px] font-semibold text-gray-200 tracking-tight' }, children), right || null);
|
| 196 |
-
|
| 197 |
-
const Segmented = ({ options, value, onChange, cols }) => h('div', {
|
| 198 |
-
className: `grid gap-1.5`, style: { gridTemplateColumns: `repeat(${cols || options.length}, minmax(0, 1fr))` } },
|
| 199 |
-
options.map(o => h('button', {
|
| 200 |
-
key: o, type: 'button', onClick: () => onChange(o),
|
| 201 |
-
className: `px-2 py-2 rounded-lg text-[12.5px] font-medium border transition-colors ${value === o
|
| 202 |
-
? 'bg-brand-blue border-brand-blue text-white'
|
| 203 |
-
: 'bg-[#242424] border-[#333] text-gray-300 hover:border-[#4b5563] hover:text-white'}`
|
| 204 |
-
}, o)));
|
| 205 |
-
|
| 206 |
-
const UploadTile = ({ slot, value, onChange, disabled }) => {
|
| 207 |
-
const inputRef = useRef(null);
|
| 208 |
-
const [drag, setDrag] = useState(false);
|
| 209 |
-
const handleFiles = async (files) => {
|
| 210 |
-
const f = files?.[0]; if (!f || !f.type.startsWith('image/')) return;
|
| 211 |
-
onChange(await fileToDataUrl(f), f.name);
|
| 212 |
-
};
|
| 213 |
-
return h('div', {
|
| 214 |
-
className: `relative rounded-xl border overflow-hidden group ${drag ? 'drop-active' : ''} ${value ? 'border-[#3a3a3a]' : 'border-dashed border-[#3a3a3a] bg-[#212121] hover:border-[#4b5563]'}`,
|
| 215 |
-
style: { aspectRatio: '3 / 4' },
|
| 216 |
-
onDragOver: e => { e.preventDefault(); setDrag(true); }, onDragLeave: () => setDrag(false),
|
| 217 |
-
onDrop: e => { e.preventDefault(); setDrag(false); if (!disabled) handleFiles(e.dataTransfer.files); },
|
| 218 |
-
onClick: () => !disabled && !value && inputRef.current?.click(),
|
| 219 |
-
},
|
| 220 |
-
h('input', { ref: inputRef, type: 'file', accept: 'image/*', className: 'hidden', onChange: e => { handleFiles(e.target.files); e.target.value = ''; } }),
|
| 221 |
-
value
|
| 222 |
-
? h(React.Fragment, null,
|
| 223 |
-
h('img', { src: value, className: 'w-full h-full object-cover bg-white', alt: slot.label }),
|
| 224 |
-
!disabled && h('button', { type: 'button', onClick: e => { e.stopPropagation(); onChange(null, null); },
|
| 225 |
-
className: 'absolute top-1.5 right-1.5 w-6 h-6 rounded-full bg-black/70 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity' }, h(X, { size: 13 })),
|
| 226 |
-
h('div', { className: 'absolute bottom-0 inset-x-0 px-2 py-1 bg-gradient-to-t from-black/70 to-transparent text-[11px] text-white' }, slot.label))
|
| 227 |
-
: h('div', { className: 'absolute inset-0 flex flex-col items-center justify-center gap-1 text-gray-500 cursor-pointer' },
|
| 228 |
-
h(ImagePlus, { size: 18 }),
|
| 229 |
-
h('span', { className: 'text-[11.5px] text-gray-300' }, slot.label, slot.required && h('span', { className: 'text-brand-blue ml-0.5' }, '*')),
|
| 230 |
-
slot.hint && h('span', { className: 'text-[10px] text-gray-500 px-2 text-center leading-tight' }, slot.hint))
|
| 231 |
-
);
|
| 232 |
-
};
|
| 233 |
-
|
| 234 |
-
const DetailTile = ({ value, onChange, disabled }) => {
|
| 235 |
-
const inputRef = useRef(null);
|
| 236 |
-
const handleFiles = async (files) => {
|
| 237 |
-
const f = files?.[0]; if (!f || !f.type.startsWith('image/')) return;
|
| 238 |
-
onChange(await fileToDataUrl(f, 1024), f.name);
|
| 239 |
-
};
|
| 240 |
-
return h('div', {
|
| 241 |
-
className: `relative w-full rounded-lg overflow-hidden group ${value ? 'border border-[#3a3a3a]' : 'border border-dashed border-[#3a3a3a] bg-[#212121] hover:border-[#4b5563]'} ${disabled ? 'opacity-60 border-[#333]' : ''}`,
|
| 242 |
-
style: { aspectRatio: '1 / 1' },
|
| 243 |
-
onDragOver: e => e.preventDefault(), onDrop: e => { e.preventDefault(); if (!disabled) handleFiles(e.dataTransfer.files); },
|
| 244 |
-
onClick: () => !disabled && !value && inputRef.current?.click(),
|
| 245 |
-
},
|
| 246 |
-
h('input', { ref: inputRef, type: 'file', accept: 'image/*', className: 'hidden', onChange: e => { handleFiles(e.target.files); e.target.value = ''; } }),
|
| 247 |
-
value
|
| 248 |
-
? h(React.Fragment, null,
|
| 249 |
-
h('img', { src: value, className: 'w-full h-full object-cover bg-white' }),
|
| 250 |
-
!disabled && h('button', { type: 'button', onClick: e => { e.stopPropagation(); onChange(null, null); },
|
| 251 |
-
className: 'absolute top-1 right-1 w-5 h-5 rounded-full bg-black/70 text-white flex items-center justify-center opacity-0 group-hover:opacity-100' }, h(X, { size: 11 })))
|
| 252 |
-
: h('div', { className: 'absolute inset-0 flex items-center justify-center text-gray-600 cursor-pointer' }, h(ImagePlus, { size: 14 })));
|
| 253 |
-
};
|
| 254 |
-
|
| 255 |
-
const FaceTile = ({ preset, selected, onClick }) => h('button', {
|
| 256 |
-
type: 'button', onClick, title: preset.label,
|
| 257 |
-
className: `relative rounded-xl overflow-hidden border-2 transition-colors ${selected ? 'border-brand-blue' : 'border-transparent hover:border-[#4b5563]'}`,
|
| 258 |
-
style: { aspectRatio: '1 / 1' } },
|
| 259 |
-
h('img', { src: preset.url, className: 'w-full h-full object-cover', alt: preset.label }),
|
| 260 |
-
selected && h('div', { className: 'absolute top-1 right-1 w-5 h-5 rounded-full bg-brand-blue flex items-center justify-center' }, h(Check, { size: 12, className: 'text-white' })),
|
| 261 |
-
h('div', { className: 'absolute bottom-0 inset-x-0 px-1.5 py-0.5 bg-black/60 text-[10.5px] text-white text-center' }, preset.label));
|
| 262 |
-
|
| 263 |
-
// ═══════════════════════════════════════════════════════════
|
| 264 |
-
// App
|
| 265 |
-
// ═══════════════════════════════════════════════════════════
|
| 266 |
-
function App() {
|
| 267 |
-
const [user, setUser] = useState({ username: 'anonymous', is_logged_in: false, oauth_enabled: false });
|
| 268 |
-
const [health, setHealth] = useState(null);
|
| 269 |
-
|
| 270 |
-
const [age, setAge] = useState('성인');
|
| 271 |
-
const [facePreset, setFacePreset] = useState('preset_9');
|
| 272 |
-
const [faceUpload, setFaceUpload] = useState(null);
|
| 273 |
-
const [shot, setShot] = useState('전신컷');
|
| 274 |
-
const [angle, setAngle] = useState('반측면');
|
| 275 |
-
const [gaze, setGaze] = useState('자연스러운 시선');
|
| 276 |
-
const [prompt, setPrompt] = useState('');
|
| 277 |
-
const [details, setDetails] = useState(Object.fromEntries(Object.entries(DETAIL_OPTIONS).map(([k, v]) => [k, v.def])));
|
| 278 |
-
const [detailTab, setDetailTab] = useState('top');
|
| 279 |
-
const [images, setImages] = useState({});
|
| 280 |
-
const [imageNames, setImageNames] = useState({}); // 슬롯별 원본 파일명 (Dataset 로그·스타일코드 집계용)
|
| 281 |
-
const [faceUploadName, setFaceUploadName] = useState(null);
|
| 282 |
-
|
| 283 |
-
const [jobs, setJobs] = useState([]); // 진행 중/실패 작업 [{id, jobId, meta, stageLabel, startedAt, error}]
|
| 284 |
-
const [tick, setTick] = useState(0); // 경과시간 표시용 1초 타이머
|
| 285 |
-
const [results, setResults] = useState([]); // [{id, imageUrl, meta, elapsedSec}]
|
| 286 |
-
const [current, setCurrent] = useState(null);
|
| 287 |
-
const [error, setError] = useState(null);
|
| 288 |
-
const [aiLabel, setAiLabel] = useState(true);
|
| 289 |
-
const [lightbox, setLightbox] = useState(false); // 결과 이미지 확대 보기
|
| 290 |
-
const [showSpecs, setShowSpecs] = useState(false); // 의상 분석 결과 / 최종 프롬프트 펼치기
|
| 291 |
-
useEffect(() => {
|
| 292 |
-
if (!lightbox) return;
|
| 293 |
-
const onKey = (e) => { if (e.key === 'Escape') setLightbox(false); };
|
| 294 |
-
window.addEventListener('keydown', onKey);
|
| 295 |
-
return () => window.removeEventListener('keydown', onKey);
|
| 296 |
-
}, [lightbox]);
|
| 297 |
-
const faceFileRef = useRef(null);
|
| 298 |
-
|
| 299 |
-
useEffect(() => {
|
| 300 |
-
fetch('/api/whoami').then(r => r.ok ? r.json() : null).then(d => d && setUser(d)).catch(() => {});
|
| 301 |
-
fetch('/api/comfy/health').then(r => r.ok ? r.json() : { ok: false, error: '브리지 라우트가 없습니다' }).then(setHealth).catch(() => setHealth({ ok: false, error: '상태 확인 실패' }));
|
| 302 |
-
}, []);
|
| 303 |
-
|
| 304 |
-
const activeJobs = jobs.filter(j => !j.error);
|
| 305 |
-
useEffect(() => {
|
| 306 |
-
if (activeJobs.length === 0) return;
|
| 307 |
-
const id = setInterval(() => setTick(t => t + 1), 1000);
|
| 308 |
-
return () => clearInterval(id);
|
| 309 |
-
}, [activeJobs.length]);
|
| 310 |
-
|
| 311 |
-
useEffect(() => { // 연령 바꾸면 해당 그룹 첫 프리셋으로
|
| 312 |
-
const list = age === '키즈' ? KIDS_FACE_PRESETS : ADULT_FACE_PRESETS;
|
| 313 |
-
if (!faceUpload && !list.some(p => p.id === facePreset)) setFacePreset(list[0].id);
|
| 314 |
-
}, [age]);
|
| 315 |
-
|
| 316 |
-
const presets = age === '키즈' ? KIDS_FACE_PRESETS : ADULT_FACE_PRESETS;
|
| 317 |
-
const setImg = (key, v, name) => { setImages(prev => ({ ...prev, [key]: v })); setImageNames(prev => ({ ...prev, [key]: v ? (name || null) : null })); };
|
| 318 |
-
|
| 319 |
-
const detailList = DETAIL_GARMENTS.flatMap(g => DETAIL_KINDS.map(k => ({ garment: g.key, kind: k.key, image: images[`detail:${g.key}:${k.key}`], filename: imageNames[`detail:${g.key}:${k.key}`] })))
|
| 320 |
-
.filter(x => x.image && images[x.garment]);
|
| 321 |
-
const detailCount = detailList.length;
|
| 322 |
-
const missing = [];
|
| 323 |
-
if (!images.outer && !images.top && !images.bottom) missing.push('의상 1개 이상 (아우터·상의·하의)');
|
| 324 |
-
if (shot === '레퍼런스 구도 그대로' && !images.pose) missing.push('레퍼런스 포즈');
|
| 325 |
-
const canGenerate = missing.length === 0 && (faceUpload || facePreset) && health?.ok;
|
| 326 |
-
|
| 327 |
-
const handleGenerate = async () => {
|
| 328 |
-
if (user.oauth_enabled && !user.is_logged_in) { alert("로그인이 필요합니다. 우측 상단의 'Hugging Face로 로그인' 버튼을 눌러주세요."); return; }
|
| 329 |
-
if (!canGenerate) return;
|
| 330 |
-
setError(null);
|
| 331 |
-
const id = Date.now().toString(36) + Math.random().toString(36).slice(2, 5);
|
| 332 |
-
const meta = { shot, angle, gaze, age, prompt, face: faceUpload ? '업로드' : (presets.find(p => p.id === facePreset)?.label || facePreset) };
|
| 333 |
-
const mainImages = Object.fromEntries(Object.entries(images).filter(([k, v]) => v && !k.startsWith('detail:')));
|
| 334 |
-
const payload = { face: faceUpload || facePreset, faceFilename: faceUpload ? faceUploadName : null, images: mainImages, imageFilenames: imageNames,
|
| 335 |
-
details: detailList.slice(0, DETAIL_MAX).map(x => ({ garment: x.garment, kind: x.kind, image: x.image, filename: x.filename || null })),
|
| 336 |
-
options: { shot, angle, gaze, age, ...details }, prompt, meta };
|
| 337 |
-
setJobs(prev => [...prev, { id, meta, stageLabel: '요청 전송 중', startedAt: Date.now() }]);
|
| 338 |
-
const patch = (p) => setJobs(prev => prev.map(j => j.id === id ? { ...j, ...p } : j));
|
| 339 |
-
let jobId;
|
| 340 |
-
try {
|
| 341 |
-
jobId = await submitToComfy(payload);
|
| 342 |
-
} catch (e) {
|
| 343 |
-
patch({ error: e.message }); return;
|
| 344 |
-
}
|
| 345 |
-
patch({ jobId, stageLabel: '대기 중' });
|
| 346 |
-
await trackJob(id, jobId, meta, patch);
|
| 347 |
-
};
|
| 348 |
-
|
| 349 |
-
// 서버 작업을 완료까지 따라가며 결과/에러를 반영 (새 요청과 새로고침 복구 둘 다 사용)
|
| 350 |
-
const trackJob = async (id, jobId, meta, patch) => {
|
| 351 |
-
try {
|
| 352 |
-
const j = await pollComfyJob(jobId, (st) => patch({ stageLabel: st.stageLabel, execStartedAt: st.execStartedAt || null }));
|
| 353 |
-
const item = { id, imageUrl: j.imageUrl, meta, elapsedSec: j.elapsedSec, createdAt: j.createdAt, garmentSpecs: j.garmentSpecs || null, finalPrompt: j.finalPrompt || null };
|
| 354 |
-
setResults(prev => prev.some(r => r.id === id) ? prev : [item, ...prev]);
|
| 355 |
-
setCurrent(prev => prev || item);
|
| 356 |
-
setJobs(prev => prev.filter(x => x.id !== id));
|
| 357 |
-
} catch (e) {
|
| 358 |
-
patch({ error: e.message });
|
| 359 |
-
}
|
| 360 |
-
};
|
| 361 |
-
const dismissJob = (id) => setJobs(prev => prev.filter(j => j.id !== id));
|
| 362 |
-
|
| 363 |
-
// 새로고침/재접속 시 서버에 남아 있는 내 작업 복구
|
| 364 |
-
useEffect(() => {
|
| 365 |
-
(async () => {
|
| 366 |
-
try {
|
| 367 |
-
const r = await fetch('/api/comfy/jobs', { headers: apiHeaders() });
|
| 368 |
-
if (!r.ok) return;
|
| 369 |
-
const { jobs: saved } = await r.json();
|
| 370 |
-
const done = saved.filter(j => j.status === 'done' && j.imageUrl)
|
| 371 |
-
.map(j => ({ id: j.id, imageUrl: j.imageUrl, meta: j.meta || {}, elapsedSec: j.elapsedSec, createdAt: j.createdAt, garmentSpecs: j.garmentSpecs || null, finalPrompt: j.finalPrompt || null }))
|
| 372 |
-
.sort((a, b) => b.createdAt - a.createdAt);
|
| 373 |
-
if (done.length) { setResults(done); setCurrent(prev => prev || done[0]); }
|
| 374 |
-
const pending = saved.filter(j => j.status !== 'done');
|
| 375 |
-
if (pending.length) {
|
| 376 |
-
setJobs(pending.map(j => ({ id: j.id, jobId: j.id, meta: j.meta || {}, stageLabel: j.stageLabel, startedAt: j.createdAt, execStartedAt: j.execStartedAt || null, error: j.error || null })));
|
| 377 |
-
for (const j of pending.filter(x => x.status === 'running')) {
|
| 378 |
-
const patch = (p) => setJobs(prev => prev.map(x => x.id === j.id ? { ...x, ...p } : x));
|
| 379 |
-
trackJob(j.id, j.id, j.meta || {}, patch);
|
| 380 |
-
}
|
| 381 |
-
}
|
| 382 |
-
} catch {}
|
| 383 |
-
})();
|
| 384 |
-
}, []);
|
| 385 |
-
|
| 386 |
-
// ── Left: settings ────────────────────────────────────────
|
| 387 |
-
const left = h('aside', { className: 'w-full lg:w-[420px] xl:w-[460px] shrink-0 h-full overflow-y-auto border-r border-[#2a2a2a] bg-[#1e1e1e]' },
|
| 388 |
-
h('div', { className: 'p-5 space-y-6' },
|
| 389 |
-
|
| 390 |
-
h('section', null,
|
| 391 |
-
h(SectionTitle, { right: h(Segmented, { options: AGE_OPTIONS, value: age, onChange: setAge }) }, '얼굴'),
|
| 392 |
-
h('div', { className: 'grid grid-cols-4 gap-2' },
|
| 393 |
-
presets.map(p => h(FaceTile, { key: p.id, preset: p, selected: !faceUpload && facePreset === p.id, onClick: () => { setFaceUpload(null); setFacePreset(p.id); } })),
|
| 394 |
-
h('button', { type: 'button', onClick: () => faceFileRef.current?.click(),
|
| 395 |
-
className: `relative rounded-xl overflow-hidden border-2 ${faceUpload ? 'border-brand-blue' : 'border-dashed border-[#3a3a3a] hover:border-[#4b5563] bg-[#242424]'}`, style: { aspectRatio: '1 / 1' } },
|
| 396 |
-
faceUpload
|
| 397 |
-
? h(React.Fragment, null, h('img', { src: faceUpload, className: 'w-full h-full object-cover' }),
|
| 398 |
-
h('span', { onClick: e => { e.stopPropagation(); setFaceUpload(null); }, className: 'absolute top-1 right-1 w-5 h-5 rounded-full bg-black/70 flex items-center justify-center' }, h(X, { size: 11 })),
|
| 399 |
-
h('div', { className: 'absolute bottom-0 inset-x-0 py-0.5 bg-black/60 text-[10.5px] text-center' }, '업로드'))
|
| 400 |
-
: h('div', { className: 'absolute inset-0 flex flex-col items-center justify-center gap-1 text-gray-400' }, h(User, { size: 16 }), h('span', { className: 'text-[10.5px]' }, '직접 업로드'))),
|
| 401 |
-
h('input', { ref: faceFileRef, type: 'file', accept: 'image/*', className: 'hidden', onChange: async e => { const f = e.target.files?.[0]; if (f) { setFaceUpload(await fileToDataUrl(f, 1024)); setFaceUploadName(f.name); } e.target.value = ''; } }))),
|
| 402 |
-
|
| 403 |
-
h('section', null, h(SectionTitle, null, '샷 선택'), h(Segmented, { options: SHOT_OPTIONS, value: shot, onChange: setShot, cols: 2 })),
|
| 404 |
-
h('section', null, h(SectionTitle, null, '카메라 앵글'), h(Segmented, { options: ANGLE_OPTIONS, value: angle, onChange: setAngle, cols: 3 })),
|
| 405 |
-
h('section', null, h(SectionTitle, null, '시선'), h(Segmented, { options: GAZE_OPTIONS, value: gaze, onChange: setGaze })),
|
| 406 |
-
|
| 407 |
-
h('section', null,
|
| 408 |
-
h(SectionTitle, null, '프롬프트 작성'),
|
| 409 |
-
h('textarea', { value: prompt, onChange: e => setPrompt(e.target.value), rows: 3,
|
| 410 |
-
placeholder: '추가 지시사항 (선택). 예: 손을 주머니에 넣고 살짝 미소, 소매를 한 번 접어 올린 스타일링',
|
| 411 |
-
className: 'w-full rounded-xl bg-[#242424] border border-[#333] px-3 py-2.5 text-[13px] text-gray-100 placeholder-gray-500 focus:outline-none focus:border-brand-blue' })),
|
| 412 |
-
|
| 413 |
-
h('section', null,
|
| 414 |
-
h(SectionTitle, { right: h('span', { className: 'text-[11px] text-gray-500' }, '아우터·상의·하의 중 1개 이상') }, '이미지 업로드'),
|
| 415 |
-
h('div', { className: 'grid grid-cols-4 gap-2' },
|
| 416 |
-
IMAGE_SLOTS.map(s => h(UploadTile, { key: s.key, slot: s, value: images[s.key], onChange: (v, name) => setImg(s.key, v, name) })))),
|
| 417 |
-
|
| 418 |
-
h('section', null,
|
| 419 |
-
h(SectionTitle, null, '길이 · 핏'),
|
| 420 |
-
h('div', { className: 'flex gap-1.5 mb-3' },
|
| 421 |
-
DETAIL_GROUPS.map(g => h('button', {
|
| 422 |
-
key: g.key, type: 'button', onClick: () => setDetailTab(g.key),
|
| 423 |
-
className: `px-3 py-1.5 rounded-lg text-[12.5px] font-semibold transition-colors ${detailTab === g.key
|
| 424 |
-
? 'bg-brand-blue text-white'
|
| 425 |
-
: (images[g.key] ? 'bg-[#2a2a2a] text-gray-200 hover:bg-[#333]' : 'bg-[#242424] text-gray-500 hover:text-gray-300')}`
|
| 426 |
-
}, g.label, images[g.key] ? h('span', { className: `ml-1.5 inline-block w-1.5 h-1.5 rounded-full align-middle ${detailTab === g.key ? 'bg-white' : 'bg-brand-blue'}` }) : null))),
|
| 427 |
-
(() => {
|
| 428 |
-
const g = DETAIL_GROUPS.find(x => x.key === detailTab);
|
| 429 |
-
const rows = [['길이', g.length], ['핏', g.fit]];
|
| 430 |
-
return h('div', { key: g.key, className: 'space-y-2 animate-fadeIn' },
|
| 431 |
-
rows.map(([label, k]) => h('div', { key: k, className: 'grid grid-cols-[52px_1fr] items-center gap-2' },
|
| 432 |
-
h('span', { className: 'text-[12px] text-gray-400' }, label),
|
| 433 |
-
h('div', { className: 'flex flex-wrap gap-1.5' },
|
| 434 |
-
DETAIL_OPTIONS[k].options.map(o => h('button', {
|
| 435 |
-
key: o, type: 'button', onClick: () => setDetails(d => ({ ...d, [k]: o })),
|
| 436 |
-
className: `px-3 py-1.5 rounded-lg text-[12.5px] font-medium border transition-colors ${details[k] === o
|
| 437 |
-
? 'bg-brand-blue border-brand-blue text-white'
|
| 438 |
-
: 'bg-[#242424] border-[#333] text-gray-300 hover:border-[#4b5563] hover:text-white'}`
|
| 439 |
-
}, o))))),
|
| 440 |
-
!images[g.key] && h('p', { className: 'text-[11px] text-gray-500 pt-1' }, `${g.label} 이미지를 올리지 않으면 이 설정은 사용되지 않아요.`));
|
| 441 |
-
})()),
|
| 442 |
-
|
| 443 |
-
h('section', null,
|
| 444 |
-
h(SectionTitle, { right: h('span', { className: `text-[11px] ${detailCount >= DETAIL_MAX ? 'text-amber-400' : 'text-gray-500'}` }, `선택 · ${detailCount}/${DETAIL_MAX}장`) }, '디테일 참조 (조직감 · 로고)'),
|
| 445 |
-
health?.ok && health.detailCuts === false
|
| 446 |
-
? h('p', { className: 'text-[11.5px] text-gray-500' }, '현재 배포된 워크플로우(workflow_api.json)에 디테일 참조 입력이 없어 사용할 수 없어요. v5 워크플로우를 Export (API)해서 교체해주세요.')
|
| 447 |
-
: h(React.Fragment, null,
|
| 448 |
-
h('p', { className: 'text-[11px] text-gray-500 mb-2.5 leading-relaxed' }, '원단 조직감이나 로고·프린트 클로즈업을 올리면 생성 시 그 의상에 그대로 재현하도록 참조로 전달돼요. 참조가 많으면 정확도가 떨어져서 전체 4장까지만.'),
|
| 449 |
-
h('div', { className: 'grid grid-cols-2 gap-x-4 gap-y-2.5' },
|
| 450 |
-
DETAIL_GARMENTS.map(g => {
|
| 451 |
-
const enabled = !!images[g.key];
|
| 452 |
-
return h('div', { key: g.key, className: 'flex items-center gap-2' },
|
| 453 |
-
h('span', { className: `w-14 shrink-0 text-[12px] ${enabled ? 'text-gray-300' : 'text-gray-600'}`, title: enabled ? '' : `${g.label} 이미지를 먼저 올려주세요` }, g.label),
|
| 454 |
-
DETAIL_KINDS.map(k => {
|
| 455 |
-
const id = `${g.key}:${k.key}`;
|
| 456 |
-
const cur = images[`detail:${id}`];
|
| 457 |
-
return h('div', { key: k.key, className: 'w-14 flex flex-col items-center gap-0.5' },
|
| 458 |
-
h(DetailTile, { value: cur, disabled: !enabled || (!cur && detailCount >= DETAIL_MAX), onChange: (v, name) => setImg(`detail:${id}`, v, name) }),
|
| 459 |
-
h('span', { className: 'text-[9.5px] text-gray-500' }, k.label));
|
| 460 |
-
}));
|
| 461 |
-
})))),
|
| 462 |
-
|
| 463 |
-
h('div', { className: 'pt-3 pb-3 sticky bottom-0 bg-[#1e1e1e] border-t border-[#2a2a2a] -mx-5 px-5' },
|
| 464 |
-
missing.length > 0 && h('p', { className: 'text-[11.5px] text-gray-500 mb-2' }, `필요: ${missing.join(', ')}`),
|
| 465 |
-
activeJobs.length > 0 && missing.length === 0 && h('p', { className: 'text-[11.5px] text-gray-500 mb-2' }, `${activeJobs.length}건 진행 중 — 설정을 바꿔 바로 다음 컷을 걸어둘 수 있어요`),
|
| 466 |
-
h('button', { type: 'button', onClick: handleGenerate, disabled: !canGenerate,
|
| 467 |
-
className: `w-full h-12 rounded-xl font-semibold text-[14px] flex items-center justify-center gap-2 transition-colors ${canGenerate ? 'bg-brand-blue hover:bg-brand-hover text-white' : 'bg-[#2a2a2a] text-gray-500 cursor-not-allowed'}` },
|
| 468 |
-
h(Sparkles, { size: 16 }),
|
| 469 |
-
activeJobs.length > 0 ? `룩북 생성 (${activeJobs.length}건 진행 중)` : '룩북 생성'))));
|
| 470 |
-
|
| 471 |
-
// ── Right: result ─────────────────────────────────────────
|
| 472 |
-
const right = h('main', { className: 'flex-1 h-full overflow-y-auto' },
|
| 473 |
-
h('div', { className: 'max-w-5xl mx-auto p-6 lg:p-8' },
|
| 474 |
-
!health?.ok && health && h('div', { className: 'mb-5 rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-[13px] text-amber-200 flex gap-2' },
|
| 475 |
-
h(AlertTriangle, { size: 16, className: 'shrink-0 mt-0.5' }), h('span', null, health.error || 'Comfy 브리지 설정을 확인해주세요.')),
|
| 476 |
-
health?.ok && health.loginRequired === false && h('div', { className: 'mb-5 rounded-xl border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-[13px] text-amber-200 flex gap-2' },
|
| 477 |
-
h(AlertTriangle, { size: 16, className: 'shrink-0 mt-0.5' }), h('span', null, 'HF OAuth가 연결되지 않아 로그인 없이 누구나 생성할 수 있는 상태입니다. README의 hf_oauth 설정과 Space 재시작을 확인해주세요.')),
|
| 478 |
-
error && h('div', { className: 'mb-5 rounded-xl border border-red-500/40 bg-red-500/10 px-4 py-3 text-[13px] text-red-200 flex gap-2 animate-fadeIn' },
|
| 479 |
-
h(AlertTriangle, { size: 16, className: 'shrink-0 mt-0.5' }), h('span', { className: 'break-all' }, error)),
|
| 480 |
-
|
| 481 |
-
jobs.length > 0 && h('div', { className: 'mb-5 rounded-xl border border-[#2a2a2a] bg-[#202020] overflow-hidden animate-fadeIn' },
|
| 482 |
-
h('div', { className: 'px-4 py-2.5 border-b border-[#2a2a2a] text-[12.5px] font-semibold text-gray-300 flex items-center gap-2' },
|
| 483 |
-
h(RefreshCw, { size: 13, className: activeJobs.length ? 'animate-spin text-brand-blue' : 'text-gray-500' }),
|
| 484 |
-
`진행 중 ${activeJobs.length}건`, jobs.length - activeJobs.length > 0 ? h('span', { className: 'text-red-300 font-normal' }, ` · 실패 ${jobs.length - activeJobs.length}건`) : null),
|
| 485 |
-
jobs.map((j, i) => h('div', { key: j.id, className: `px-4 py-2.5 flex items-center gap-3 text-[12.5px] ${i > 0 ? 'border-t border-[#262626]' : ''}` },
|
| 486 |
-
h('div', { className: `w-1.5 h-1.5 rounded-full shrink-0 ${j.error ? 'bg-red-400' : 'bg-brand-blue pulse-ring relative'}` }),
|
| 487 |
-
h('div', { className: 'flex-1 min-w-0' },
|
| 488 |
-
h('div', { className: 'text-gray-100 truncate' }, `${j.meta.face} · ${j.meta.shot} · ${j.meta.angle} · ${j.meta.gaze}`, j.meta.prompt ? h('span', { className: 'text-gray-500' }, ` · "${j.meta.prompt}"`) : null),
|
| 489 |
-
h('div', { className: j.error ? 'text-red-300 break-all' : 'text-gray-400' },
|
| 490 |
-
j.error ? j.error : (j.execStartedAt ? `${j.stageLabel} · ${fmtSec((Date.now() - j.execStartedAt) / 1000)}` : `${j.stageLabel} · 대기 ${fmtSec((Date.now() - j.startedAt) / 1000)}`))),
|
| 491 |
-
j.error && h('button', { type: 'button', onClick: () => dismissJob(j.id), className: 'text-gray-500 hover:text-white' }, h(X, { size: 14 }))))),
|
| 492 |
-
|
| 493 |
-
h('div', { className: 'grid grid-cols-1 md:grid-cols-[minmax(0,1fr)_200px] gap-6' },
|
| 494 |
-
// 메인 뷰어
|
| 495 |
-
h('div', { className: 'rounded-2xl bg-[#202020] border border-[#2a2a2a] overflow-hidden relative', style: { minHeight: '60vh' } },
|
| 496 |
-
!current && activeJobs.length > 0
|
| 497 |
-
? h('div', { className: 'absolute inset-0 flex flex-col items-center justify-center gap-5' },
|
| 498 |
-
h('div', { className: 'shimmer absolute inset-0 opacity-60' }),
|
| 499 |
-
h('div', { className: 'relative pulse-ring w-14 h-14 rounded-full bg-brand-blue/20 flex items-center justify-center' }, h(Sparkles, { size: 22, className: 'text-brand-blue' })),
|
| 500 |
-
h('div', { className: 'relative text-center' },
|
| 501 |
-
h('div', { className: 'text-[15px] font-semibold text-gray-100' }, activeJobs[0].stageLabel),
|
| 502 |
-
h('div', { className: 'mt-1 text-[12.5px] text-gray-400 flex items-center justify-center gap-1' }, h(Clock, { size: 12 }),
|
| 503 |
-
activeJobs[0].execStartedAt ? `${fmtSec((Date.now() - activeJobs[0].execStartedAt) / 1000)} 경과 · 보통 1~2분 소요` : '실행 순서를 기다리는 중')),
|
| 504 |
-
h('p', { className: 'relative text-[11.5px] text-gray-500 max-w-xs text-center' }, '이 탭을 닫지 마세요. 생성이 끝나면 여기에 이미지가 표시됩니다.'))
|
| 505 |
-
: current
|
| 506 |
-
? h('div', { className: 'animate-fadeIn flex flex-col' },
|
| 507 |
-
h('div', { className: 'flex justify-center bg-[#1c1c1c]' },
|
| 508 |
-
h('div', { className: 'relative inline-block' },
|
| 509 |
-
h('img', { src: current.imageUrl, onClick: () => setLightbox(true), title: '클릭하면 크게 보기',
|
| 510 |
-
className: 'max-h-[78vh] w-auto max-w-full block bg-white cursor-zoom-in', alt: '생성 결과' }),
|
| 511 |
-
aiLabel && h('div', { className: 'ai-label-overlay' }, AI_LABEL_TEXT),
|
| 512 |
-
h('button', { type: 'button', onClick: () => setLightbox(true), title: '크게 보기',
|
| 513 |
-
className: 'absolute bottom-3 right-3 w-9 h-9 rounded-lg bg-black/55 hover:bg-black/75 text-white flex items-center justify-center' }, h(Maximize2, { size: 16 })))),
|
| 514 |
-
h('div', { className: 'flex items-center justify-between gap-3 px-4 py-3 border-t border-[#2a2a2a]' },
|
| 515 |
-
h('label', { className: 'flex items-center gap-2 cursor-pointer select-none text-[12.5px] text-gray-300' },
|
| 516 |
-
h('button', { type: 'button', role: 'switch', 'aria-checked': aiLabel, onClick: () => setAiLabel(v => !v),
|
| 517 |
-
className: `relative w-9 h-5 rounded-full transition-colors ${aiLabel ? 'bg-brand-blue' : 'bg-[#3a3a3a]'}` },
|
| 518 |
-
h('span', { className: `absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white transition-transform ${aiLabel ? 'translate-x-4' : ''}` })),
|
| 519 |
-
h('span', null, "'AI 생성 이미지' 표기"),
|
| 520 |
-
h('span', { className: 'text-gray-500' }, aiLabel ? '화면·다운로드에 포함' : '표기 없음')),
|
| 521 |
-
h('button', { type: 'button', onClick: () => downloadWithLabel(current.imageUrl, `spao_${current.meta.shot}_${current.meta.angle}_${current.id}.png`, aiLabel),
|
| 522 |
-
className: 'h-10 px-4 rounded-xl bg-brand-blue hover:bg-brand-hover text-white text-[13px] font-semibold flex items-center gap-1.5' }, h(Download, { size: 15 }), '다운로드')))
|
| 523 |
-
: h('div', { className: 'absolute inset-0 flex flex-col items-center justify-center text-gray-500 gap-2' },
|
| 524 |
-
h(Upload, { size: 28, className: 'opacity-50' }),
|
| 525 |
-
h('p', { className: 'text-[13.5px]' }, '왼쪽에서 얼굴·의상을 고르고 룩북 생성을 누르면'),
|
| 526 |
-
h('p', { className: 'text-[13.5px]' }, '한 번에 모델컷이 생성됩니다.'))),
|
| 527 |
-
// 히스토리
|
| 528 |
-
h('div', null,
|
| 529 |
-
h('h3', { className: 'text-[13px] font-semibold text-gray-300 mb-2.5' }, `이번 세션 결과 ${results.length ? `(${results.length})` : ''}`),
|
| 530 |
-
results.length === 0
|
| 531 |
-
? h('p', { className: 'text-[12px] text-gray-500' }, '아직 없음')
|
| 532 |
-
: h('div', { className: 'grid grid-cols-3 md:grid-cols-1 gap-2' },
|
| 533 |
-
results.map(r => h('button', { key: r.id, type: 'button', onClick: () => setCurrent(r),
|
| 534 |
-
className: `relative rounded-xl overflow-hidden border-2 ${current?.id === r.id ? 'border-brand-blue' : 'border-transparent hover:border-[#4b5563]'}` },
|
| 535 |
-
h('img', { src: r.imageUrl, className: 'w-full h-auto block bg-white' }),
|
| 536 |
-
h('div', { className: 'absolute bottom-0 inset-x-0 px-2 py-1 bg-black/65 text-[10.5px] text-left leading-tight' },
|
| 537 |
-
h('div', null, `${r.meta.face ? r.meta.face + ' · ' : ''}${r.meta.shot} · ${r.meta.angle}`),
|
| 538 |
-
h('div', { className: 'text-gray-300' }, `${r.meta.gaze} · ${fmtSec(r.elapsedSec)}`))))))),
|
| 539 |
-
|
| 540 |
-
current && h('div', { className: 'mt-5 text-[12px] text-gray-500' },
|
| 541 |
-
`${current.meta.age} · ${current.meta.shot} · ${current.meta.angle} · ${current.meta.gaze}`, current.meta.prompt ? ` · "${current.meta.prompt}"` : ''),
|
| 542 |
-
current && (current.garmentSpecs || current.finalPrompt) && h('div', { className: 'mt-3 rounded-xl border border-[#2a2a2a] bg-[#202020]' },
|
| 543 |
-
h('button', { type: 'button', onClick: () => setShowSpecs(v => !v), className: 'w-full flex items-center justify-between px-4 py-2.5 text-[12.5px] font-semibold text-gray-300 hover:text-white' },
|
| 544 |
-
h('span', null, '의상 분석 결과 · 최종 프롬프트'), h('span', { className: 'text-gray-500 font-normal' }, showSpecs ? '접기' : '펼치기')),
|
| 545 |
-
showSpecs && h('div', { className: 'px-4 pb-4 space-y-3 animate-fadeIn' },
|
| 546 |
-
current.garmentSpecs && h('div', null,
|
| 547 |
-
h('div', { className: 'text-[11px] text-gray-500 mb-1' }, 'GPT 비전 의상 분석 (GARMENT SPECS)'),
|
| 548 |
-
h('pre', { className: 'text-[11.5px] text-gray-200 whitespace-pre-wrap break-words bg-[#1a1a1a] rounded-lg p-3 max-h-48 overflow-y-auto' }, current.garmentSpecs)),
|
| 549 |
-
current.finalPrompt && h('div', null,
|
| 550 |
-
h('div', { className: 'text-[11px] text-gray-500 mb-1' }, 'GPT-image에 전달된 최종 프롬프트'),
|
| 551 |
-
h('pre', { className: 'text-[11.5px] text-gray-300 whitespace-pre-wrap break-words bg-[#1a1a1a] rounded-lg p-3 max-h-64 overflow-y-auto' }, current.finalPrompt))))));
|
| 552 |
-
|
| 553 |
-
// ── Header ────────────────────────────────────────────────
|
| 554 |
-
const header = h('header', { className: 'h-14 shrink-0 border-b border-[#2a2a2a] bg-[#1a1a1a] flex items-center justify-between px-5' },
|
| 555 |
-
h('div', { className: 'flex items-center gap-5' },
|
| 556 |
-
h('div', { className: 'flex items-center gap-3' },
|
| 557 |
-
h('div', { className: 'w-8 h-8 rounded-lg bg-brand-blue flex items-center justify-center' }, h(Sparkles, { size: 16, className: 'text-white' })),
|
| 558 |
-
h('div', { className: 'text-[15px] font-bold tracking-tight' }, 'SPAO AI 룩북 생성기')),
|
| 559 |
-
user.oauth_enabled && h('div', { className: 'flex items-center gap-2 text-[12.5px] pl-5 border-l border-[#2a2a2a]' },
|
| 560 |
-
user.is_logged_in
|
| 561 |
-
? h(React.Fragment, null,
|
| 562 |
-
h('span', { className: 'text-gray-300' }, user.name || user.username),
|
| 563 |
-
h('a', { href: user.logout_url, className: 'text-gray-500 hover:text-white' }, '로그아웃'))
|
| 564 |
-
: h('a', { href: user.login_url, className: 'px-3 py-1.5 rounded-lg bg-[#2a2a2a] hover:bg-[#333] text-gray-100' }, '🤗 Hugging Face로 로그인'))),
|
| 565 |
-
h('div', null,
|
| 566 |
-
health && !health.ok && h('span', { className: 'inline-flex items-center gap-1.5 text-[12.5px] text-amber-400' },
|
| 567 |
-
h('span', { className: 'w-1.5 h-1.5 rounded-full bg-amber-400' }), 'Comfy 설정 필요')));
|
| 568 |
-
|
| 569 |
-
const lightboxEl = lightbox && current && h('div', {
|
| 570 |
-
className: 'fixed inset-0 z-50 bg-black/90 flex items-center justify-center animate-fadeIn cursor-zoom-out',
|
| 571 |
-
onClick: () => setLightbox(false) },
|
| 572 |
-
h('img', { src: current.imageUrl, alt: '생성 결과 확대', onClick: e => e.stopPropagation(),
|
| 573 |
-
className: 'max-w-[96vw] max-h-[96vh] object-contain bg-white cursor-default shadow-2xl' }),
|
| 574 |
-
aiLabel && h('div', { className: 'absolute top-4 right-16 text-[12px] text-gray-300 font-light pointer-events-none' }, AI_LABEL_TEXT),
|
| 575 |
-
h('button', { type: 'button', onClick: () => setLightbox(false), title: '닫기 (Esc)',
|
| 576 |
-
className: 'absolute top-4 right-4 w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 text-white flex items-center justify-center' }, h(X, { size: 18 })),
|
| 577 |
-
h('div', { className: 'absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2', onClick: e => e.stopPropagation() },
|
| 578 |
-
h('button', { type: 'button', onClick: () => downloadWithLabel(current.imageUrl, `spao_${current.meta.shot}_${current.meta.angle}_${current.id}.png`, aiLabel),
|
| 579 |
-
className: 'h-10 px-4 rounded-xl bg-brand-blue hover:bg-brand-hover text-white text-[13px] font-semibold flex items-center gap-1.5' }, h(Download, { size: 15 }), '다운로드')));
|
| 580 |
-
|
| 581 |
-
return h('div', { className: 'h-screen flex flex-col bg-[#1a1a1a]' }, header,
|
| 582 |
-
h('div', { className: 'flex-1 flex flex-col lg:flex-row min-h-0' }, left, right), l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