Issue#1 第二轮对齐交付入库: 通道列表 20列→8列双语义聚合+编辑页分组深度对齐+Chrome 会话工具——①ChannelList.vue 8 列=ID/运营商·通道名称(名称+协议tag+兜底tag+运营商中文标签)/企业ID·速度(sp_id/单速×连接=总速)/接入码·地址/上家/优先级·限额(P值·权重/日限·夜间禁发)/状态switch/操作,删 7 低频列(信息保留在编辑页与回执抽屉),carrierLabels() 码值→中文;②ChannelEdit.vue 通道号(接入码)02基本信息→04通道配置(http 通道也有接入码,v-if 块外)、02 组内顺序对齐参考平台(盈讯通 33 字段 collapse 范式)、行式交替排布;③scripts/chrome-session.mjs 真浏览器会话工具(Chrome 157 channel=chrome,每会话独立 launch+单 page 铁律);门禁=eslint 0 警/vue-tsc 0/vitest 148 全绿/build 9.68s(本次复验 RC=0);Chrome 实机 VERIFY_PASS(上会话截图 /tmp/verify-list-v2.png);memory-bank 同步;工单评论待用户贴 Gitea
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// chrome-session.mjs — 宿主 CPU 缺陷(8173M error 25)约束下的 Playwright+系统Chrome 会话工具
|
||||
//
|
||||
// 背景(2026-11-15 实测,详见 memory-bank/techContext):
|
||||
// - Playwright 自带 chromium:newPage 即 Target crashed,不可用
|
||||
// - 官方 Google Chrome 157(channel:'chrome'):可用,但**同一 browser 第 2 个 newPage 必崩**
|
||||
// (renderer segfault error 25 @ 固定偏移 0x90b1f9,zombie 后 newPage 永久挂起)
|
||||
// - 稳定口径 = 每会话独立 launch + 单 page 内 goto 导航(实测 5/5 与 4/5[失败仅外网网络])
|
||||
//
|
||||
// 用法:
|
||||
// node scripts/chrome-session.mjs <url> [--shot 路径前缀] [--wait ms]
|
||||
// 登录参考平台等复杂场景:复制本脚本 runSession() 回调改造(env 传账号,勿硬编码)
|
||||
//
|
||||
// 环境要求:web/node_modules(playwright)、google-chrome-stable(已装 157)
|
||||
|
||||
import { chromium } from '../web/node_modules/playwright/index.mjs';
|
||||
|
||||
const withTimeout = (p, ms, tag) =>
|
||||
Promise.race([p, new Promise((_, rej) => setTimeout(() => rej(new Error(tag + ' TIMEOUT')), ms))]);
|
||||
|
||||
const ARGS = ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'];
|
||||
const launch = () => withTimeout(chromium.launch({ channel: 'chrome', args: ARGS }), 20000, 'launch');
|
||||
|
||||
export async function runSession({ url, onReady, shotPrefix = '/tmp/chrome-session', waitMs = 2000, retries = 2 }) {
|
||||
for (let attempt = 1; attempt <= retries + 1; attempt++) {
|
||||
let browser;
|
||||
try {
|
||||
browser = await launch();
|
||||
const page = await withTimeout(browser.newPage(), 15000, 'newPage'); // 铁律:本会话唯一 page,后续一律 page.goto
|
||||
await withTimeout(page.goto(url, { timeout: 20000, waitUntil: 'domcontentloaded' }), 30000, 'goto');
|
||||
await page.waitForTimeout(waitMs);
|
||||
if (onReady) await onReady(page);
|
||||
const title = await withTimeout(page.title(), 10000, 'title');
|
||||
await withTimeout(page.screenshot({ path: `${shotPrefix}.png`, fullPage: true }), 20000, 'shot');
|
||||
return { ok: true, title, url: page.url() };
|
||||
} catch (e) {
|
||||
console.error(`[chrome-session] attempt ${attempt} FAIL: ${e.message}`);
|
||||
if (attempt > retries) return { ok: false, error: e.message };
|
||||
await new Promise((r) => setTimeout(r, 1500));
|
||||
} finally {
|
||||
if (browser) await browser.close().catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// CLI 直跑:node scripts/chrome-session.mjs http://127.0.0.1:5173/
|
||||
if (process.argv[1] && process.argv[1].endsWith('chrome-session.mjs')) {
|
||||
const url = process.argv[2] || 'http://127.0.0.1:5173/';
|
||||
const r = await runSession({ url });
|
||||
console.log(JSON.stringify(r));
|
||||
process.exit(r.ok ? 0 : 1);
|
||||
}
|
||||
Reference in New Issue
Block a user