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.

Add enable tauri new window open handling (For CLI).

GXiangbff7e448f428
diff --git a/bin/defaults.ts b/bin/defaults.ts
index 0eb784d8..37cb984c 100644
--- a/bin/defaults.ts
+++ b/bin/defaults.ts
@@ -47,6 +47,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
minWidth: 0,
minHeight: 0,
ignoreCertificateErrors: false,
+ enableTauriNewWindow: false,
};
// Just for cli development
diff --git a/bin/helpers/cli-program.ts b/bin/helpers/cli-program.ts
index dc5bf89a..3d173d14 100644
--- a/bin/helpers/cli-program.ts
+++ b/bin/helpers/cli-program.ts
@@ -221,6 +221,14 @@ ${green('|_| \\__,_|_|\\_\\___| can turn any webpage into a desktop app with
.default(DEFAULT.iterativeBuild)
.hideHelp(),
)
+ .addOption(
+ new Option(
+ '--enable-tauri-new-window',
+ "Enable Tauri's new window handling (instead of using external browser)",
+ )
+ .default(DEFAULT.enableTauriNewWindow)
+ .hideHelp(),
+ )
.version(packageJson.version, '-v, --version')
.configureHelp({
sortSubcommands: true,
diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts
index a88f94a7..0791f986 100644
--- a/bin/helpers/merge.ts
+++ b/bin/helpers/merge.ts
@@ -75,6 +75,7 @@ export async function mergeConfig(
minWidth,
minHeight,
ignoreCertificateErrors,
+ enableTauriNewWindow,
} = options;
const { platform } = process;
@@ -103,6 +104,7 @@ export async function mergeConfig(
min_width: minWidth,
min_height: minHeight,
ignore_certificate_errors: ignoreCertificateErrors,
+ enable_tauri_new_window: enableTauriNewWindow,
};
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
diff --git a/bin/types.ts b/bin/types.ts
index 8f6948a7..cc8f506c 100644
--- a/bin/types.ts
+++ b/bin/types.ts
@@ -114,6 +114,9 @@ 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;
}
export interface PakeAppOptions extends PakeCliOptions {
@@ -150,6 +153,7 @@ export interface WindowConfig {
min_width: number;
min_height: number;
ignore_certificate_errors: boolean;
+ enable_tauri_new_window: boolean;
}
export interface PakeConfig {
diff --git a/dist/cli.js b/dist/cli.js
index 406bbf96..66e9dbb5 100755
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -368,7 +368,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, } = 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, enableTauriNewWindow, } = options;
const { platform } = process;
const platformHideOnClose = hideOnClose ?? platform === 'darwin';
const tauriConfWindowOptions = {
@@ -393,6 +393,7 @@ async function mergeConfig(url, options, tauriConf) {
min_width: minWidth,
min_height: minHeight,
ignore_certificate_errors: ignoreCertificateErrors,
+ enable_tauri_new_window: enableTauriNewWindow,
};
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
tauriConf.productName = name;
@@ -1888,6 +1889,7 @@ const DEFAULT_PAKE_OPTIONS = {
minWidth: 0,
minHeight: 0,
ignoreCertificateErrors: false,
+ enableTauriNewWindow: false,
};
function validateNumberInput(value) {
@@ -2038,6 +2040,9 @@ ${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)
+ .hideHelp())
.version(packageJson.version, '-v, --version')
.configureHelp({
sortSubcommands: true,
diff --git a/docs/cli-usage.md b/docs/cli-usage.md
index ca1266b0..a621657d 100644
--- a/docs/cli-usage.md
+++ b/docs/cli-usage.md
@@ -481,6 +481,14 @@ Ignore TLS certificate validation errors when loading the target URL. Useful for
--ignore-certificate-errors
```
+#### [enable-tauri-new-window]
+
+Use the Tauri API to open a new window. Useful for third-party login pop-up authorization.
+
+```shell
+--enable-tauri-new-window
+```
+
### Packaging Complete
After completing the above steps, your application should be successfully packaged. Please note that the packaging process may take some time depending on your system configuration and network conditions. Be patient, and once the packaging is complete, you can find the application installer in the specified directory.
diff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.md
index 1536b1a8..309153c2 100644
--- a/docs/cli-usage_CN.md
+++ b/docs/cli-usage_CN.md
@@ -479,6 +479,14 @@ pake ./my-app/index.html --name "my-app" --use-local-file
--ignore-certificate-errors
```
+#### [enable-tauri-new-window]
+
+使用 Tauri API 打开新视窗,适用于第三方登入弹出视窗授权
+
+```shell
+--enable-tauri-new-window
+```
+
### 打包完成
完成上述步骤后,您的应用程序应该已经成功打包。请注意,根据您的系统配置和网络状况,打包过程可能需要一些时间。请耐心等待,一旦打包完成,您就可以在指定的目录中找到应用程序安装包。