This commit is contained in:
oneao committed 2026-10-15 17:31:35 +08:00
1 parent b4498e5350
commit bf9dca19de
47 files changed
+8592 -313

No files matched your search

@@ -0,0 +1,71 @@
import { chromium } from '@playwright/test'
/**
* 用**正确阈值**重测。
* 之前的探针用 r<246 判"深色",而表头底色是 245 → 被误判成线。
* 边框线是 217,白底是 255,表头灰是 245。
* 正确判据:只看接近 217 的像素(容差 ±6),把 245 和 255 都当作"非线"。
*/
const BASE = process.env.PROBE_URL || 'http://localhost:5200'
const LINE = 217
const TOL = 6
const isLine = ([r, g, b]) =>
Math.abs(r - LINE) <= TOL && Math.abs(g - LINE) <= TOL && Math.abs(b - LINE) <= TOL
const browser = await chromium.launch()
const page = await browser.newPage({ viewport: { width: 1400, height: 1200 } })
await page.goto(BASE, { waitUntil: 'networkidle' })
const clipSample = async (x, y, w, h) => {
const shot = await page.screenshot({ clip: { x, y, width: w, height: h } })
return page.evaluate(async (dataUrl) => {
const img = new Image()
await new Promise((res) => {
img.onload = res
img.src = dataUrl
})
const cv = document.createElement('canvas')
cv.width = img.width
cv.height = img.height
const ctx = cv.getContext('2d')
ctx.drawImage(img, 0, 0)
const d = ctx.getImageData(0, 0, img.width, img.height).data
const out = []
for (let i = 0; i < d.length; i += 4) out.push([d[i], d[i + 1], d[i + 2]])
return out
}, `data:image/png;base64,${shot.toString('base64')}`)
}
const heights = [500, 400, 350, 300, 250, 200, 180, 160, 150, 140, 130, 120, 110, 100, 90, 80]
console.log('=== 正确阈值(只认 217±6,245/255 均视为非线)===')
console.log('容器高 | 底边像素(217线) | 线数 | 判定')
let bad = 0
for (const h of heights) {
await page.evaluate((hh) => {
document.querySelector('[data-testid="table-big-wrap"]').style.height = `${hh}px`
}, h)
await page.waitForTimeout(420)
await page.locator('[data-testid="table-big-wrap"]').scrollIntoViewIfNeeded()
await page.waitForTimeout(180)
const g = await page.evaluate(() => {
const wrap = document.querySelector('[data-testid="table-big-wrap"]')
const root = wrap.querySelector('.g3-table')
const r = root.getBoundingClientRect()
return { left: Math.round(r.left), bottom: Math.round(r.bottom) }
})
const y = Math.max(0, g.bottom - 5)
if (1200 - y < 12) continue
const px = await clipSample(g.left + 300, y, 1, 12)
const vec = px.map((p) => (isLine(p) ? 1 : 0))
const n = vec.reduce((a, b) => a + b, 0)
if (n !== 1) bad += 1
console.log(
`${String(h).padStart(6)} | ${vec.join('')} | ${String(n).padStart(4)} | ${n === 1 ? '✅ 一条线' : n === 0 ? '❌ 缺线' : '❌ ' + n + ' 条'}`,
)
}
console.log(`\n失败档位: ${bad} 个`)
await browser.close()