mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-28 03:42:51 +08:00
增强浏览器启动选项:新增隐身模式支持,调整无头模式和窗口尺寸的配置,优化命令按钮的宽度设置
This commit is contained in:
parent
60db7be873
commit
4805cf6716
@ -107,10 +107,11 @@ const launchBrowser = async (options) => {
|
||||
const {
|
||||
browserType = "msedge",
|
||||
useSingleUserDataDir = true,
|
||||
headless = false,
|
||||
proxy = null,
|
||||
browserPath = getBrowserPath(browserType),
|
||||
windowSize = null,
|
||||
incognito = false,
|
||||
headless = false,
|
||||
} = options;
|
||||
|
||||
if (!browserPath) {
|
||||
@ -119,14 +120,28 @@ const launchBrowser = async (options) => {
|
||||
|
||||
const port = await findAvailablePort(9222);
|
||||
|
||||
const args = [
|
||||
const automationArgs = [
|
||||
`--remote-debugging-port=${port}`,
|
||||
"--disable-infobars",
|
||||
"--disable-notifications",
|
||||
"--disable-popup-blocking",
|
||||
"--disable-save-password-bubble",
|
||||
"--disable-translate",
|
||||
"--no-first-run",
|
||||
"--no-default-browser-check",
|
||||
"--start-maximized",
|
||||
headless ? "--headless" : "",
|
||||
windowSize ? `--window-size=${windowSize}` : "",
|
||||
"--user-data-start-with-quickcomposer",
|
||||
];
|
||||
|
||||
const incognitoArg = {
|
||||
chrome: "--incognito",
|
||||
msedge: "--inprivate",
|
||||
};
|
||||
|
||||
const optionArgs = [
|
||||
windowSize ? `--window-size=${windowSize}` : "--start-maximized",
|
||||
proxy ? `--proxy-server=${proxy}` : "",
|
||||
incognito ? incognitoArg[browserType] : "",
|
||||
headless ? "--headless" : "",
|
||||
useSingleUserDataDir
|
||||
? `--user-data-dir=${path.join(
|
||||
os.tmpdir(),
|
||||
@ -135,6 +150,8 @@ const launchBrowser = async (options) => {
|
||||
: "",
|
||||
].filter(Boolean);
|
||||
|
||||
const args = [...automationArgs, ...optionArgs];
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (!useSingleUserDataDir) {
|
||||
try {
|
||||
|
@ -55,12 +55,17 @@ export const browserCommands = {
|
||||
useSingleUserDataDir: {
|
||||
label: "使用独立用户数据目录",
|
||||
component: "CheckButton",
|
||||
width: 6,
|
||||
width: 4,
|
||||
},
|
||||
headless: {
|
||||
label: "启用无头模式",
|
||||
label: "无头模式",
|
||||
component: "CheckButton",
|
||||
width: 6,
|
||||
width: 4,
|
||||
},
|
||||
incognito: {
|
||||
label: "隐身模式",
|
||||
component: "CheckButton",
|
||||
width: 4,
|
||||
},
|
||||
windowSize: {
|
||||
label: "窗口尺寸",
|
||||
@ -97,6 +102,7 @@ export const browserCommands = {
|
||||
browserType: "msedge",
|
||||
useSingleUserDataDir: true,
|
||||
headless: false,
|
||||
incognito: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user