Skip to content

Commit

Permalink
feat(app): 添加设置窗口大小功能,配合脚本使用
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Sep 24, 2023
1 parent b0d5158 commit 1b8c207
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/app/src/worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ function browserNetworkRoute(actions_key: string, browser: BrowserContext) {
if (!page) {
return;
}

try {
const action = search.get('action') || '';
if (action === 'mouse-move') {
Expand Down Expand Up @@ -521,6 +522,13 @@ function browserNetworkRoute(actions_key: string, browser: BrowserContext) {
responses.delete(url);
return await route.fulfill({ status: 200, body: res });
}
} else if (action === 'set-viewport') {
const width = search.get('width');
const height = search.get('height');
if (width && height) {
await page.setViewportSize({ width: Number(width), height: Number(height) });
return await route.fulfill({ status: 200, body: 'OK' });
}
}
} catch (e) {
console.error(e);
Expand Down

0 comments on commit 1b8c207

Please # to comment.