Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
:bug: Optimize the multi-platform experience of hide on close
Tw9385943b813434
diff --git a/bin/cli.ts b/bin/cli.tsindex a79de43d..9d63f9fd 100644--- a/bin/cli.ts+++ b/bin/cli.ts@@ -125,7 +125,7 @@ program.hideHelp(),).addOption(- new Option('--hide-on-close', 'Hide window on close instead of exiting')+ new Option('--hide-on-close', 'Hide window on close instead of exiting (default: true for macOS, false for others)').default(DEFAULT.hideOnClose).hideHelp(),)diff --git a/bin/defaults.ts b/bin/defaults.tsindex dd388704..2597d77f 100644--- a/bin/defaults.ts+++ b/bin/defaults.ts@@ -22,7 +22,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {debug: false,inject: [],installerLanguage: 'en-US',- hideOnClose: true,+ hideOnClose: undefined, // Platform-specific: true for macOS, false for othersincognito: false,wasm: false,};diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.tsindex 6456d84a..1d630ff5 100644--- a/bin/helpers/merge.ts+++ b/bin/helpers/merge.ts@@ -65,6 +65,9 @@ export async function mergeConfig(const { platform } = process;+ // Platform-specific hide_on_close behavior: macOS keeps true, others default to false+ const platformHideOnClose = hideOnClose ?? (platform === 'darwin');+// Set Windows parameters.const tauriConfWindowOptions = {width,@@ -76,7 +79,7 @@ export async function mergeConfig(always_on_top: alwaysOnTop,dark_mode: darkMode,disabled_web_shortcuts: disabledWebShortcuts,- hide_on_close: hideOnClose,+ hide_on_close: platformHideOnClose,incognito: incognito,title: title || null,enable_wasm: wasm,diff --git a/bin/types.ts b/bin/types.tsindex 1237e166..02c94b99 100644--- a/bin/types.ts+++ b/bin/types.ts@@ -73,8 +73,8 @@ export interface PakeCliOptions {// Installer language, valid for Windows users, default is en-USinstallerLanguage: string;- // Hide window on close instead of exiting, default false- hideOnClose: boolean;+ // Hide window on close instead of exiting, platform-specific: true for macOS, false for others+ hideOnClose: boolean | undefined;// Launch app in incognito/private mode, default falseincognito: boolean;diff --git a/dist/cli.js b/dist/cli.jsindex 3e688d41..b6cd8bd9 100755--- a/dist/cli.js+++ b/dist/cli.js@@ -18,11 +18,10 @@ import axios from 'axios';import { dir } from 'tmp-promise';import { fileTypeFromBuffer } from 'file-type';import icongen from 'icon-gen';-import sharp from 'sharp';import * as psl from 'psl';var name = "pake-cli";-var version = "3.2.17";+var version = "3.2.18";var description = "🤱🏻 Turn any webpage into a desktop app with Rust. 🤱🏻 利用 Rust 轻松构建轻量级多端桌面应用。";var engines = {node: ">=18.0.0"@@ -72,7 +71,7 @@ var exports = "./dist/cli.js";var license = "MIT";var dependencies = {"@tauri-apps/api": "^2.8.0",- "@tauri-apps/cli": "^2.8.1",+ "@tauri-apps/cli": "^2.8.3",axios: "^1.11.0",chalk: "^5.6.0",commander: "^11.1.0",@@ -84,7 +83,6 @@ var dependencies = {ora: "^8.2.0",prompts: "^2.4.2",psl: "^1.15.0",- sharp: "^0.33.5","tmp-promise": "^3.0.3","update-notifier": "^7.3.1"};@@ -103,11 +101,14 @@ var devDependencies = {"app-root-path": "^3.1.0","cross-env": "^7.0.3",prettier: "^3.6.2",- rollup: "^4.46.3",+ rollup: "^4.49.0","rollup-plugin-typescript2": "^0.36.0",tslib: "^2.8.1",typescript: "^5.9.2"};+var optionalDependencies = {+ sharp: "^0.33.5"+};var packageJson = {name: name,version: version,@@ -124,7 +125,8 @@ var packageJson = {exports: exports,license: license,dependencies: dependencies,- devDependencies: devDependencies+ devDependencies: devDependencies,+ optionalDependencies: optionalDependencies};// Convert the current module URL to a file path@@ -349,6 +351,8 @@ async function mergeConfig(url, options, tauriConf) {}));const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, } = options;const { platform } = process;+ // Platform-specific hide_on_close behavior: macOS keeps true, others default to false+ const platformHideOnClose = hideOnClose ?? (platform === 'darwin');// Set Windows parameters.const tauriConfWindowOptions = {width,@@ -360,7 +364,7 @@ async function mergeConfig(url, options, tauriConf) {always_on_top: alwaysOnTop,dark_mode: darkMode,disabled_web_shortcuts: disabledWebShortcuts,- hide_on_close: hideOnClose,+ hide_on_close: platformHideOnClose,incognito: incognito,title: title || null,enable_wasm: wasm,@@ -1056,7 +1060,7 @@ const DEFAULT_PAKE_OPTIONS = {debug: false,inject: [],installerLanguage: 'en-US',- hideOnClose: true,+ hideOnClose: undefined, // Platform-specific: true for macOS, false for othersincognito: false,wasm: false,};@@ -1067,6 +1071,24 @@ async function checkUpdateTips() {});}+// Lazy load sharp to handle installation issues gracefully+let sharp;+/**+ * Safely loads sharp with fallback+ */+async function loadSharp() {+ if (sharp)+ return sharp;+ try {+ const sharpModule = await import('sharp');+ sharp = sharpModule.default || sharpModule;+ return sharp;+ }+ catch (error) {+ logger.warn('Sharp not available, icon preprocessing will be skipped');+ return null;+ }+}// Constantsconst ICON_CONFIG = {minFileSize: 100,@@ -1086,12 +1108,17 @@ const API_TOKENS = {*/async function preprocessIcon(inputPath) {try {- const metadata = await sharp(inputPath).metadata();+ const sharpInstance = await loadSharp();+ if (!sharpInstance) {+ logger.debug('Sharp not available, skipping icon preprocessing');+ return inputPath;+ }+ const metadata = await sharpInstance(inputPath).metadata();if (metadata.channels !== 4)return inputPath; // No transparencyconst { path: tempDir } = await dir();const outputPath = path.join(tempDir, 'icon-with-background.png');- await sharp({+ await sharpInstance({create: {width: metadata.width || 512,height: metadata.height || 512,@@ -1503,7 +1530,7 @@ program.addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT_PAKE_OPTIONS.systemTrayIcon).hideHelp())- .addOption(new Option('--hide-on-close', 'Hide window on close instead of exiting')+ .addOption(new Option('--hide-on-close', 'Hide window on close instead of exiting (default: true for macOS, false for others)').default(DEFAULT_PAKE_OPTIONS.hideOnClose).hideHelp()).addOption(new Option('--title <string>', 'Window title').hideHelp())diff --git a/docs/cli-usage.md b/docs/cli-usage.mdindex 98cb852a..5804cab7 100644--- a/docs/cli-usage.md+++ b/docs/cli-usage.md@@ -293,7 +293,7 @@ Specify the system tray icon. This is only effective when the system tray is ena#### [hide-on-close]-Hide window instead of closing the application when clicking close button. Default is `true`.+Hide window instead of closing the application when clicking close button. Platform-specific default: `true` for macOS, `false` for Windows/Linux.```shell--hide-on-closediff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.mdindex 80781547..e00f3976 100644--- a/docs/cli-usage_CN.md+++ b/docs/cli-usage_CN.md@@ -292,7 +292,7 @@ pake [url] [options]#### [hide-on-close]-点击关闭按钮时隐藏窗口而不是退出应用程序。默认为 `true`。+点击关闭按钮时隐藏窗口而不是退出应用程序。平台特定默认值:macOS 为 `true`,Windows/Linux 为 `false`。```shell--hide-on-closediff --git a/src-tauri/pake.json b/src-tauri/pake.jsonindex 90fff9ed..0b0578b9 100644--- a/src-tauri/pake.json+++ b/src-tauri/pake.json@@ -13,7 +13,8 @@"activation_shortcut": "","disabled_web_shortcuts": false,"hide_on_close": true,- "incognito": false+ "incognito": false,+ "enable_wasm": false}],"user_agent": {diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 16726a47..a83bc0b8 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -64,6 +64,7 @@ pub fn run_app() {.on_window_event(move |_window, _event| {if let tauri::WindowEvent::CloseRequested { api, .. } = _event {if hide_on_close {+ // Hide window when hide_on_close is enabled (regardless of tray status)let window = _window.clone();tauri::async_runtime::spawn(async move {#[cfg(target_os = "macos")]@@ -77,8 +78,10 @@ pub fn run_app() {window.hide().unwrap();});api.prevent_close();+ } else {+ // Exit app completely when hide_on_close is false+ std::process::exit(0);}- // If hide_on_close is false, allow normal close behavior}}).run(tauri::generate_context!())