seawolf2357 commited on
Commit
e16fe27
Β·
verified Β·
1 Parent(s): 803a0e1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -14
app.py CHANGED
@@ -54,7 +54,7 @@ PDF_FILES = {
54
  }
55
  }
56
 
57
- # ν˜„μž¬ μ„ νƒλœ PDF (κΈ°λ³Έκ°’: prompt)
58
  current_pdf_key = "prompt"
59
 
60
  pdf_cache: Dict[str, Dict[str, Any]] = {}
@@ -609,6 +609,11 @@ async def cache_pdf(pdf_path: str):
609
 
610
  @app.on_event("startup")
611
  async def startup_event():
 
 
 
 
 
612
  if PROMPT_PDF_PATH.exists():
613
  logger.info(f"prompt.pdf 파일 발견: {PROMPT_PDF_PATH}")
614
  # ν”Œλ¦½λΆ 캐싱
@@ -1921,6 +1926,7 @@ HTML = """
1921
  let isAiProcessing = false;
1922
  let hasLoadedSummary = false;
1923
  let analysisCheckInterval = null;
 
1924
  let currentPdfKey = 'prompt';
1925
  let isPdfSwitching = false;
1926
 
@@ -2313,6 +2319,17 @@ HTML = """
2313
  }
2314
  }
2315
 
 
 
 
 
 
 
 
 
 
 
 
2316
  async function switchPDF(pdfKey) {
2317
  if (isPdfSwitching || pdfKey === currentPdfKey) return;
2318
 
@@ -2337,10 +2354,7 @@ HTML = """
2337
  hideLoading();
2338
  showError(switchResult.error || "PDF μ „ν™˜μ— μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.");
2339
  isPdfSwitching = false;
2340
- document.querySelectorAll('.floating-pdf-btn').forEach(btn => {
2341
- btn.classList.remove('loading');
2342
- if (btn.dataset.pdf === currentPdfKey) btn.classList.add('active');
2343
- });
2344
  return;
2345
  }
2346
 
@@ -2364,11 +2378,7 @@ HTML = """
2364
  await loadPDF();
2365
 
2366
  // λ²„νŠΌ μƒνƒœ μ΅œμ’… μ—…λ°μ΄νŠΈ
2367
- document.querySelectorAll('.floating-pdf-btn').forEach(btn => {
2368
- btn.classList.remove('loading');
2369
- btn.classList.remove('active');
2370
- if (btn.dataset.pdf === pdfKey) btn.classList.add('active');
2371
- });
2372
 
2373
  isPdfSwitching = false;
2374
 
@@ -2377,10 +2387,7 @@ HTML = """
2377
  hideLoading();
2378
  showError("PDF μ „ν™˜ 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.");
2379
  isPdfSwitching = false;
2380
- document.querySelectorAll('.floating-pdf-btn').forEach(btn => {
2381
- btn.classList.remove('loading');
2382
- if (btn.dataset.pdf === currentPdfKey) btn.classList.add('active');
2383
- });
2384
  }
2385
  }
2386
 
@@ -2397,6 +2404,14 @@ HTML = """
2397
  return;
2398
  }
2399
 
 
 
 
 
 
 
 
 
2400
  updateLoading("PDF λ‘œλ”© 쀑...", 10);
2401
 
2402
  if (pdfInfo.cached) {
@@ -2469,6 +2484,7 @@ HTML = """
2469
  $id('pdfPromptBtn').addEventListener('click', () => switchPDF('prompt'));
2470
  $id('pdfKtxBtn').addEventListener('click', () => switchPDF('ktx'));
2471
 
 
2472
  loadPDF();
2473
  });
2474
  </script>
 
54
  }
55
  }
56
 
57
+ # ν˜„μž¬ μ„ νƒλœ PDF (κΈ°λ³Έκ°’: prompt) - μ„œλ²„ μ‹œμž‘ μ‹œ 항상 prompt둜 μ΄ˆκΈ°ν™”
58
  current_pdf_key = "prompt"
59
 
60
  pdf_cache: Dict[str, Dict[str, Any]] = {}
 
609
 
610
  @app.on_event("startup")
611
  async def startup_event():
612
+ global current_pdf_key
613
+ # μ„œλ²„ μ‹œμž‘ μ‹œ 항상 prompt둜 μ΄ˆκΈ°ν™”
614
+ current_pdf_key = "prompt"
615
+ logger.info(f"μ„œλ²„ μ‹œμž‘ - κΈ°λ³Έ PDF: {current_pdf_key}")
616
+
617
  if PROMPT_PDF_PATH.exists():
618
  logger.info(f"prompt.pdf 파일 발견: {PROMPT_PDF_PATH}")
619
  # ν”Œλ¦½λΆ 캐싱
 
1926
  let isAiProcessing = false;
1927
  let hasLoadedSummary = false;
1928
  let analysisCheckInterval = null;
1929
+ // 기본값을 prompt둜 μ„€μ • (μ„œλ²„μ™€ 동기화됨)
1930
  let currentPdfKey = 'prompt';
1931
  let isPdfSwitching = false;
1932
 
 
2319
  }
2320
  }
2321
 
2322
+ // λ²„νŠΌ active μƒνƒœ μ—…λ°μ΄νŠΈ ν•¨μˆ˜
2323
+ function updatePdfButtonState(pdfKey) {
2324
+ document.querySelectorAll('.floating-pdf-btn').forEach(btn => {
2325
+ btn.classList.remove('active');
2326
+ btn.classList.remove('loading');
2327
+ if (btn.dataset.pdf === pdfKey) {
2328
+ btn.classList.add('active');
2329
+ }
2330
+ });
2331
+ }
2332
+
2333
  async function switchPDF(pdfKey) {
2334
  if (isPdfSwitching || pdfKey === currentPdfKey) return;
2335
 
 
2354
  hideLoading();
2355
  showError(switchResult.error || "PDF μ „ν™˜μ— μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.");
2356
  isPdfSwitching = false;
2357
+ updatePdfButtonState(currentPdfKey);
 
 
 
2358
  return;
2359
  }
2360
 
 
2378
  await loadPDF();
2379
 
2380
  // λ²„νŠΌ μƒνƒœ μ΅œμ’… μ—…λ°μ΄νŠΈ
2381
+ updatePdfButtonState(currentPdfKey);
 
 
 
 
2382
 
2383
  isPdfSwitching = false;
2384
 
 
2387
  hideLoading();
2388
  showError("PDF μ „ν™˜ 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.");
2389
  isPdfSwitching = false;
2390
+ updatePdfButtonState(currentPdfKey);
 
 
 
2391
  }
2392
  }
2393
 
 
2404
  return;
2405
  }
2406
 
2407
+ // β˜…β˜…β˜… 핡심 μˆ˜μ •: μ„œλ²„ μƒνƒœμ™€ ν΄λΌμ΄μ–ΈνŠΈ μƒνƒœ 동기화 β˜…β˜…β˜…
2408
+ if (pdfInfo.key) {
2409
+ currentPdfKey = pdfInfo.key;
2410
+ // λ²„νŠΌ active μƒνƒœ 동기화
2411
+ updatePdfButtonState(currentPdfKey);
2412
+ console.log('PDF 동기화 μ™„λ£Œ:', currentPdfKey, pdfInfo.display_name);
2413
+ }
2414
+
2415
  updateLoading("PDF λ‘œλ”© 쀑...", 10);
2416
 
2417
  if (pdfInfo.cached) {
 
2484
  $id('pdfPromptBtn').addEventListener('click', () => switchPDF('prompt'));
2485
  $id('pdfKtxBtn').addEventListener('click', () => switchPDF('ktx'));
2486
 
2487
+ // νŽ˜μ΄μ§€ λ‘œλ“œ μ‹œ PDF λ‘œλ“œ (μ„œλ²„μ—μ„œ κΈ°λ³Έ PDF 정보 κ°€μ Έμ˜΄)
2488
  loadPDF();
2489
  });
2490
  </script>