feat(工作台): 视频列表加收藏列+数字列右对齐,视频详情页信息三行+标签排版
This commit is contained in:
1 parent
3d65774fe1
commit
7e3d6c74fa
12 files changed
+830
-27
No files matched your search
@@ -0,0 +1,83 @@
|
||||
/* cdp-verify-noall.mjs — 验证批量条去掉全选后,表头全选仍正常(09-01)
|
||||
* 验证:①批量模式下批量条内无全选(batch-cb-all 只在表头)②点表头全选→计数=行数 ③取消全选→计数 0
|
||||
* 运行:node cdp-verify-noall.mjs
|
||||
*/
|
||||
const CDP = 'http://127.0.0.1:9223';
|
||||
async function getWs(targetId) {
|
||||
const tabs = await (await fetch(CDP + '/json')).json();
|
||||
const t = tabs.find((x) => x.id === targetId);
|
||||
if (!t) throw new Error('target not found: ' + targetId);
|
||||
return t.webSocketDebuggerUrl;
|
||||
}
|
||||
function cdp(ws, method, params = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const id = ++cdp._id;
|
||||
const w = new WebSocket(ws);
|
||||
const timer = setTimeout(() => { try { w.close(); } catch (e) {} reject(new Error('timeout: ' + method)); }, 30000);
|
||||
w.onopen = () => w.send(JSON.stringify({ id, method, params }));
|
||||
w.onmessage = (ev) => {
|
||||
const m = JSON.parse(ev.data);
|
||||
if (m.id !== id) return;
|
||||
clearTimeout(timer);
|
||||
try { w.close(); } catch (e) {}
|
||||
m.error ? reject(new Error(method + ': ' + JSON.stringify(m.error))) : resolve(m.result);
|
||||
};
|
||||
w.onerror = () => { clearTimeout(timer); reject(new Error('ws error: ' + method)); };
|
||||
});
|
||||
}
|
||||
cdp._id = 0;
|
||||
async function evalJs(ws, expr) {
|
||||
const r = await cdp(ws, 'Runtime.evaluate', { expression: expr, awaitPromise: true, returnByValue: true });
|
||||
if (r.exceptionDetails) throw new Error('eval err: ' + JSON.stringify(r.exceptionDetails).slice(0, 300));
|
||||
return r.result && r.result.value;
|
||||
}
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
async function main() {
|
||||
const tabs = await (await fetch(CDP + '/json')).json();
|
||||
const tab = tabs.find((x) => x.url.includes('localhost:8900')) || tabs.find((x) => x.type === 'page');
|
||||
if (!tab) throw new Error('no 8900 tab found');
|
||||
const ws = await getWs(tab.id);
|
||||
await cdp(ws, 'Page.enable');
|
||||
await cdp(ws, 'Runtime.enable');
|
||||
|
||||
let pass = 0, fail = 0;
|
||||
const check = (name, cond) => { cond ? pass++ : fail++; console.log((cond ? 'PASS' : 'FAIL') + ' | ' + name); };
|
||||
|
||||
for (const [name, hash, rowSel] of [
|
||||
['账号列表', '#/accounts', '.table tbody tr'],
|
||||
['AI写脚本列表', '#/rewrites', '.table tbody tr']
|
||||
]) {
|
||||
await cdp(ws, 'Page.navigate', { url: 'http://localhost:8900/?v=noall' + hash });
|
||||
await sleep(2200);
|
||||
await evalJs(ws, `document.querySelector('[data-batch-open]')?.click()`);
|
||||
await sleep(600);
|
||||
const r = await evalJs(ws, `(() => {
|
||||
const inBar = document.querySelectorAll('.list-batchbar .batch-cb-all').length;
|
||||
const inHead = document.querySelectorAll('thead .batch-cb-all').length;
|
||||
const rows = document.querySelectorAll('${rowSel} .batch-cb').length;
|
||||
const hasLabel = document.querySelectorAll('.batch-all-label').length;
|
||||
// 表头全选 → 计数
|
||||
const head = document.querySelector('thead .batch-cb-all');
|
||||
if (head) { head.click(); }
|
||||
return { inBar, inHead, rows, hasLabel };
|
||||
})()`);
|
||||
await sleep(300);
|
||||
const cnt = await evalJs(ws, `Number(document.querySelector('.batch-count-n')?.textContent || -1)`);
|
||||
check(name + ' 批量条内无全选', r.inBar === 0);
|
||||
check(name + ' 表头有全选框', r.inHead === 1);
|
||||
check(name + ' 批量条内无全选 label', r.hasLabel === 0);
|
||||
check(name + ' 点表头全选→计数=行数(' + r.rows + ')', cnt === r.rows && r.rows > 0);
|
||||
// 取消全选
|
||||
await evalJs(ws, `document.querySelector('thead .batch-cb-all').click()`);
|
||||
await sleep(300);
|
||||
const cnt2 = await evalJs(ws, `Number(document.querySelector('.batch-count-n')?.textContent || -1)`);
|
||||
check(name + ' 再点取消全选→计数 0', cnt2 === 0);
|
||||
await evalJs(ws, `document.querySelector('[data-batch-cancel]')?.click()`);
|
||||
await sleep(300);
|
||||
}
|
||||
|
||||
console.log(`\n结果: ${pass} PASS / ${fail} FAIL`);
|
||||
process.exit(fail ? 1 : 0);
|
||||
}
|
||||
main().catch((e) => { console.error('ERROR:', e.message); process.exit(1); });
|
||||
Reference in new issue
Block a user