Compare commits
No commits in common. "main" and "main" have entirely different histories.
2
.env
2
.env
|
|
@ -1,4 +1,4 @@
|
||||||
PORT=3456
|
PORT=3456
|
||||||
HEADLESS=true
|
HEADLESS=false
|
||||||
# CHROME_PATH=/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
|
# CHROME_PATH=/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
|
||||||
API_KEY=
|
API_KEY=
|
||||||
|
|
|
||||||
|
|
@ -40,21 +40,14 @@ class BrowserManager {
|
||||||
console.log(`[${this._tag}] Sử dụng: ${chromePath || 'bundled Chromium'}`);
|
console.log(`[${this._tag}] Sử dụng: ${chromePath || 'bundled Chromium'}`);
|
||||||
console.log(`[${this._tag}] Profile : ${this.profileDir}`);
|
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 = {
|
const opts = {
|
||||||
headless: isHeadless,
|
headless: process.env.HEADLESS === 'true',
|
||||||
userDataDir: this.profileDir,
|
userDataDir: this.profileDir,
|
||||||
// headless=true: --start-maximized không có tác dụng, phải set viewport tường minh
|
defaultViewport: null,
|
||||||
defaultViewport: isHeadless ? { width: WIN_W, height: WIN_H } : null,
|
|
||||||
args: [
|
args: [
|
||||||
'--no-sandbox',
|
'--no-sandbox',
|
||||||
'--disable-setuid-sandbox',
|
'--disable-setuid-sandbox',
|
||||||
'--disable-infobars',
|
'--disable-infobars',
|
||||||
`--window-size=${WIN_W},${WIN_H}`,
|
|
||||||
'--start-maximized',
|
'--start-maximized',
|
||||||
'--no-default-browser-check',
|
'--no-default-browser-check',
|
||||||
'--no-first-run',
|
'--no-first-run',
|
||||||
|
|
@ -83,11 +76,6 @@ class BrowserManager {
|
||||||
this.page = null;
|
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)
|
// macOS: kéo cửa sổ lên trước (chỉ slot 0)
|
||||||
if (process.platform === 'darwin' && this.slotIndex === 0) {
|
if (process.platform === 'darwin' && this.slotIndex === 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue