diff --git a/app/modules/live/CLAUDE.md b/app/modules/live/CLAUDE.md index fd1e75b..6d757ec 100644 --- a/app/modules/live/CLAUDE.md +++ b/app/modules/live/CLAUDE.md @@ -22,6 +22,7 @@ - **한 화면 맞춤**(2026-11-05) — 달력 보기는 넓은 화면(1101px 이상)에서 페이지 세로 스크롤 없음: `.lv-cal-wrap` 이 남은 높이를 쓰고, 풀HD 브라우저(세로 880px 이상)면 방송이 없는 달은 18개 시간 칸·합계 줄이 표 안 스크롤 없이 들어간다(카드가 있는 줄은 카드 높이만큼 커져서 방송이 많으면 표 안에서 스크롤, 페이지는 안 움직임). **방송이 걸친 칸은 합친다**(2026-11-06, `store._covered_slots` → `rowspan`, 가려진 칸 `skip`) — 2시간 방송 = 두 칸, 끝이 정각이 아니면 그 칸까지, 자정 넘김은 그날 마지막 칸까지. 합친 칸 안에서 시작하는 다른 방송은 같은 칸에 들어가고 칸이 더 늘어난다(겹친 방송). 끌어 놓기는 합친 칸의 첫 시간으로. 카드·표 글자·칸 크기를 늘리면 `live_calendar.browser.test.js` 로 다시 확인. - **오른쪽 달력**(2026-11-05, 달력 보기만, 세로 2분할 `.lv-split`, 240px = 공용 달력의 80%, 예전 날짜로 이동 줄 대신, 공용 `erp-datepop` `mountRange` + `locale` 옵션으로 영문) — 날짜를 누르면 그 날이 표 맨 왼쪽(마지막 날까지 — `endGap` 이 표 끝에 여백), 다른 달이면 그 달 화면으로 가서 맨 왼쪽(sessionStorage `lv_cal_jump`). 표시만 하고 요금·일수에 안 씀. 글자 굵게, **방송 있는 날 = 숫자 오른쪽 위 초록 점**(2026-11-06, `db.broadcast_days` 보는 달 ±1년 → `#lv-live-days`, 공용 `mountRange` 의 `dayClass` 옵션 → `has-live`). 테스트 `tests/js/live_calendar.browser.test.js`(`render_live.py`). **말레이시아 공휴일 표 = `holidays.py`**(쿠알라룸푸르 기준, 2026·2027, 대체휴일 포함) — 이슬람 명절은 달 관측으로 바뀔 수 있고, 2028 은 공고되면 손으로 추가. +- **결과 이미지 미리보기**(2026-11-06, 달력 보기) — 카드 오른쪽 아래 이미지 링크(`a[data-preview]`)에 마우스를 올리거나 탭으로 가면 오른쪽 달력 아래 빈 곳(`#lv-preview`, `.lv-side` 세로 줄)에 첫 장을 보여 주고 벗어나면 숨김. 링크를 누르면 예전처럼 새 탭. 좁은 화면(1100px 이하)은 미리보기 없음. - **결과 이미지 → 매출 자동 입력**(2026-11-06, `ocr.py`, `POST /live/broadcasts/read-sales`) — 창에서 이미지를 고르면 서버의 Tesseract(Dockerfile 에서 설치, 외부 전송 없음)가 이미지 **위 절반**을 읽어 첫 `RM` 금액(틱톡 LIVE 결과 화면의 Attr. GMV)을 판매금액 칸에 채운다(저장 안 함 — 사람이 확인 후 저장, 여러 장이면 찾을 때까지 한 장씩). `RM1.2K` 처럼 줄인 값·못 찾음 = 칸 그대로 + 안내. tesseract 가 없으면(로컬 개발 PC) 안내만. - **결과 이미지** — 방송 저장과 한 트랜잭션, JPG·PNG·WebP, 한 장 8MB, 방송당 10장(`store.MAX_IMAGES`). `prepare_photo` 가 실제 이미지 확인·긴 변 2400px·EXIF(GPS 등) 제거. BYTEA 저장. `GET /live/images/{id}`(권한 필요, 하루 private 캐시), `?thumb=1` = 160px JPEG(그때그때 만듦). 올린 뒤 내용이 안 바뀐다는 전제 — 이미지를 고치는 기능을 넣으면 캐시도 바꿀 것. diff --git a/app/modules/live/templates/live/_scripts.html b/app/modules/live/templates/live/_scripts.html index 9fbe4f8..320c013 100644 --- a/app/modules/live/templates/live/_scripts.html +++ b/app/modules/live/templates/live/_scripts.html @@ -1,2 +1,2 @@ - + diff --git a/app/modules/live/templates/live/calendar.html b/app/modules/live/templates/live/calendar.html index c15015d..4914f82 100644 --- a/app/modules/live/templates/live/calendar.html +++ b/app/modules/live/templates/live/calendar.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {#- 라이브 커머스 달력 보기(2026-11-04) — 줄 = 2시간 칸, 열 = 날짜, 맨 아래 = 날짜별 합계. 카드 머리 = 호스트 간단한 이름 + 그 방송의 틱톡 계정. 카드 머리를 끌어 빈 칸으로 옮기거나 다른 카드 위에 놓아 맞바꾼다(live.js). 문구 = t()(i18n.py), 영문은 CSS 로 대문자(받은 화면과 같게). -#} -{% block head_extra %} +{% block head_extra %} {% endblock %} @@ -49,7 +49,7 @@
{{ t('판매금액') }}{{ c.card_sales }}
{{ t('커미션') }} ({{ cal.commission_percent }}%){{ c.card_commission }}
- + {% endfor %} {% if not cell.cards and hosts | selectattr('is_active') | list %} @@ -79,7 +79,11 @@ {#- 화면 오른쪽 위에 붙는 달력 — 날짜를 누르면 그 날이 표 맨 왼쪽(live.js), 말레이시아 공휴일(holidays.py) -#} - +
+ + {#- 카드의 이미지 링크에 마우스를 올리면 달력 아래 빈 곳에 결과 이미지(live.js) -#} + +
{% include "live/_dialog.html" %} diff --git a/app/modules/live/templates/live/index.html b/app/modules/live/templates/live/index.html index 99bd371..a4dc4da 100644 --- a/app/modules/live/templates/live/index.html +++ b/app/modules/live/templates/live/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {#- 라이브 커머스 스케줄표(2026-11-04) — 달마다 방송 목록. 추가·고치기 창은 달력과 공용(_dialog.html, live.js). 문구 = t()(i18n.py). -#} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
diff --git a/app/modules/live/templates/live/settings.html b/app/modules/live/templates/live/settings.html index a25a985..9d9e140 100644 --- a/app/modules/live/templates/live/settings.html +++ b/app/modules/live/templates/live/settings.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {#- 라이브 커머스 설정(2026-11-04) — 호스트 정보. 계좌 등 개인정보·지우기는 ERP 관리자만(router.settings), 칩 권한자는 이름·상태만 보임 — `live_host` = 새 등록, `live_host_edit` = 고치기(개인정보는 빈칸으로 열림, 비워 두면 그대로). 추가·고치기는 같은 창(live.js). 문구 = t()(i18n.py). -#} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %} {#- 쇼핑몰(005, store.PLATFORMS) — 로고는 말레이시아 배송 모듈 이미지 -#} diff --git a/app/static/live.css b/app/static/live.css index 953c249..c1614f1 100644 --- a/app/static/live.css +++ b/app/static/live.css @@ -54,10 +54,18 @@ } @media (max-width: 1100px) { .lv-split { grid-template-columns: minmax(0, 1fr); } - .lv-side-cal { order: -1; max-width: 340px; } + .lv-side { order: -1; max-width: 340px; } + .lv-preview { display: none; } /* 좁은 화면(휴대폰)은 마우스 올리기가 없음 — 링크를 누르면 새 탭 */ } +/* 오른쪽 줄 = 달력 + 그 아래 빈 곳에 결과 이미지 미리보기(카드의 이미지 링크에 마우스를 올린 동안) */ +.lv-side { display: flex; flex-direction: column; gap: 10px; min-height: 0; } +.lv-preview { flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; min-height: 0; margin: 0; padding: 8px; border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; + box-shadow: 0 8px 24px rgba(15, 23, 42, .14); } +.lv-preview[hidden] { display: none; } +.lv-preview img { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; object-position: top; } +.lv-preview figcaption { flex: none; font-size: 10.5px; font-weight: 600; color: #4b5563; text-align: center; } /* 오른쪽 달력 = 공용 달력의 80% */ -.lv-side-cal { align-self: start; box-sizing: border-box; padding: 10px; border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; font-size: 10.4px; } +.lv-side-cal { flex: none; box-sizing: border-box; padding: 10px; border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; font-size: 10.4px; } .lv-side-cal .pj-dp-nav { margin: 0 0 4px; } .lv-side-cal .pj-dp-title { font-size: 11.2px; } .lv-side-cal .pj-dp-navbtn { width: 22px; height: 22px; } diff --git a/app/static/live.js b/app/static/live.js index 654fefb..09bc15e 100644 --- a/app/static/live.js +++ b/app/static/live.js @@ -215,6 +215,23 @@ else if (left !== null) calWrap.scrollLeft = Number(left); else if (todayHead) jumpTo(todayHead.dataset.day); + // ── 달력: 카드의 이미지 링크에 마우스를 올리거나 탭으로 가면 오른쪽 달력 아래에 결과 이미지(첫 장), 벗어나면 숨김 ── + const preview = document.getElementById("lv-preview"); + if (preview) { + const pImg = preview.querySelector("img"), pCap = preview.querySelector("figcaption"); + const linkOf = function (el) { return el && el.closest && el.closest("a[data-preview]"); }; + const show = function (a) { + if (pImg.getAttribute("src") !== a.getAttribute("href")) pImg.src = a.getAttribute("href"); + pImg.alt = a.title; + pCap.textContent = a.dataset.preview; + preview.hidden = false; + }; + calWrap.addEventListener("mouseover", function (e) { const a = linkOf(e.target); if (a) show(a); }); + calWrap.addEventListener("mouseout", function (e) { const a = linkOf(e.target); if (a && !a.contains(e.relatedTarget)) preview.hidden = true; }); + calWrap.addEventListener("focusin", function (e) { const a = linkOf(e.target); if (a) show(a); }); + calWrap.addEventListener("focusout", function (e) { if (linkOf(e.target)) preview.hidden = true; }); + } + // ── 달력: 날짜별 광고비 ── document.addEventListener("click", async function (e) { const b = e.target.closest("button[data-spend]"); diff --git a/tests/js/live_calendar.browser.test.js b/tests/js/live_calendar.browser.test.js index 3d87908..05223b3 100644 --- a/tests/js/live_calendar.browser.test.js +++ b/tests/js/live_calendar.browser.test.js @@ -26,6 +26,9 @@ function check(name, cond, extra) { const type = f.endsWith(".css") ? "text/css" : f.endsWith(".js") ? "application/javascript" : "font/woff2"; return r.fulfill({ status: 200, contentType: type, body: fs.readFileSync(f) }); } + if (u.pathname.startsWith("/live/images/")) { // 결과 이미지 미리보기 — 아무 그림이나 + return r.fulfill({ status: 200, contentType: "image/png", body: fs.readFileSync(path.join(ROOT, "app", "static", "dispatch", "courier", "tiktok.png")) }); + } const page = u.pathname === "/live/calendar" ? (u.searchParams.get("month") === "2026-12" ? "live_cal_dec.html" : "live_cal_ko.html") : u.pathname.slice(1); if (!page.endsWith(".html")) return r.fulfill({ status: 200, contentType: "application/json", body: "{}" }); r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: fs.readFileSync(path.join(__dirname, ".out", page), "utf8") }); @@ -127,6 +130,22 @@ function check(name, cond, extra) { }); check("합친 칸 높이 = 두 줄", tall < 2, tall); await p.screenshot({ path: path.join(__dirname, ".out", "live_merge.png") }); + // 이미지 링크에 마우스 → 오른쪽 달력 아래 미리보기, 벗어나면 숨김 + const imgLink = p.locator('td[data-day="2026-11-05"][data-start="06:00"] a[data-preview]'); + check("미리보기 처음엔 숨김", await p.locator("#lv-preview").isHidden()); + await imgLink.hover(); + await p.waitForTimeout(200); + const pv = await p.evaluate(function () { + const box = document.getElementById("lv-preview"), cal = document.getElementById("lv-side-cal").getBoundingClientRect(), b = box.getBoundingClientRect(); + const img = box.querySelector("img"); + return { hidden: box.hidden, src: img.getAttribute("src"), loaded: img.naturalWidth > 0, cap: box.querySelector("figcaption").textContent, + below: b.top >= cal.bottom, sameCol: Math.abs(b.left - cal.left) < 2 && Math.abs(b.width - cal.width) < 2, bottom: b.bottom <= window.innerHeight }; + }); + check("이미지 링크에 마우스 = 달력 아래 미리보기", !pv.hidden && pv.src === "/live/images/7" && pv.loaded && pv.below && pv.sameCol && pv.bottom && pv.cap.includes("1/2"), pv); + await p.screenshot({ path: path.join(__dirname, ".out", "live_preview.png") }); + await p.mouse.move(5, 5); + await p.waitForTimeout(100); + check("벗어나면 숨김", await p.locator("#lv-preview").isHidden()); await p.locator('#lv-side-cal [data-nav="1"]').click(); await Promise.all([p.waitForURL(/month=2026-12/), day("2026-12-10").click()]); diff --git a/tests/js/render_live.py b/tests/js/render_live.py index c750e44..b3fa9b8 100644 --- a/tests/js/render_live.py +++ b/tests/js/render_live.py @@ -36,7 +36,8 @@ class Fake: return [] # 운영 화면처럼 — 6·8·16시 칸에 카드(세 줄 모두 카드가 있으면 그 줄이 가장 높다), 모든 시간 칸을 채워 높이 최악으로 return [{"id": h, "host_id": 1, "host_name": "Nabella", "tiktok_handle": "MainAccount", "broadcast_date": date(2026, 11, 5), "start_time": time(h), - "end_time": time(h + 2), "venue": "", "sales_amount": Decimal("500"), "images": []} for h in range(6, 24, 2) if h < 22] + \ + "end_time": time(h + 2), "venue": "", "sales_amount": Decimal("500"), + "images": [{"id": 7, "filename": "r.png"}, {"id": 8, "filename": "s.png"}] if h == 6 else []} for h in range(6, 24, 2) if h < 22] + \ [{"id": 22, "host_id": 1, "host_name": "Nabella", "tiktok_handle": "MainAccount", "broadcast_date": date(2026, 11, 5), "start_time": time(22), "end_time": time(23, 30), "venue": "", "sales_amount": Decimal("500"), "images": []}]