feat: 新增一键打开渠道脚本
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user