diff --git a/preview/check-live.mjs b/preview/check-live.mjs index c775b0b..2abc227 100644 --- a/preview/check-live.mjs +++ b/preview/check-live.mjs @@ -103,6 +103,22 @@ async function main() { await shot('live-05-report.png') } + if (process.argv.includes('--each')) { + result.each = [] + const n = await evaluate("document.querySelectorAll('.ssw-seat').length") + for (let i = 0; i < n; i++) { + await evaluate(`(() => { const s = document.querySelectorAll('.ssw-seat'); if (s[${i}]) s[${i}].click(); return true })()`) + await sleep(1200) + const info = await evaluate(`(() => ({ + name: document.querySelector('.ssw-current-name')?.innerText?.trim() ?? null, + notice: document.querySelector('.ssw-notice')?.innerText?.trim() ?? null, + selected: document.querySelector('.ssw-seat[aria-pressed=true] .ssw-role-name')?.innerText?.trim() ?? null, + }))()`) + await shot('seat-' + String(i + 1).padStart(2, '0') + '.png') + result.each.push({ i: i + 1, ...info }) + } + } + if (process.argv.includes('--seat')) { const clicked = await evaluate("(() => { const s = document.querySelectorAll('.ssw-seat'); if (s.length >= 10) { s[9].click(); return true } return false })()") await sleep(1500) @@ -130,7 +146,8 @@ async function main() { } } result.pass = !!(result.entry?.found && result.workbench?.found && (result.workbench?.seatCount === 10 || result.workbench?.enableText) - && (!process.argv.includes('--report') || (result.report?.count === 10 && result.report.items.every(it => it.name && it.text)))) + && (!process.argv.includes('--report') || (result.report?.count === 10 && result.report.items.every(it => it.name && it.text))) + && (!process.argv.includes('--each') || result.each?.length === 10)) } try { await main() } catch (error) { result.fatal = String(error?.stack ?? error) } finally { try { ws?.close() } catch {}; try { browser?.kill() } catch {} } diff --git a/preview/montage.py b/preview/montage.py new file mode 100644 index 0000000..4219e9f --- /dev/null +++ b/preview/montage.py @@ -0,0 +1,27 @@ +from PIL import Image, ImageDraw, ImageFont +seats = [("丞相","e35483b1"),("中书","4e278758"),("尚书","2e65d691"),("门下","78223c4a"),("吏部","cf800860"), + ("户部","82262be8"),("礼部","1f2aeec7"),("兵部","2ce3587b"),("刑部","57f94de8"),("工部","857831f9")] +crop = (772, 0, 1440, 900) +tw, th = 300, 397 +cols, rows, pad, labelh = 5, 2, 10, 24 +tiles = [] +for i in range(1, 11): + im = Image.open(f"preview/seat-{i:02d}.png").convert("RGB").crop(crop).resize((tw, th)) + tiles.append(im) +W = cols * tw + (cols + 1) * pad +H = rows * (th + labelh) + (rows + 1) * pad +canvas = Image.new("RGB", (W, H), "white") +d = ImageDraw.Draw(canvas) +try: + font = ImageFont.truetype("C:/Windows/Fonts/msyh.ttc", 15) +except Exception: + font = ImageFont.load_default() +for idx, (name, sid) in enumerate(seats): + r, c = idx // cols, idx % cols + x = pad + c * (tw + pad) + y = pad + r * (th + labelh + pad) + canvas.paste(tiles[idx], (x, y)) + d.rectangle([x, y + th, x + tw, y + th + labelh], fill="#eef4ff") + d.text((x + 6, y + th + 4), f"{name} {sid}", fill="#1f2a3a", font=font) +canvas.save("preview/seats-contact.png") +print("saved", canvas.size) diff --git a/preview/seat-01.png b/preview/seat-01.png new file mode 100644 index 0000000..99e0425 Binary files /dev/null and b/preview/seat-01.png differ diff --git a/preview/seat-02.png b/preview/seat-02.png new file mode 100644 index 0000000..99e0425 Binary files /dev/null and b/preview/seat-02.png differ diff --git a/preview/seat-03.png b/preview/seat-03.png new file mode 100644 index 0000000..99e0425 Binary files /dev/null and b/preview/seat-03.png differ diff --git a/preview/seat-04.png b/preview/seat-04.png new file mode 100644 index 0000000..99e0425 Binary files /dev/null and b/preview/seat-04.png differ diff --git a/preview/seat-05.png b/preview/seat-05.png new file mode 100644 index 0000000..99e0425 Binary files /dev/null and b/preview/seat-05.png differ diff --git a/preview/seat-06.png b/preview/seat-06.png new file mode 100644 index 0000000..99e0425 Binary files /dev/null and b/preview/seat-06.png differ diff --git a/preview/seat-07.png b/preview/seat-07.png new file mode 100644 index 0000000..99e0425 Binary files /dev/null and b/preview/seat-07.png differ diff --git a/preview/seat-08.png b/preview/seat-08.png new file mode 100644 index 0000000..99e0425 Binary files /dev/null and b/preview/seat-08.png differ diff --git a/preview/seat-09.png b/preview/seat-09.png new file mode 100644 index 0000000..99e0425 Binary files /dev/null and b/preview/seat-09.png differ diff --git a/preview/seat-10.png b/preview/seat-10.png new file mode 100644 index 0000000..166cfdd Binary files /dev/null and b/preview/seat-10.png differ diff --git a/preview/seats-contact.png b/preview/seats-contact.png new file mode 100644 index 0000000..933016d Binary files /dev/null and b/preview/seats-contact.png differ diff --git a/preview/seats-summary.mjs b/preview/seats-summary.mjs new file mode 100644 index 0000000..d78199d --- /dev/null +++ b/preview/seats-summary.mjs @@ -0,0 +1,10 @@ +import fs from 'node:fs' +const r = JSON.parse(fs.readFileSync('preview/each.json', 'utf8')) +const st = JSON.parse(fs.readFileSync('C:/Users/qyh15/.dsh-test-b/sansheng/state.json', 'utf8')) +const proj = Object.values(st.projects)[0] +const seats = proj ? Object.values(proj.seats) : [] +console.log(JSON.stringify({ + pass: r.pass, + each: r.each, + seats: seats.map(s => ({ seat: s.seatId, session: (s.sessionId || '').slice(0, 8), status: s.status })), +}, null, 2))