Support setting navigation bar title

This commit is contained in:
Tw93
2025-08-14 17:18:52 +08:00
parent 7a4f4c6d3d
commit b2072b5e80
8 changed files with 45 additions and 1 deletions

View File

@@ -99,6 +99,13 @@ npm run build:mac # macOS universal build
- `src/app/` - Core modules (window, tray, shortcuts) - `src/app/` - Core modules (window, tray, shortcuts)
- `src/inject/` - Web page injection logic - `src/inject/` - Web page injection logic
## Documentation Guidelines
- **Main README**: Only include common, frequently-used parameters to avoid clutter
- **CLI Documentation** (`bin/README.md`): Include ALL parameters with detailed usage examples
- **Rare/Advanced Parameters**: Should have full documentation in CLI docs but minimal/no mention in main README
- **Examples of rare parameters**: `--title`, `--incognito`, `--system-tray-icon`, etc.
### Key Configuration Files ### Key Configuration Files
- `pake.json` - App configuration - `pake.json` - App configuration

12
bin/README.md vendored
View File

@@ -224,6 +224,18 @@ Hide the window instead of exiting when clicking the close button. Default is `t
--hide-on-close --hide-on-close
``` ```
#### [title]
Set the window title bar text. If not specified, the window title will be empty.
```shell
--title <string>
# Examples:
--title "My Application"
--title "Google Translate"
```
#### [incognito] #### [incognito]
Launch the application in incognito/private browsing mode. Default is `false`. When enabled, the webview will run in private mode, which means it won't store cookies, local storage, or browsing history. This is useful for privacy-sensitive applications. Launch the application in incognito/private browsing mode. Default is `false`. When enabled, the webview will run in private mode, which means it won't store cookies, local storage, or browsing history. This is useful for privacy-sensitive applications.

12
bin/README_CN.md vendored
View File

@@ -232,6 +232,18 @@ pake [url] [options]
--incognito --incognito
``` ```
#### [title]
设置窗口标题栏文本。如果未指定,窗口标题将为空。
```shell
--title <string>
# 示例:
--title "我的应用"
--title "音乐播放器"
```
#### [installer-language] #### [installer-language]
设置 Windows 安装包语言。支持 `zh-CN`、`ja-JP`,更多在 [Tauri 文档](https://tauri.app/distribute/windows-installer/#internationalization)。默认为 `en-US`。 设置 Windows 安装包语言。支持 `zh-CN`、`ja-JP`,更多在 [Tauri 文档](https://tauri.app/distribute/windows-installer/#internationalization)。默认为 `en-US`。

1
bin/cli.ts vendored
View File

@@ -128,6 +128,7 @@ program
.default(DEFAULT.hideOnClose) .default(DEFAULT.hideOnClose)
.hideHelp(), .hideHelp(),
) )
.addOption(new Option('--title <string>', 'Window title').hideHelp())
.addOption( .addOption(
new Option('--incognito', 'Launch app in incognito/private mode').default( new Option('--incognito', 'Launch app in incognito/private mode').default(
DEFAULT.incognito, DEFAULT.incognito,

View File

@@ -34,6 +34,7 @@ export async function mergeConfig(
installerLanguage, installerLanguage,
hideOnClose, hideOnClose,
incognito, incognito,
title,
} = options; } = options;
const { platform } = process; const { platform } = process;
@@ -51,6 +52,7 @@ export async function mergeConfig(
disabled_web_shortcuts: disabledWebShortcuts, disabled_web_shortcuts: disabledWebShortcuts,
hide_on_close: hideOnClose, hide_on_close: hideOnClose,
incognito: incognito, incognito: incognito,
title: title || null,
}; };
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions }); Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });

3
bin/types.ts vendored
View File

@@ -6,6 +6,9 @@ export interface PakeCliOptions {
// Application name // Application name
name?: string; name?: string;
// Window title (supports Chinese characters)
title?: string;
// Application icon // Application icon
icon: string; icon: string;

View File

@@ -15,6 +15,7 @@ pub struct WindowConfig {
pub activation_shortcut: String, pub activation_shortcut: String,
pub hide_on_close: bool, pub hide_on_close: bool,
pub incognito: bool, pub incognito: bool,
pub title: Option<String>,
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]

View File

@@ -28,8 +28,14 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) ->
serde_json::to_string(&window_config).unwrap() serde_json::to_string(&window_config).unwrap()
); );
let window_title = window_config
.title
.as_ref()
.map(|t| t.as_str())
.unwrap_or("");
let mut window_builder = WebviewWindowBuilder::new(app, "pake", url) let mut window_builder = WebviewWindowBuilder::new(app, "pake", url)
.title("") .title(window_title)
.visible(false) .visible(false)
.user_agent(user_agent) .user_agent(user_agent)
.resizable(window_config.resizable) .resizable(window_config.resizable)