Skip to content

Commit 4a91c42

Browse files
committed
✨ add new param hide-on-close
1 parent d8b8102 commit 4a91c42

16 files changed

Lines changed: 1215 additions & 1128 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ npm run analyze
9191

9292
- **Window Management**: `src-tauri/src/app/window.rs` - Window creation, sizing, title bar handling
9393
- **System Tray**: `src-tauri/src/app/setup.rs` - Cross-platform system tray integration
94+
- **Window Close Behavior**: `src-tauri/src/lib.rs` - Configurable close behavior (hide vs exit)
9495
- **Global Shortcuts**: Activation shortcuts for bringing app to foreground
9596
- **Web Integration**: Custom user agents, proxy support, CSS/JS injection
9697
- **Multi-platform**: Builds for macOS (Intel/M1), Windows, Linux (deb/appimage/rpm)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ npm run build
198198

199199
1. You can refer to the [codebase structure](https://github.com/tw93/Pake/wiki/Description-of-Pake's-code-structure) before working on Pake, which will help you much in development.
200200
2. Modify the `url` and `productName` fields in the `pake.json` file under the src-tauri directory, the "domain" field in the `tauri.config.json` file needs to be modified synchronously, as well as the `icon` and `identifier` fields in the `tauri.xxx.conf.json` file. You can select an `icon` from the `icons` directory or download one from [macOSicons](https://macosicons.com/#/) to match your product needs.
201-
3. For configurations on window properties, you can modify the `pake.json` file to change the value of `width`, `height`, `fullscreen` (or not), `resizable` (or not) of the `windows` property. To adapt to the immersive header on Mac, change `hideTitleBar` to `true`, look for the `Header` element, and add the `padding-top` property.
201+
3. For configurations on window properties, you can modify the `pake.json` file to change the value of `width`, `height`, `fullscreen` (or not), `resizable` (or not), `hide_on_close` (hide window on close instead of exiting) of the `windows` property. To adapt to the immersive header on Mac, change `hideTitleBar` to `true`, look for the `Header` element, and add the `padding-top` property.
202202
4. For advanced usages such as style rewriting, advertisement removal, JS injection, container message communication, and user-defined shortcut keys, see [Advanced Usage of Pake](https://github.com/tw93/Pake/wiki/Advanced-Usage-of-Pake).
203203

204204
## Developers

README_CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ npm run build
196196

197197
1. 代码结构可参考 [文档](https://github.com/tw93/Pake/wiki/Pake-%E7%9A%84%E4%BB%A3%E7%A0%81%E7%BB%93%E6%9E%84%E8%AF%B4%E6%98%8E),便于你在开发前了解更多。
198198
2. 修改 src-tauri 目录下 `pake.json` 中的 `url``productName` 字段,需同步修改下 `tauri.config.json` 中的 `domain` 字段,以及 `tauri.xxx.conf.json` 中的 `icon``identifier` 字段,其中 `icon` 可以从 icons 目录选择一个,也可以去 [macOSicons](https://macosicons.com/#/) 下载符合效果的。
199-
3. 关于窗口属性设置,可以在 `pake.json` 修改 windows 属性对应的 `width/height`,fullscreen 是否全屏,resizable 是否可以调整大小,假如想适配 Mac 沉浸式头部,可以将 hideTitleBar 设置成 `true`,找到 Header 元素加一个 padding-top 样式即可,不想适配改成 `false` 也行。
199+
3. 关于窗口属性设置,可以在 `pake.json` 修改 windows 属性对应的 `width/height`,fullscreen 是否全屏,resizable 是否可以调整大小,hide_on_close 关闭时是否隐藏窗口而不是退出,假如想适配 Mac 沉浸式头部,可以将 hideTitleBar 设置成 `true`,找到 Header 元素加一个 padding-top 样式即可,不想适配改成 `false` 也行。
200200
4. 此外样式改写、屏蔽广告、逻辑代码注入、容器消息通信、自定义快捷键可见 [高级用法](https://github.com/tw93/Pake/wiki/Pake-%E7%9A%84%E9%AB%98%E7%BA%A7%E7%94%A8%E6%B3%95)
201201

202202
## 开发者

bin/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ Specify the system tray icon. This is only effective when the system tray is ena
208208
--system-tray-icon <path>
209209
```
210210

211+
#### [hide-on-close]
212+
213+
Hide the window instead of exiting when clicking the close button. Default is `true`. When enabled, the application will be minimized to the system tray (if available) or hidden when the close button is clicked, rather than actually closing the application.
214+
215+
```shell
216+
--hide-on-close
217+
```
218+
211219
#### [installer-language]
212220

213221
Set the Windows Installer language. Options include `zh-CN`, `ja-JP`, More at [Tauri Document](https://tauri.app/distribute/windows-installer/#internationalization). Default is `en-US`.

bin/README_CN.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ pake [url] [options]
208208
--system-tray-icon <path>
209209
```
210210

211+
#### [hide-on-close]
212+
213+
设置点击关闭按钮时隐藏窗口而不是退出应用。默认为 `true`。启用后,点击关闭按钮时应用会最小化到系统托盘(如果可用)或隐藏窗口,而不是直接关闭应用程序。
214+
215+
```shell
216+
--hide-on-close
217+
```
218+
211219
#### [installer-language]
212220

213221
设置 Windows 安装包语言。支持 `zh-CN``ja-JP`,更多在 [Tauri 文档](https://tauri.app/distribute/windows-installer/#internationalization)。默认为 `en-US`

bin/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ program
4444
)
4545
.addOption(new Option('--show-system-tray', 'Show system tray in app').default(DEFAULT.showSystemTray).hideHelp())
4646
.addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT.systemTrayIcon).hideHelp())
47+
.addOption(new Option('--hide-on-close', 'Hide window on close instead of exiting').default(DEFAULT.hideOnClose).hideHelp())
4748
.addOption(new Option('--installer-language <string>', 'Installer language').default(DEFAULT.installerLanguage).hideHelp())
4849
.version(packageJson.version, '-v, --version', 'Output the current version')
4950
.action(async (url: string, options: PakeCliOptions) => {

bin/defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
2222
debug: false,
2323
inject: [],
2424
installerLanguage: 'en-US',
25+
hideOnClose: true,
2526
};
2627

2728
// Just for cli development

bin/helpers/merge.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
2828
inject,
2929
proxyUrl,
3030
installerLanguage,
31+
hideOnClose,
3132
} = options;
3233

3334
const { platform } = process;
@@ -43,6 +44,7 @@ export async function mergeConfig(url: string, options: PakeAppOptions, tauriCon
4344
always_on_top: alwaysOnTop,
4445
dark_mode: darkMode,
4546
disabled_web_shortcuts: disabledWebShortcuts,
47+
hide_on_close: hideOnClose,
4648
};
4749
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
4850

bin/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export interface PakeCliOptions {
6868

6969
// Installer language, valid for Windows users, default is en-US
7070
installerLanguage: string;
71+
72+
// Hide window on close instead of exiting, default false
73+
hideOnClose: boolean;
7174
}
7275

7376
export interface PakeAppOptions extends PakeCliOptions {

dist/cli.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ var packageJson = {
124124

125125
var windows = [
126126
{
127-
url: "https://weread.qq.com",
127+
url: "https://weread.qq.com/",
128128
url_type: "web",
129129
hide_title_bar: true,
130130
fullscreen: false,
@@ -147,6 +147,7 @@ var system_tray = {
147147
linux: true,
148148
windows: true
149149
};
150+
var hide_on_close = true;
150151
var system_tray_path = "icons/icon.png";
151152
var inject = [
152153
];
@@ -155,6 +156,7 @@ var pakeConf = {
155156
windows: windows,
156157
user_agent: user_agent,
157158
system_tray: system_tray,
159+
hide_on_close: hide_on_close,
158160
system_tray_path: system_tray_path,
159161
inject: inject,
160162
proxy_url: proxy_url
@@ -430,7 +432,7 @@ async function combineFiles(files, output) {
430432
}
431433

432434
async function mergeConfig(url, options, tauriConf) {
433-
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, } = options;
435+
const { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, } = options;
434436
const { platform } = process;
435437
// Set Windows parameters.
436438
const tauriConfWindowOptions = {
@@ -488,6 +490,7 @@ async function mergeConfig(url, options, tauriConf) {
488490
tauriConf.pake.user_agent[currentPlatform] = userAgent;
489491
}
490492
tauriConf.pake.system_tray[currentPlatform] = showSystemTray;
493+
tauriConf.pake.hide_on_close = hideOnClose;
491494
// Processing targets are currently only open to Linux.
492495
if (platform === 'linux') {
493496
delete tauriConf.bundle.linux.deb.files;
@@ -800,6 +803,7 @@ const DEFAULT_PAKE_OPTIONS = {
800803
debug: false,
801804
inject: [],
802805
installerLanguage: 'en-US',
806+
hideOnClose: true,
803807
};
804808

805809
async function checkUpdateTips() {
@@ -994,6 +998,7 @@ program
994998
.addOption(new Option('--activation-shortcut <string>', 'Shortcut key to active App').default(DEFAULT_PAKE_OPTIONS.activationShortcut).hideHelp())
995999
.addOption(new Option('--show-system-tray', 'Show system tray in app').default(DEFAULT_PAKE_OPTIONS.showSystemTray).hideHelp())
9961000
.addOption(new Option('--system-tray-icon <string>', 'Custom system tray icon').default(DEFAULT_PAKE_OPTIONS.systemTrayIcon).hideHelp())
1001+
.addOption(new Option('--hide-on-close', 'Hide window on close instead of exiting').default(DEFAULT_PAKE_OPTIONS.hideOnClose).hideHelp())
9971002
.addOption(new Option('--installer-language <string>', 'Installer language').default(DEFAULT_PAKE_OPTIONS.installerLanguage).hideHelp())
9981003
.version(packageJson.version, '-v, --version', 'Output the current version')
9991004
.action(async (url, options) => {

0 commit comments

Comments
 (0)