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.

:sparkles: Support drag-and-drop configuration

Tw93bd764f5f5fba
diff --git a/bin/cli.ts b/bin/cli.ts
index 9d63f9fd..12cecbd2 100644
--- a/bin/cli.ts
+++ b/bin/cli.ts
@@ -125,7 +125,10 @@ program
.hideHelp(),
)
.addOption(
- new Option('--hide-on-close', 'Hide window on close instead of exiting (default: true for macOS, false for others)')
+ new Option(
+ '--hide-on-close',
+ 'Hide window on close instead of exiting (default: true for macOS, false for others)',
+ )
.default(DEFAULT.hideOnClose)
.hideHelp(),
)
@@ -140,6 +143,11 @@ program
.default(DEFAULT.wasm)
.hideHelp(),
)
+ .addOption(
+ new Option('--enable-drag-drop', 'Enable drag and drop functionality')
+ .default(DEFAULT.enableDragDrop)
+ .hideHelp(),
+ )
.addOption(
new Option('--installer-language <string>', 'Installer language')
.default(DEFAULT.installerLanguage)
diff --git a/bin/defaults.ts b/bin/defaults.ts
index 2597d77f..72ab5205 100644
--- a/bin/defaults.ts
+++ b/bin/defaults.ts
@@ -25,6 +25,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
hideOnClose: undefined, // Platform-specific: true for macOS, false for others
incognito: false,
wasm: false,
+ enableDragDrop: false,
};
// Just for cli development
diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts
index 1d630ff5..5645383d 100644
--- a/bin/helpers/merge.ts
+++ b/bin/helpers/merge.ts
@@ -61,12 +61,13 @@ export async function mergeConfig(
incognito,
title,
wasm,
+ enableDragDrop,
} = options;
const { platform } = process;
// Platform-specific hide_on_close behavior: macOS keeps true, others default to false
- const platformHideOnClose = hideOnClose ?? (platform === 'darwin');
+ const platformHideOnClose = hideOnClose ?? platform === 'darwin';
// Set Windows parameters.
const tauriConfWindowOptions = {
@@ -83,6 +84,7 @@ export async function mergeConfig(
incognito: incognito,
title: title || null,
enable_wasm: wasm,
+ enable_drag_drop: enableDragDrop,
};
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
diff --git a/bin/types.ts b/bin/types.ts
index 02c94b99..261c6b2d 100644
--- a/bin/types.ts
+++ b/bin/types.ts
@@ -81,6 +81,9 @@ export interface PakeCliOptions {
// Enable WebAssembly support (Flutter Web, etc.), default false
wasm: boolean;
+
+ // Enable drag and drop functionality, default false
+ enableDragDrop: boolean;
}
export interface PakeAppOptions extends PakeCliOptions {
diff --git a/dist/cli.js b/dist/cli.js
index 960b6370..61aef9e2 100755
--- a/dist/cli.js
+++ b/dist/cli.js
@@ -348,10 +348,10 @@ async function mergeConfig(url, options, tauriConf) {
await fsExtra.copy(sourcePath, destPath);
}
}));
- 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 { width, height, fullscreen, hideTitleBar, alwaysOnTop, appVersion, darkMode, disabledWebShortcuts, activationShortcut, userAgent, showSystemTray, systemTrayIcon, useLocalFile, identifier, name, resizable = true, inject, proxyUrl, installerLanguage, hideOnClose, incognito, title, wasm, enableDragDrop, } = options;
const { platform } = process;
// Platform-specific hide_on_close behavior: macOS keeps true, others default to false
- const platformHideOnClose = hideOnClose ?? (platform === 'darwin');
+ const platformHideOnClose = hideOnClose ?? platform === 'darwin';
// Set Windows parameters.
const tauriConfWindowOptions = {
width,
@@ -367,6 +367,7 @@ async function mergeConfig(url, options, tauriConf) {
incognito: incognito,
title: title || null,
enable_wasm: wasm,
+ enable_drag_drop: enableDragDrop,
};
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
tauriConf.productName = name;
@@ -1062,6 +1063,7 @@ const DEFAULT_PAKE_OPTIONS = {
hideOnClose: undefined, // Platform-specific: true for macOS, false for others
incognito: false,
wasm: false,
+ enableDragDrop: false,
};
async function checkUpdateTips() {
@@ -1516,6 +1518,9 @@ program
.addOption(new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)')
.default(DEFAULT_PAKE_OPTIONS.wasm)
.hideHelp())
+ .addOption(new Option('--enable-drag-drop', 'Enable drag and drop functionality')
+ .default(DEFAULT_PAKE_OPTIONS.enableDragDrop)
+ .hideHelp())
.addOption(new Option('--installer-language <string>', 'Installer language')
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
.hideHelp())
diff --git a/docs/cli-usage.md b/docs/cli-usage.md
index 5804cab7..27c5757d 100644
--- a/docs/cli-usage.md
+++ b/docs/cli-usage.md
@@ -332,6 +332,17 @@ This option adds necessary HTTP headers (`Cross-Origin-Opener-Policy: same-origi
pake https://flutter.dev --name FlutterApp --wasm
```
+#### [enable-drag-drop]
+
+Enable native drag and drop functionality within the application. Default is `false`. When enabled, allows drag and drop operations like reordering items, file uploads, and other interactive drag behaviors that work in regular browsers.
+
+```shell
+--enable-drag-drop
+
+# Example: Package an app that requires drag-drop functionality
+pake https://planka.example.com --name PlankApp --enable-drag-drop
+```
+
#### [installer-language]
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`.
diff --git a/docs/cli-usage_CN.md b/docs/cli-usage_CN.md
index e00f3976..696be859 100644
--- a/docs/cli-usage_CN.md
+++ b/docs/cli-usage_CN.md
@@ -319,6 +319,17 @@ pake [url] [options]
pake https://flutter.dev --name FlutterApp --wasm
```
+#### [enable-drag-drop]
+
+启用原生拖拽功能。默认为 `false`。启用后,允许在应用中进行拖拽操作,如重新排序项目、文件上传以及其他在常规浏览器中有效的交互式拖拽行为。
+
+```shell
+--enable-drag-drop
+
+# 示例:打包需要拖拽功能的应用
+pake https://planka.example.com --name PlankApp --enable-drag-drop
+```
+
#### [title]
设置窗口标题栏文本。如果未指定,窗口标题将为空。
diff --git a/src-tauri/src/app/config.rs b/src-tauri/src/app/config.rs
index cc3d74c8..b04ffa75 100644
--- a/src-tauri/src/app/config.rs
+++ b/src-tauri/src/app/config.rs
@@ -17,6 +17,7 @@ pub struct WindowConfig {
pub incognito: bool,
pub title: Option<String>,
pub enable_wasm: bool,
+ pub enable_drag_drop: bool,
}
#[derive(Debug, Serialize, Deserialize)]
diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs
index 2198b4a4..4ac01bfb 100644
--- a/src-tauri/src/app/window.rs
+++ b/src-tauri/src/app/window.rs
@@ -38,8 +38,14 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) ->
.fullscreen(window_config.fullscreen)
.inner_size(window_config.width, window_config.height)
.always_on_top(window_config.always_on_top)
- .disable_drag_drop_handler()
- .incognito(window_config.incognito)
+ .incognito(window_config.incognito);
+
+ // Conditionally disable drag-drop handler
+ if !window_config.enable_drag_drop {
+ window_builder = window_builder.disable_drag_drop_handler();
+ }
+
+ window_builder = window_builder
.initialization_script(&config_script)
.initialization_script(include_str!("../inject/component.js"))
.initialization_script(include_str!("../inject/event.js"))