feat: 新增一键打开渠道脚本

This commit is contained in:
duanshuwen
2026-03-12 22:31:18 +08:00
parent 236f4c7dc1
commit 792746bfb2
7 changed files with 98 additions and 114 deletions

View File

@@ -12,10 +12,12 @@ const preparePage = async (chromium, { tabIndex = Number(process.env.TAB_INDEX),
const idx = Number.isFinite(tabIndex) && tabIndex >= 0 ? Math.floor(tabIndex) : 0;
let pages = await context.pages();
while (pages.length <= idx) {
await context.newPage();
pages = await context.pages();
}
const page = pages[idx];
await page.bringToFront();
@@ -24,6 +26,7 @@ const preparePage = async (chromium, { tabIndex = Number(process.env.TAB_INDEX),
const safeDisconnectBrowser = async (browser) => {
if (!browser) return;
try {
if (typeof browser.disconnect === 'function') {
await browser.disconnect();