229 |
배경 설정
230 |
231 | {/* 배경 타입 선택 */}
232 |
233 |
242 |
251 |
260 |
261 |
262 | {/* 타입별 설정 */}
263 | {backgroundType === 'image' && (
264 |
265 |
266 |
📁 컴퓨터에서 이미지 선택:
267 |
268 | JPG, PNG, GIF, WebP 지원 (최대 5MB)
269 |
270 | {tempImage && (
271 |
272 | ⚠️ 새 이미지 업로드시 기존 이미지가 교체됩니다 (서버에서 자동 삭제)
273 |
274 | )}
275 |
276 |
{
281 | const file = e.target.files?.[0]
282 | if (!file) return
283 |
284 | // 파일 크기 체크
285 | if (file.size > 5 * 1024 * 1024) {
286 | alert('파일 크기는 5MB 이하여야 합니다')
287 | return
288 | }
289 |
290 | // 파일 업로드
291 | const formData = new FormData()
292 | formData.append('file', file)
293 | // storageKey를 기반으로 purpose 설정
294 | const purpose = storageKey ? storageKey.replace('-background', '') + '-background' : 'background'
295 | formData.append('purpose', purpose)
296 | formData.append('oldPath', tempImage || '')
297 |
298 | try {
299 | const response = await fetch('/api/upload-image', {
300 | method: 'POST',
301 | body: formData
302 | })
303 |
304 | const result = await response.json()
305 |
306 | if (result.success) {
307 | setTempImage(result.path)
308 | detectImageAspect(result.path)
309 | handleSave('image', result.path)
310 | alert('✅ 배경 이미지가 업로드되었습니다!')
311 | } else {
312 | alert(`❌ ${result.error}`)
313 | }
314 | } catch {
315 | alert('업로드 중 오류가 발생했습니다')
316 | }
317 | }}
318 | className="hidden"
319 | />
320 |
327 |
328 |
329 | {
333 | setTempImage(e.target.value)
334 | if (e.target.value) {
335 | detectImageAspect(e.target.value)
336 | }
337 | }}
338 | placeholder="또는 URL 직접 입력 (https://...)"
339 | className="w-full px-3 py-2 border rounded-lg bg-background"
340 | />
341 |
342 |
343 | )}
344 |
345 | {backgroundType === 'video' && (
346 |
347 |
348 |
📁 컴퓨터에서 비디오 선택:
349 |
350 | MP4, WebM 지원 (최대 20MB)
351 |
352 | {tempVideo && (
353 |
354 | ⚠️ 새 비디오 업로드시 기존 비디오가 교체됩니다 (서버에서 자동 삭제)
355 |
356 | )}
357 |
358 |
{
363 | const file = e.target.files?.[0]
364 | if (!file) return
365 |
366 | // 파일 크기 체크 (비디오는 20MB까지)
367 | if (file.size > 20 * 1024 * 1024) {
368 | alert('비디오 파일 크기는 20MB 이하여야 합니다')
369 | return
370 | }
371 |
372 | // 파일 업로드
373 | const formData = new FormData()
374 | formData.append('file', file)
375 | // storageKey를 기반으로 purpose 설정
376 | const purpose = storageKey ? storageKey.replace('-background', '') + '-background-video' : 'background-video'
377 | formData.append('purpose', purpose)
378 | formData.append('oldPath', tempVideo || '')
379 |
380 | try {
381 | const response = await fetch('/api/upload-video', {
382 | method: 'POST',
383 | body: formData
384 | })
385 |
386 | const result = await response.json()
387 |
388 | if (result.success) {
389 | setTempVideo(result.path)
390 | handleSave('video', result.path)
391 | alert('✅ 배경 비디오가 업로드되었습니다!')
392 | } else {
393 | alert(`❌ ${result.error}`)
394 | }
395 | } catch {
396 | alert('업로드 중 오류가 발생했습니다')
397 | }
398 | }}
399 | className="hidden"
400 | />
401 |
408 |
409 |
410 | setTempVideo(e.target.value)}
414 | placeholder="또는 URL 직접 입력 (YouTube, Vimeo 등)"
415 | className="w-full px-3 py-2 border rounded-lg bg-background"
416 | />
417 |
418 |
419 | )}
420 |
421 | {backgroundType === 'color' && (
422 |
423 | setTempColor(e.target.value)}
427 | className="w-full h-20 border rounded-lg cursor-pointer"
428 | />
429 |
430 | )}
431 |
432 | {/* 투명도 설정 */}
433 |
434 |
437 | setTempOpacity(parseFloat(e.target.value))}
444 | className="w-full"
445 | />
446 |
447 |
448 | {/* 버튼들 */}
449 |
450 | {/* 기본으로 설정 버튼 */}
451 |
502 |
503 | {/* 적용/취소 버튼 */}
504 |
505 |
514 |
520 |
521 |
522 |