Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

feat: add --new-window option for third-party login popup (#1106)

Tw9393613a3f84ea
diff --git a/bin/defaults.ts b/bin/defaults.ts
index 37cb984c..e05b124c 100644
--- a/bin/defaults.ts
+++ b/bin/defaults.ts
@@ -47,7 +47,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
minWidth: 0,
minHeight: 0,
ignoreCertificateErrors: false,
- enableTauriNewWindow: false,
+ newWindow: false,
};
// Just for cli development
diff --git a/bin/helpers/cli-program.ts b/bin/helpers/cli-program.ts
index 3d173d14..13da6df4 100644
--- a/bin/helpers/cli-program.ts
+++ b/bin/helpers/cli-program.ts
@@ -223,10 +223,10 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
)
.addOption(
new Option(
- '--enable-tauri-new-window',
- "Enable Tauri's new window handling (instead of using external browser)",
+ '--new-window',
+ 'Allow new window for third-party login',
)
- .default(DEFAULT.enableTauriNewWindow)
+ .default(DEFAULT.newWindow)
.hideHelp(),
)
.version(packageJson.version, '-v, --version')
diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts
index aeaab696..82b545a1 100644
--- a/bin/helpers/merge.ts
+++ b/bin/helpers/merge.ts
@@ -76,7 +76,7 @@ export async function mergeConfig(
minWidth,
minHeight,
ignoreCertificateErrors,
- enableTauriNewWindow,
+ newWindow,
} = options;
const { platform } = process;
@@ -105,7 +105,7 @@ export async function mergeConfig(
min_width: minWidth,
min_height: minHeight,
ignore_certificate_errors: ignoreCertificateErrors,
- enable_tauri_new_window: enableTauriNewWindow,
+ new_window: newWindow,
};
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
diff --git a/bin/types.ts b/bin/types.ts
index cc8f506c..a8f865c1 100644
--- a/bin/types.ts
+++ b/bin/types.ts
@@ -115,8 +115,8 @@ export interface PakeCliOptions {
// Turn on rapid build mode (app only, no dmg/deb/msi), good for debugging
iterativeBuild: boolean;
- // Enable Tauri's new window handling (instead of using external browser), default false
- enableTauriNewWindow: boolean;
+ // Allow new window for third-party login, default false
+ newWindow: boolean;
}
export interface PakeAppOptions extends PakeCliOptions {
@@ -153,7 +153,7 @@ export interface WindowConfig {
min_width: number;
min_height: number;
ignore_certificate_errors: boolean;
- enable_tauri_new_window: boolean;
+ new_window: boolean;
}
export interface PakeConfig {
diff --git a/dist/cli.js b/dist/cli.js
index c8025e2d..4bc9fbc5 100644
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -484,7 +484,7 @@ async function mergeConfig(url, options, tauriConf) {
await fsExtra.copy(sourcePath, destPath);
}
}));
- const { width, height, fullscreen, maximize, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name = 'pake-app', resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, enableDragDrop, multiInstance, startToTray, forceInternalNavigation, zoom, minWidth, minHeight, ignoreCertificateErrors, enableTauriNewWindow, } = options;
+ const { width, height, fullscreen, maximize, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name = 'pake-app', resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, enableDragDrop, multiInstance, startToTray, forceInternalNavigation, zoom, minWidth, minHeight, ignoreCertificateErrors, newWindow, } = options;
const { platform } = process;
const platformHideOnClose = hideOnClose ?? platform === 'darwin';
const tauriConfWindowOptions = {
@@ -509,7 +509,7 @@ async function mergeConfig(url, options, tauriConf) {
min_width: minWidth,
min_height: minHeight,
ignore_certificate_errors: ignoreCertificateErrors,
- enable_tauri_new_window: enableTauriNewWindow,
+ new_window: newWindow,
};
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
tauriConf.productName = name;
@@ -1926,7 +1926,7 @@ const DEFAULT_PAKE_OPTIONS = {
minWidth: 0,
minHeight: 0,
ignoreCertificateErrors: false,
- enableTauriNewWindow: false,
+ newWindow: false,
};
function validateNumberInput(value) {
@@ -2077,8 +2077,8 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
.addOption(new Option('--iterative-build', 'Turn on rapid build mode (app only, no dmg/deb/msi), good for debugging')
.default(DEFAULT_PAKE_OPTIONS.iterativeBuild)
.hideHelp())
- .addOption(new Option('--enable-tauri-new-window', "Enable Tauri's new window handling (instead of using external browser)")
- .default(DEFAULT_PAKE_OPTIONS.enableTauriNewWindow)
+ .addOption(new Option('--new-window', 'Allow new window for third-party login')
+ .default(DEFAULT_PAKE_OPTIONS.newWindow)
.hideHelp())
.version(packageJson.version, '-v, --version')
.configureHelp({
diff --git a/docs/cli-usage.md b/docs/cli-usage.md
index a621657d..4ed2ad34 100644
--- a/docs/cli-usage.md
+++ b/docs/cli-usage.md
@@ -481,12 +481,12 @@ Ignore TLS certificate validation errors when loading the target URL. Useful for
--ignore-certificate-errors
```
-#### [enable-tauri-new-window]
+#### [new-window]
-Use the Tauri API to open a new window. Useful for third-party login pop-up authorization.
+Allow new window for third-party login authorization.
```shell
---enable-tauri-new-window
+--new-window
```
### Packaging Complete
diff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.md
index 309153c2..d47ccbb8 100644
--- a/docs/cli-usage_CN.md
+++ b/docs/cli-usage_CN.md
@@ -479,12 +479,12 @@ pake ./my-app/index.html --name "my-app" --use-local-file
--ignore-certificate-errors
```
-#### [enable-tauri-new-window]
+#### [new-window]
-使用 Tauri API 打开新视窗,适用于第三方登入弹出视窗授权
+允许弹出新窗口,适用于第三方登录授权。
```shell
---enable-tauri-new-window
+--new-window
```
### 打包完成
diff --git a/src-tauri/pake.json b/src-tauri/pake.json
index ae40f822..88133feb 100644
--- a/src-tauri/pake.json
+++ b/src-tauri/pake.json
@@ -19,7 +19,7 @@
"maximize": false,
"start_to_tray": false,
"force_internal_navigation": false,
- "enable_tauri_new_window": false
+ "new_window": false
}
],
"user_agent": {
diff --git a/src-tauri/src/app/config.rs b/src-tauri/src/app/config.rs
index a708dfe6..f9402c6c 100644
--- a/src-tauri/src/app/config.rs
+++ b/src-tauri/src/app/config.rs
@@ -19,7 +19,7 @@ pub struct WindowConfig {
pub title: Option<String>,
pub enable_wasm: bool,
pub enable_drag_drop: bool,
- pub enable_tauri_new_window: bool,
+ pub new_window: bool,
pub start_to_tray: bool,
#[serde(default)]
pub force_internal_navigation: bool,
diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs
index 13a00dd2..4cb2fd1d 100644
--- a/src-tauri/src/app/window.rs
+++ b/src-tauri/src/app/window.rs
@@ -82,10 +82,9 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) ->
window_builder = window_builder.disable_drag_drop_handler();
}
- if window_config.enable_tauri_new_window {
- window_builder = window_builder.on_new_window(move |_url, _features| {
- tauri::webview::NewWindowResponse::Allow
- })
+ if window_config.new_window {
+ window_builder = window_builder
+ .on_new_window(move |_url, _features| tauri::webview::NewWindowResponse::Allow);
}
// Add initialization scripts