update view port
This commit is contained in:
parent
26f894c7bc
commit
b7e7ab2b45
2
.env
2
.env
|
|
@ -1,4 +1,4 @@
|
|||
PORT=3456
|
||||
HEADLESS=false
|
||||
HEADLESS=true
|
||||
# CHROME_PATH=/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
|
||||
API_KEY=
|
||||
|
|
|
|||
|
|
@ -40,14 +40,21 @@ class BrowserManager {
|
|||
console.log(`[${this._tag}] Sử dụng: ${chromePath || 'bundled Chromium'}`);
|
||||
console.log(`[${this._tag}] Profile : ${this.profileDir}`);
|
||||
|
||||
const isHeadless = process.env.HEADLESS === 'true';
|
||||
// NotebookLM ẩn cột Sources khi cửa sổ quá hẹp — cần viewport rộng
|
||||
const WIN_W = parseInt(process.env.WINDOW_WIDTH || '1920', 10);
|
||||
const WIN_H = parseInt(process.env.WINDOW_HEIGHT || '1080', 10);
|
||||
|
||||
const opts = {
|
||||
headless: process.env.HEADLESS === 'true',
|
||||
headless: isHeadless,
|
||||
userDataDir: this.profileDir,
|
||||
defaultViewport: null,
|
||||
// headless=true: --start-maximized không có tác dụng, phải set viewport tường minh
|
||||
defaultViewport: isHeadless ? { width: WIN_W, height: WIN_H } : null,
|
||||
args: [
|
||||
'--no-sandbox',
|
||||
'--disable-setuid-sandbox',
|
||||
'--disable-infobars',
|
||||
`--window-size=${WIN_W},${WIN_H}`,
|
||||
'--start-maximized',
|
||||
'--no-default-browser-check',
|
||||
'--no-first-run',
|
||||
|
|
@ -76,6 +83,11 @@ class BrowserManager {
|
|||
this.page = null;
|
||||
});
|
||||
|
||||
// Đảm bảo viewport đủ rộng (headless không auto-maximize)
|
||||
if (isHeadless) {
|
||||
await this.page.setViewport({ width: WIN_W, height: WIN_H });
|
||||
}
|
||||
|
||||
// macOS: kéo cửa sổ lên trước (chỉ slot 0)
|
||||
if (process.platform === 'darwin' && this.slotIndex === 0) {
|
||||
setTimeout(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue