fix: launch external pickup directly on target url
This commit is contained in:
parent
d39c77324a
commit
9b9c6f17e4
@ -24,6 +24,8 @@ export interface ExternalLaunchOptions {
|
||||
extraArgs?: string[];
|
||||
/** 独立用户数据目录;缺省使用系统临时目录下的独立 profile */
|
||||
userDataDir?: string;
|
||||
/** 首次启动时直接打开的 URL,避免先出现 about:blank */
|
||||
initialUrl?: string;
|
||||
}
|
||||
|
||||
export interface ExternalRemoteOptions {
|
||||
@ -225,12 +227,13 @@ export async function launchExternalBrowser(options: ExternalLaunchOptions): Pro
|
||||
await fs.mkdir(userDataDir, { recursive: true });
|
||||
|
||||
const extraArgs = (options.extraArgs ?? []).filter(Boolean);
|
||||
const startUrl = options.initialUrl?.trim() || "about:blank";
|
||||
const args = [
|
||||
`--remote-debugging-port=${port}`,
|
||||
`--user-data-dir=${userDataDir}`,
|
||||
"--no-first-run",
|
||||
"--no-default-browser-check",
|
||||
"about:blank",
|
||||
startUrl,
|
||||
...extraArgs
|
||||
];
|
||||
|
||||
|
||||
@ -119,7 +119,9 @@ function registerIpc(): void {
|
||||
const browserOptions = options.browser;
|
||||
let session;
|
||||
if (browserOptions) {
|
||||
session = await externalBrowserSession(browserOptions);
|
||||
session = await externalBrowserSession(
|
||||
browserOptions.mode === "launch" && url ? { ...browserOptions, initialUrl: url } : browserOptions
|
||||
);
|
||||
} else {
|
||||
session = latestExternalSession();
|
||||
}
|
||||
@ -130,7 +132,7 @@ function registerIpc(): void {
|
||||
session = await BrowserSession.create();
|
||||
}
|
||||
const currentUrl = await session.currentUrl();
|
||||
if (url && (currentUrl === "about:blank" || currentUrl !== url)) {
|
||||
if (url && currentUrl !== url) {
|
||||
await session.navigate(url);
|
||||
}
|
||||
return session.pickElement();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user