mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
feat: 增加拟人鼠标轨迹选择,Token 允许留空 (closes #12)
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user