Skip to content

Commit 5c6e452

Browse files
committed
chore: 测试触发懒加载
1 parent c25f976 commit 5c6e452

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

src/backend/adapter/gemini.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import {
1515
moveMouseAway,
1616
waitForInput,
1717
gotoWithCheck,
18-
waitApiResponse,
19-
scrollToElement
18+
waitApiResponse
2019
} from '../utils/index.js';
2120
import { logger } from '../../utils/logger.js';
2221

@@ -174,8 +173,9 @@ async function generate(context, prompt, imgPaths, modelId, meta = {}) {
174173
meta
175174
});
176175

177-
// 将图片滚动到可视范围,触发懒加载
178-
await scrollToElement(page, 'generated-image', { timeout: 120000 });
176+
// 等待图片元素出现,然后在chat-history上滚动触发懒加载
177+
await page.locator('generated-image').waitFor({ state: 'attached', timeout: 120000 });
178+
await safeScroll(page, '#chat-history', { deltaY: 700 });
179179
imageResponse = await imageResponsePromise;
180180
} catch (e) {
181181
const pageError = normalizePageError(e, meta);

src/backend/adapter/zai_is.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ async function generate(context, prompt, imgPaths, modelId, meta = {}) {
137137
await waitForInput(page, INPUT_SELECTOR, { click: false });
138138
await sleep(1500, 2500);
139139

140-
// 2. 上传图片 (如果有多张图片,会一张一张上传,每次都是 v1/files POST 请求)
141-
if (imgPaths && imgPaths.length > 0) {
140+
// 2. 并行执行:上传图片 + 填写提示词
141+
const uploadTask = (imgPaths && imgPaths.length > 0) ? (async () => {
142142
const expectedUploads = imgPaths.length;
143143
let uploadedCount = 0;
144144

@@ -155,13 +155,20 @@ async function generate(context, prompt, imgPaths, modelId, meta = {}) {
155155
return false;
156156
}
157157
});
158+
await sleep(500, 1000);
159+
})() : Promise.resolve();
158160

159-
await sleep(1000, 2000);
160-
}
161+
const promptTask = (async () => {
162+
// 等待一小段时间,让图片上传先开始(pasteImages 会先点击输入框)
163+
if (imgPaths && imgPaths.length > 0) {
164+
await sleep(800, 1200);
165+
}
166+
await safeClick(page, INPUT_SELECTOR, { bias: 'input' });
167+
await fillPrompt(page, INPUT_SELECTOR, prompt, meta);
168+
})();
161169

162-
// 3. 填写提示词
163-
await safeClick(page, INPUT_SELECTOR, { bias: 'input' });
164-
await fillPrompt(page, INPUT_SELECTOR, prompt, meta);
170+
// 等待两个任务都完成
171+
await Promise.all([uploadTask, promptTask]);
165172
await sleep(500, 1000);
166173

167174
// 4. 通过 UI 交互选择模型

0 commit comments

Comments
 (0)