✨ Support drag-and-drop configuration
This commit is contained in:
10
bin/cli.ts
vendored
10
bin/cli.ts
vendored
@@ -125,7 +125,10 @@ program
|
|||||||
.hideHelp(),
|
.hideHelp(),
|
||||||
)
|
)
|
||||||
.addOption(
|
.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)
|
.default(DEFAULT.hideOnClose)
|
||||||
.hideHelp(),
|
.hideHelp(),
|
||||||
)
|
)
|
||||||
@@ -140,6 +143,11 @@ program
|
|||||||
.default(DEFAULT.wasm)
|
.default(DEFAULT.wasm)
|
||||||
.hideHelp(),
|
.hideHelp(),
|
||||||
)
|
)
|
||||||
|
.addOption(
|
||||||
|
new Option('--enable-drag-drop', 'Enable drag and drop functionality')
|
||||||
|
.default(DEFAULT.enableDragDrop)
|
||||||
|
.hideHelp(),
|
||||||
|
)
|
||||||
.addOption(
|
.addOption(
|
||||||
new Option('--installer-language <string>', 'Installer language')
|
new Option('--installer-language <string>', 'Installer language')
|
||||||
.default(DEFAULT.installerLanguage)
|
.default(DEFAULT.installerLanguage)
|
||||||
|
|||||||
1
bin/defaults.ts
vendored
1
bin/defaults.ts
vendored
@@ -25,6 +25,7 @@ export const DEFAULT_PAKE_OPTIONS: PakeCliOptions = {
|
|||||||
hideOnClose: undefined, // Platform-specific: true for macOS, false for others
|
hideOnClose: undefined, // Platform-specific: true for macOS, false for others
|
||||||
incognito: false,
|
incognito: false,
|
||||||
wasm: false,
|
wasm: false,
|
||||||
|
enableDragDrop: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Just for cli development
|
// Just for cli development
|
||||||
|
|||||||
4
bin/helpers/merge.ts
vendored
4
bin/helpers/merge.ts
vendored
@@ -61,12 +61,13 @@ export async function mergeConfig(
|
|||||||
incognito,
|
incognito,
|
||||||
title,
|
title,
|
||||||
wasm,
|
wasm,
|
||||||
|
enableDragDrop,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
const { platform } = process;
|
const { platform } = process;
|
||||||
|
|
||||||
// Platform-specific hide_on_close behavior: macOS keeps true, others default to false
|
// 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.
|
// Set Windows parameters.
|
||||||
const tauriConfWindowOptions = {
|
const tauriConfWindowOptions = {
|
||||||
@@ -83,6 +84,7 @@ export async function mergeConfig(
|
|||||||
incognito: incognito,
|
incognito: incognito,
|
||||||
title: title || null,
|
title: title || null,
|
||||||
enable_wasm: wasm,
|
enable_wasm: wasm,
|
||||||
|
enable_drag_drop: enableDragDrop,
|
||||||
};
|
};
|
||||||
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||||
|
|
||||||
|
|||||||
3
bin/types.ts
vendored
3
bin/types.ts
vendored
@@ -81,6 +81,9 @@ export interface PakeCliOptions {
|
|||||||
|
|
||||||
// Enable WebAssembly support (Flutter Web, etc.), default false
|
// Enable WebAssembly support (Flutter Web, etc.), default false
|
||||||
wasm: boolean;
|
wasm: boolean;
|
||||||
|
|
||||||
|
// Enable drag and drop functionality, default false
|
||||||
|
enableDragDrop: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PakeAppOptions extends PakeCliOptions {
|
export interface PakeAppOptions extends PakeCliOptions {
|
||||||
|
|||||||
9
dist/cli.js
vendored
9
dist/cli.js
vendored
@@ -348,10 +348,10 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
await fsExtra.copy(sourcePath, destPath);
|
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;
|
const { platform } = process;
|
||||||
// Platform-specific hide_on_close behavior: macOS keeps true, others default to false
|
// 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.
|
// Set Windows parameters.
|
||||||
const tauriConfWindowOptions = {
|
const tauriConfWindowOptions = {
|
||||||
width,
|
width,
|
||||||
@@ -367,6 +367,7 @@ async function mergeConfig(url, options, tauriConf) {
|
|||||||
incognito: incognito,
|
incognito: incognito,
|
||||||
title: title || null,
|
title: title || null,
|
||||||
enable_wasm: wasm,
|
enable_wasm: wasm,
|
||||||
|
enable_drag_drop: enableDragDrop,
|
||||||
};
|
};
|
||||||
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
Object.assign(tauriConf.pake.windows[0], { url, ...tauriConfWindowOptions });
|
||||||
tauriConf.productName = name;
|
tauriConf.productName = name;
|
||||||
@@ -1062,6 +1063,7 @@ const DEFAULT_PAKE_OPTIONS = {
|
|||||||
hideOnClose: undefined, // Platform-specific: true for macOS, false for others
|
hideOnClose: undefined, // Platform-specific: true for macOS, false for others
|
||||||
incognito: false,
|
incognito: false,
|
||||||
wasm: false,
|
wasm: false,
|
||||||
|
enableDragDrop: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
async function checkUpdateTips() {
|
async function checkUpdateTips() {
|
||||||
@@ -1516,6 +1518,9 @@ program
|
|||||||
.addOption(new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)')
|
.addOption(new Option('--wasm', 'Enable WebAssembly support (Flutter Web, etc.)')
|
||||||
.default(DEFAULT_PAKE_OPTIONS.wasm)
|
.default(DEFAULT_PAKE_OPTIONS.wasm)
|
||||||
.hideHelp())
|
.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')
|
.addOption(new Option('--installer-language <string>', 'Installer language')
|
||||||
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
|
.default(DEFAULT_PAKE_OPTIONS.installerLanguage)
|
||||||
.hideHelp())
|
.hideHelp())
|
||||||
|
|||||||
@@ -332,6 +332,17 @@ This option adds necessary HTTP headers (`Cross-Origin-Opener-Policy: same-origi
|
|||||||
pake https://flutter.dev --name FlutterApp --wasm
|
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]
|
#### [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`.
|
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`.
|
||||||
|
|||||||
@@ -319,6 +319,17 @@ pake [url] [options]
|
|||||||
pake https://flutter.dev --name FlutterApp --wasm
|
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]
|
#### [title]
|
||||||
|
|
||||||
设置窗口标题栏文本。如果未指定,窗口标题将为空。
|
设置窗口标题栏文本。如果未指定,窗口标题将为空。
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ pub struct WindowConfig {
|
|||||||
pub incognito: bool,
|
pub incognito: bool,
|
||||||
pub title: Option<String>,
|
pub title: Option<String>,
|
||||||
pub enable_wasm: bool,
|
pub enable_wasm: bool,
|
||||||
|
pub enable_drag_drop: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -38,8 +38,14 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) ->
|
|||||||
.fullscreen(window_config.fullscreen)
|
.fullscreen(window_config.fullscreen)
|
||||||
.inner_size(window_config.width, window_config.height)
|
.inner_size(window_config.width, window_config.height)
|
||||||
.always_on_top(window_config.always_on_top)
|
.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(&config_script)
|
||||||
.initialization_script(include_str!("../inject/component.js"))
|
.initialization_script(include_str!("../inject/component.js"))
|
||||||
.initialization_script(include_str!("../inject/event.js"))
|
.initialization_script(include_str!("../inject/event.js"))
|
||||||
|
|||||||
Reference in New Issue
Block a user