fix: 修复脚本依次执行问题

This commit is contained in:
duanshuwen
2026-03-25 22:03:51 +08:00
parent 15139bd606
commit 280abcecbe
12 changed files with 15 additions and 314 deletions

View File

@@ -51,8 +51,7 @@ export function runTaskOperationService() {
['fzName', 'fg_trace.js'],
['mtName', 'mt_trace.js'],
['dyHotelName', 'dy_hotel_trace.js'],
['dyHotSpringName', 'dy_hot_spring_trace.js'],
['xcName', 'xc_trace.js'],
['dyHotSpringName', 'dy_hot_spring_trace.js']
]
const scriptEntries = pairs.filter(([prop]) => roomType?.[prop])
@@ -75,9 +74,14 @@ export function runTaskOperationService() {
dyHotelName: 'douyin',
dyHotSpringName: 'douyin',
}
const defaultTabIndexMap: Record<string, number> = {
fliggy: 0,
meituan: 1,
douyin: 2
}
const mappedName = channelNameMap[item.channel]
const tabIndex = mappedName ? (openedTabIndexByChannelName.get(mappedName) ?? i) : i
log.info(`Launching script for channel ${item.channel}: ${item.scriptPath}`)
const tabIndex = mappedName ? (openedTabIndexByChannelName.get(mappedName) ?? defaultTabIndexMap[mappedName] ?? i) : i
log.info(`Launching script for channel ${item.channel}: ${item.scriptPath} (tabIndex: ${tabIndex})`)
const result = await executeScriptServiceInstance.executeScript(item.scriptPath, {
roomType: roomType[item.channel],
startTime: options.startTime,

View File

@@ -24,6 +24,7 @@ const isSameOrigin = (currentUrl, targetUrl) => {
const current = normalizeUrl(currentUrl);
const target = normalizeUrl(targetUrl);
if (!current || !target) return false;
return current.origin === target.origin;
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 KiB

View File

@@ -220,5 +220,6 @@ const navigateToRoomStatusManagement = async (page) => {
process.exitCode = 1;
} finally {
await safeDisconnectBrowser(browser);
process.exit(process.exitCode || 0);
}
})();

View File

@@ -220,5 +220,6 @@ const navigateToRoomStatusManagement = async (page) => {
process.exitCode = 1;
} finally {
await safeDisconnectBrowser(browser);
process.exit(process.exitCode || 0);
}
})();

View File

@@ -169,5 +169,6 @@ const toggleRoomByDateIndex = async (container, { roomType, dateIndex, operation
process.exitCode = 1;
} finally {
await safeDisconnectBrowser(browser);
process.exit(process.exitCode || 0);
}
})();

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

View File

@@ -232,5 +232,6 @@ const toggleRoom = async (page, { roomType, mmdd, operation }) => {
process.exitCode = 1;
} finally {
await safeDisconnectBrowser(browser);
process.exit(process.exitCode || 0);
}
})();

View File

@@ -128,5 +128,6 @@ const isBlankLikePage = (url) => {
}
} catch {}
}
process.exit(process.exitCode || 0);
}
})();

View File

@@ -1,4 +0,0 @@
import log from 'electron-log';
log.info('xc_trace.mjs placeholder: not implemented');
process.exit(0);

View File

@@ -46,6 +46,6 @@ export async function launchLocalChrome() {
// 延迟几秒等浏览器起来
setTimeout(() => {
resolve(0);
}, 3000); // 延迟3
}, 1000); // 延迟1
});
}