Skip to content

Commit c16d9b0

Browse files
committed
merge
2 parents bf65869 + 77e212d commit c16d9b0

File tree

12 files changed

+111
-18
lines changed

12 files changed

+111
-18
lines changed

bin/cli.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ program
174174
.default(DEFAULT.startToTray)
175175
.hideHelp(),
176176
)
177+
.addOption(
178+
new Option(
179+
'--force-internal-navigation',
180+
'Keep every link inside the Pake window instead of opening external handlers',
181+
)
182+
.default(DEFAULT.forceInternalNavigation)
183+
.hideHelp(),
184+
)
177185
.addOption(
178186
new Option('--installer-language <string>', 'Installer language')
179187
.default(DEFAULT.installerLanguage)
@@ -204,6 +212,7 @@ program
204212
}
205213

206214
log.setDefaultLevel('info');
215+
log.setLevel('info');
207216
if (options.debug) {
208217
log.setLevel('debug');
209218
}

bin/defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
3030
keepBinary: false,
3131
multiInstance: false,
3232
startToTray: false,
33+
forceInternalNavigation: false,
3334
};
3435

3536
// Just for cli development

bin/helpers/merge.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export async function mergeConfig(
7373
enableDragDrop,
7474
multiInstance,
7575
startToTray,
76+
forceInternalNavigation,
7677
} = options;
7778

7879
const { platform } = process;
@@ -96,6 +97,7 @@ export async function mergeConfig(
9697
enable_wasm: wasm,
9798
enable_drag_drop: enableDragDrop,
9899
start_to_tray: startToTray && showSystemTray,
100+
force_internal_navigation: forceInternalNavigation,
99101
};
100102
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
101103

bin/types.ts

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

9797
// Start app minimized to tray, default false
9898
startToTray: boolean;
99+
100+
// Force navigation to stay inside the Pake window even for external links
101+
forceInternalNavigation: boolean;
99102
}
100103

101104
export interface PakeAppOptions extends PakeCliOptions {

dist/cli.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import sharp from 'sharp';
2323
import * as psl from 'psl';
2424

2525
var name = "pake-cli";
26-
var version = "3.4.3";
26+
var version = "3.5.1";
2727
var description = "🤱🏻 Turn any webpage into a desktop app with one command. 🤱🏻 一键打包网页生成轻量桌面应用。";
2828
var engines = {
2929
node: ">=18.0.0"
@@ -470,7 +470,7 @@ async function mergeConfig(url, options, tauriConf) {
470470
await fsExtra.copy(sourcePath, destPath);
471471
}
472472
}));
473-
const { width, height, fullscreen, maximize, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, enableDragDrop, multiInstance, startToTray, } = options;
473+
const { width, height, fullscreen, maximize, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, enableDragDrop, multiInstance, startToTray, forceInternalNavigation, } = options;
474474
const { platform } = process;
475475
const platformHideOnClose = hideOnClose ?? platform === 'darwin';
476476
const tauriConfWindowOptions = {
@@ -490,6 +490,7 @@ async function mergeConfig(url, options, tauriConf) {
490490
enable_wasm: wasm,
491491
enable_drag_drop: enableDragDrop,
492492
start_to_tray: startToTray && showSystemTray,
493+
force_internal_navigation: forceInternalNavigation,
493494
};
494495
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
495496
tauriConf.productName = name;
@@ -1331,6 +1332,7 @@ const DEFAULT_PAKE_OPTIONS = {
13311332
keepBinary: false,
13321333
multiInstance: false,
13331334
startToTray: false,
1335+
forceInternalNavigation: false,
13341336
};
13351337

13361338
async function checkUpdateTips() {
@@ -1862,6 +1864,9 @@ program
18621864
.addOption(new Option('--start-to-tray', 'Start app minimized to tray')
18631865
.default(DEFAULT_PAKE_OPTIONS.startToTray)
18641866
.hideHelp())
1867+
.addOption(new Option('--force-internal-navigation', 'Keep every link inside the Pake window instead of opening external handlers')
1868+
.default(DEFAULT_PAKE_OPTIONS.forceInternalNavigation)
1869+
.hideHelp())
18651870
.addOption(new Option('--installer-language <string>', 'Installer language')
18661871
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
18671872
.hideHelp())
@@ -1888,6 +1893,7 @@ program
18881893
return;
18891894
}
18901895
log.setDefaultLevel('info');
1896+
log.setLevel('info');
18911897
if (options.debug) {
18921898
log.setLevel('debug');
18931899
}

docs/cli-usage.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,14 @@ Sets whether to disable web shortcuts in the original Pake container, defaults t
204204
--disabled-web-shortcuts
205205
```
206206

207+
#### [force-internal-navigation]
208+
209+
Keeps every clicked link (even pointing to other domains) inside the Pake window instead of letting the OS open an external browser or helper. Default is `false`.
210+
211+
```shell
212+
--force-internal-navigation
213+
```
214+
207215
#### [multi-arch]
208216

209217
Package the application to support both Intel and M1 chips, exclusively for macOS. Default is `false`.

docs/cli-usage_CN.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ pake https://github.com --name GitHub
202202
--disabled-web-shortcuts
203203
```
204204

205+
#### [force-internal-navigation]
206+
207+
启用后所有点击的链接(即使是跨域)都会在 Pake 窗口内打开,不会再调用外部浏览器或辅助程序。默认 `false`
208+
209+
```shell
210+
--force-internal-navigation
211+
```
212+
205213
#### [multi-arch]
206214

207215
设置打包结果同时支持 Intel 和 M1 芯片,仅适用于 macOS,默认为 `false`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pake-cli",
3-
"version": "3.4.3",
3+
"version": "3.5.1",
44
"description": "🤱🏻 Turn any webpage into a desktop app with one command. 🤱🏻 一键打包网页生成轻量桌面应用。",
55
"engines": {
66
"node": ">=18.0.0"

scripts/configure-tauri.mjs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import linuxJson from "../src-tauri/tauri.linux.conf.json" with { type: "json" }
66

77
import { writeFileSync, existsSync, copyFileSync } from "fs";
88
import os from "os";
9+
import sharp from "sharp";
910

1011
/**
1112
* Configuration script for Tauri app generation
@@ -121,20 +122,40 @@ function updateBaseConfigs() {
121122
}
122123
}
123124

124-
function ensureIconExists(iconPath, defaultPath, description = "icon") {
125+
async function ensureRgbaPng(iconPath) {
126+
try {
127+
const buffer = await sharp(iconPath)
128+
.ensureAlpha()
129+
.png({ force: true })
130+
.toBuffer();
131+
writeFileSync(iconPath, buffer);
132+
} catch (error) {
133+
console.warn(`Failed to normalize ${iconPath} to RGBA: ${error.message}`);
134+
}
135+
}
136+
137+
async function ensureIconExists(
138+
iconPath,
139+
defaultPath,
140+
description = "icon",
141+
ensureRgba = false,
142+
) {
125143
if (!existsSync(iconPath)) {
126-
// For official release apps, icons should already exist
127144
if (process.env.PAKE_CREATE_APP === "1") {
128145
console.warn(
129146
`${description} for ${process.env.NAME} not found at ${iconPath}`,
130147
);
131-
return; // Don't auto-generate for release builds
148+
return;
132149
}
133150
console.warn(
134151
`${description} for ${process.env.NAME} not found, using default`,
135152
);
136153
copyFileSync(defaultPath, iconPath);
137154
}
155+
156+
if (ensureRgba && existsSync(iconPath)) {
157+
await ensureRgbaPng(iconPath);
158+
}
138159
}
139160

140161
function updatePlatformConfig(platformConfig, platformVars) {
@@ -150,8 +171,13 @@ function updatePlatformConfig(platformConfig, platformVars) {
150171

151172
// Platform-specific handlers
152173
const platformHandlers = {
153-
linux: (config) => {
154-
ensureIconExists(config.iconPath, config.defaultIcon, "Linux icon");
174+
linux: async (config) => {
175+
await ensureIconExists(
176+
config.iconPath,
177+
config.defaultIcon,
178+
"Linux icon",
179+
true,
180+
);
155181

156182
// Update desktop entry
157183
linuxJson.bundle.linux.deb.files = {
@@ -162,14 +188,14 @@ const platformHandlers = {
162188
updatePlatformConfig(linuxJson, config);
163189
},
164190

165-
darwin: (config) => {
166-
ensureIconExists(config.iconPath, config.defaultIcon, "macOS icon");
191+
darwin: async (config) => {
192+
await ensureIconExists(config.iconPath, config.defaultIcon, "macOS icon");
167193
updatePlatformConfig(macosJson, config);
168194
},
169195

170-
win32: (config) => {
171-
ensureIconExists(config.iconPath, config.defaultIcon, "Windows icon");
172-
ensureIconExists(
196+
win32: async (config) => {
197+
await ensureIconExists(config.iconPath, config.defaultIcon, "Windows icon");
198+
await ensureIconExists(
173199
config.hdIconPath,
174200
config.hdDefaultIcon,
175201
"Windows HD icon",
@@ -196,7 +222,7 @@ function saveConfigurations() {
196222
}
197223

198224
// Main execution
199-
function main() {
225+
async function main() {
200226
try {
201227
validateEnvironment();
202228
updateBaseConfigs();
@@ -210,7 +236,7 @@ function main() {
210236

211237
const handler = platformHandlers[platform];
212238
if (handler) {
213-
handler(platformConfig);
239+
await handler(platformConfig);
214240
}
215241

216242
saveConfigurations();

src-tauri/pake.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"enable_wasm": false,
1818
"enable_drag_drop": false,
1919
"maximize": false,
20-
"start_to_tray": false
20+
"start_to_tray": false,
21+
"force_internal_navigation": false
2122
}
2223
],
2324
"user_agent": {

0 commit comments

Comments
 (0)