feat: 增加拟人鼠标轨迹选择,Token 允许留空 (closes #12)

This commit is contained in:
foxhui
2026-01-24 03:24:49 +08:00
parent f7bcddc91b
commit a85b731ce1
43 changed files with 210 additions and 63 deletions
+13 -4
View File
@@ -65,13 +65,22 @@ async function generate(context, prompt, imgPaths, modelId, meta = {}) {
document.execCommand('insertText', false, text);
}, searchText);
// 等待下拉选项出现后再按回车
// 等待过滤完成:第一个选项包含目标模型的主 ID
// searchText 可能是 codeName(含括号说明),但过滤后的选项应该包含 modelId
try {
await page.waitForSelector('[role="option"]', { timeout: 5000 });
await page.waitForFunction(
(targetId) => {
const firstOption = document.querySelector('[role="option"]');
return firstOption && firstOption.textContent?.includes(targetId);
},
modelId,
{ timeout: 5000 }
);
} catch {
// 超时也继续,可能选项已经存在
// 超时也继续,可能列表结构不同
logger.debug('适配器', `等待模型选项过滤超时,继续执行`, meta);
}
await sleep(200, 300);
await sleep(300, 500);
await page.keyboard.press('Enter');
}