Merge branch 'dev'

This commit is contained in:
Tw93
2025-10-16 12:45:27 +08:00
31 changed files with 1672 additions and 554 deletions

View File

@@ -38,6 +38,44 @@ document.addEventListener("keydown", (e) => {
});
```
## Built-in Features
### Download Error Notifications
Pake automatically provides user-friendly download error notifications:
**Features:**
- **Bilingual Support**: Automatically detects browser language (Chinese/English)
- **System Notifications**: Uses native OS notifications when permission is granted
- **Graceful Fallback**: Falls back to console logging if notifications are unavailable
- **Comprehensive Coverage**: Handles all download types (HTTP, Data URI, Blob)
**User Experience:**
When a download fails, users will see a notification:
- English: "Download Error - Download failed: filename.pdf"
- Chinese: "下载错误 - 下载失败: filename.pdf"
**Requesting Notification Permission:**
To enable notifications, add this to your injected JavaScript:
```javascript
// Request notification permission on app start
if (window.Notification && Notification.permission === "default") {
Notification.requestPermission();
}
```
The download system automatically handles:
- Regular HTTP(S) downloads
- Data URI downloads (base64 encoded files)
- Blob URL downloads (dynamically generated files)
- Context menu initiated downloads
## Container Communication
Send messages between web content and Pake container.

View File

@@ -38,6 +38,41 @@ document.addEventListener("keydown", (e) => {
});
```
## 内置功能
### 下载错误通知
Pake 自动提供用户友好的下载错误通知:
**功能特性:**
- **双语支持**:自动检测浏览器语言(中文/英文)
- **系统通知**:在授予权限后使用原生操作系统通知
- **优雅降级**:如果通知不可用则降级到控制台日志
- **全面覆盖**处理所有下载类型HTTP、Data URI、Blob
**用户体验:**
当下载失败时,用户将看到通知:
- 英文:"Download Error - Download failed: filename.pdf"
- 中文:"下载错误 - 下载失败: filename.pdf"
**请求通知权限:**
要启用通知,请在注入的 JavaScript 中添加:
```javascript
// 在应用启动时请求通知权限
if (window.Notification && Notification.permission === "default") {
Notification.requestPermission();
}
```
下载系统自动处理:
- 常规 HTTP(S) 下载
- Data URI 下载base64 编码文件)
- Blob URL 下载(动态生成的文件)
- 右键菜单发起的下载
## 容器通信
在网页内容和 Pake 容器之间发送消息。

16
docs/cli-usage.md vendored
View File

@@ -280,7 +280,12 @@ Specify the system tray icon. This is only effective when the system tray is ena
Hide window instead of closing the application when clicking close button. Platform-specific default: `true` for macOS, `false` for Windows/Linux.
```shell
# Hide on close (default behavior on macOS)
--hide-on-close
--hide-on-close true
# Close application immediately (default behavior on Windows/Linux)
--hide-on-close false
```
#### [title]
@@ -340,6 +345,17 @@ pake https://github.com --name GitHub --keep-binary
**Output**: Creates both installer and standalone executable (`AppName-binary` on Unix, `AppName.exe` on Windows).
#### [multi-instance]
Allow the packaged app to run more than one instance at the same time. Default is `false`, which means launching a second instance simply focuses the existing window. Enable this when you need to open several windows of the same app simultaneously.
```shell
--multi-instance
# Example: Allow multiple chat windows
pake https://chat.example.com --name ChatApp --multi-instance
```
#### [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`.

16
docs/cli-usage_CN.md vendored
View File

@@ -279,7 +279,12 @@ pake https://github.com --name GitHub
点击关闭按钮时隐藏窗口而不是退出应用程序。平台特定默认值macOS 为 `true`Windows/Linux 为 `false`。
```shell
# 关闭时隐藏macOS 默认行为)
--hide-on-close
--hide-on-close true
# 立即关闭应用程序Windows/Linux 默认行为)
--hide-on-close false
```
#### [title]
@@ -339,6 +344,17 @@ pake https://github.com --name GitHub --keep-binary
**输出结果**同时创建安装包和独立可执行文件Unix 系统为 `AppName-binary`Windows 为 `AppName.exe`)。
#### [multi-instance]
允许打包后的应用同时运行多个实例。默认为 `false`,此时再次启动只会聚焦已有窗口。启用该选项后,可以同时打开同一个应用的多个窗口。
```shell
--multi-instance
# 示例:允许聊天应用同时开多个窗口
pake https://chat.example.com --name ChatApp --multi-instance
```
#### [installer-language]
设置 Windows 安装包语言。支持 `zh-CN`、`ja-JP`,更多在 [Tauri 文档](https://tauri.app/distribute/windows-installer/#internationalization)。默认为 `en-US`。

248
docs/faq.md vendored Normal file
View File

@@ -0,0 +1,248 @@
# Frequently Asked Questions (FAQ)
<h4 align="right"><strong>English</strong> | <a href="faq_CN.md">简体中文</a></h4>
Common issues and solutions when using Pake.
## Build Issues
### Linux: AppImage Build Fails with "failed to run linuxdeploy"
**Problem:**
When building AppImage on Linux (Debian, Ubuntu, Arch, etc.), you may encounter errors like:
```txt
Error: failed to run linuxdeploy
Error: strip: Unable to recognise the format of the input file
```
**Solution 1: Use NO_STRIP (Recommended)**
Simply add `NO_STRIP=true` before your build command:
```bash
NO_STRIP=true pake https://example.com --name MyApp --targets appimage
```
This bypasses the library stripping process that often causes issues on certain Linux distributions.
**Solution 2: Install System Dependencies**
If NO_STRIP doesn't work, ensure you have all required system dependencies:
```bash
sudo apt update
sudo apt install -y \
libdbus-1-dev \
libsoup-3.0-dev \
libjavascriptcoregtk-4.1-dev \
libwebkit2gtk-4.1-dev \
build-essential \
curl wget file \
libxdo-dev \
libssl-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
gnome-video-effects \
libglib2.0-dev \
libgirepository1.0-dev \
pkg-config
```
Then try building again with `NO_STRIP=true`.
**Solution 3: Use DEB Format Instead**
DEB packages are more stable on Debian-based systems:
```bash
pake https://example.com --name MyApp --targets deb
```
**Solution 4: Use Docker**
Build in a clean environment without installing dependencies:
```bash
docker run --rm -v $(pwd)/output:/app/output \
ghcr.io/tw93/pake:latest \
pake https://example.com --name MyApp --targets appimage
```
**Why This Happens:**
This is a known issue with Tauri's linuxdeploy tool, which can fail when:
- System libraries have incompatible formats for stripping
- Building on newer distributions (Arch, Debian Trixie, etc.)
- Missing WebKit2GTK or GTK development libraries
The `NO_STRIP=true` environment variable is the official workaround recommended by the Tauri community.
---
### Linux: "cargo: command not found" After Installing Rust
**Problem:**
You installed Rust but Pake still reports "cargo: command not found".
**Solution:**
Pake CLI automatically reloads the Rust environment, but if issues persist:
```bash
# Reload environment in current terminal
source ~/.cargo/env
# Or restart your terminal
```
Then try building again.
---
### macOS: Build Fails with Module Compilation Errors
**Problem:**
On macOS 26 Beta or newer, you may see errors related to `CoreFoundation` or `_Builtin_float` modules.
**Solution:**
Create a configuration file to use compatible SDK:
```bash
cat > src-tauri/.cargo/config.toml << 'EOF'
[env]
MACOSX_DEPLOYMENT_TARGET = "15.0"
SDKROOT = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
EOF
```
This file is already in `.gitignore` and won't be committed.
---
### Windows: Missing Visual Studio Build Tools
**Problem:**
Build fails with errors about missing MSVC or Windows SDK.
**Solution:**
Install Visual Studio Build Tools:
1. Download [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022)
2. During installation, select "Desktop development with C++"
3. For ARM64 support: Also select "MSVC v143 - VS 2022 C++ ARM64 build tools" under Individual Components
---
## Runtime Issues
### App Window is Too Small/Large
**Solution:**
Specify custom dimensions when building:
```bash
pake https://example.com --width 1200 --height 800
```
See [CLI Usage Guide](cli-usage.md#window-options) for all window options.
---
### App Icon Not Showing Correctly
**Problem:**
Custom icon doesn't appear or shows default icon.
**Solution:**
Ensure you're using the correct icon format for your platform:
- **macOS**: `.icns` format
- **Windows**: `.ico` format
- **Linux**: `.png` format
```bash
# macOS
pake https://example.com --icon ./icon.icns
# Windows
pake https://example.com --icon ./icon.ico
# Linux
pake https://example.com --icon ./icon.png
```
Pake can automatically convert icons, but providing the correct format is more reliable.
---
### Website Features Not Working (Login, Upload, etc.)
**Problem:**
Some website features don't work in the Pake app.
**Solution:**
This is usually due to web compatibility issues. Try:
1. **Set custom User Agent:**
```bash
pake https://example.com --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
```
2. **Inject custom JavaScript:**
```bash
pake https://example.com --inject ./fix.js
```
3. **Check if the site requires specific permissions** that may not be available in WebView
---
## Installation Issues
### Permission Denied When Installing Globally
**Problem:**
`npm install -g pake-cli` fails with permission errors.
**Solution:**
Use one of these approaches:
```bash
# Option 1: Use npx (no installation needed)
npx pake-cli https://example.com
# Option 2: Fix npm permissions
npm config set prefix ~/.npm-global
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g pake-cli
# Option 3: Use pnpm (recommended)
pnpm install -g pake-cli
```
---
## Getting Help
If your issue isn't covered here:
1. Check the [CLI Usage Guide](cli-usage.md) for detailed parameter documentation
2. See [Advanced Usage](advanced-usage.md) for prerequisites and system setup
3. Search [existing GitHub issues](https://github.com/tw93/Pake/issues)
4. [Open a new issue](https://github.com/tw93/Pake/issues/new) with:
- Your OS and version
- Node.js and Rust versions (`node --version`, `rustc --version`)
- Complete error message
- Build command you used

248
docs/faq_CN.md vendored Normal file
View File

@@ -0,0 +1,248 @@
# 常见问题 (FAQ)
<h4 align="right"><a href="faq.md">English</a> | <strong>简体中文</strong></h4>
使用 Pake 时的常见问题和解决方案。
## 构建问题
### LinuxAppImage 构建失败,提示 "failed to run linuxdeploy"
**问题描述:**
在 Linux 系统Debian、Ubuntu、Arch 等)上构建 AppImage 时,可能遇到如下错误:
```txt
Error: failed to run linuxdeploy
Error: strip: Unable to recognise the format of the input file
```
**解决方案 1使用 NO_STRIP推荐**
在构建命令前加上 `NO_STRIP=true`
```bash
NO_STRIP=true pake https://example.com --name MyApp --targets appimage
```
这会绕过经常在某些 Linux 发行版上出现问题的库文件剥离过程。
**解决方案 2安装系统依赖**
如果 NO_STRIP 不起作用,确保已安装所有必需的系统依赖:
```bash
sudo apt update
sudo apt install -y \
libdbus-1-dev \
libsoup-3.0-dev \
libjavascriptcoregtk-4.1-dev \
libwebkit2gtk-4.1-dev \
build-essential \
curl wget file \
libxdo-dev \
libssl-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
gnome-video-effects \
libglib2.0-dev \
libgirepository1.0-dev \
pkg-config
```
然后使用 `NO_STRIP=true` 再次尝试构建。
**解决方案 3改用 DEB 格式**
DEB 包在基于 Debian 的系统上更稳定:
```bash
pake https://example.com --name MyApp --targets deb
```
**解决方案 4使用 Docker**
在干净的环境中构建,无需安装依赖:
```bash
docker run --rm -v $(pwd)/output:/app/output \
ghcr.io/tw93/pake:latest \
pake https://example.com --name MyApp --targets appimage
```
**原因:**
这是 Tauri 的 linuxdeploy 工具的已知问题,在以下情况下可能失败:
- 系统库的格式不兼容剥离操作
- 在较新的发行版上构建Arch、Debian Trixie 等)
- 缺少 WebKit2GTK 或 GTK 开发库
`NO_STRIP=true` 环境变量是 Tauri 社区推荐的官方解决方法。
---
### Linux"cargo: command not found" 即使已安装 Rust
**问题描述:**
已安装 Rust 但 Pake 仍然提示 "cargo: command not found"。
**解决方案:**
Pake CLI 会自动重新加载 Rust 环境,但如果问题仍然存在:
```bash
# 在当前终端重新加载环境
source ~/.cargo/env
# 或者重启终端
```
然后再次尝试构建。
---
### macOS构建失败出现模块编译错误
**问题描述:**
在 macOS 26 Beta 或更新版本上,可能看到与 `CoreFoundation``_Builtin_float` 模块相关的错误。
**解决方案:**
创建配置文件以使用兼容的 SDK
```bash
cat > src-tauri/.cargo/config.toml << 'EOF'
[env]
MACOSX_DEPLOYMENT_TARGET = "15.0"
SDKROOT = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
EOF
```
此文件已在 `.gitignore` 中,不会被提交。
---
### Windows缺少 Visual Studio 构建工具
**问题描述:**
构建失败,提示缺少 MSVC 或 Windows SDK。
**解决方案:**
安装 Visual Studio 构建工具:
1. 下载 [Visual Studio Build Tools](https://visualstudio.microsoft.com/zh-hans/downloads/#build-tools-for-visual-studio-2022)
2. 安装时选择"使用 C++ 的桌面开发"
3. ARM64 支持:在"单个组件"下额外选择"MSVC v143 - VS 2022 C++ ARM64 构建工具"
---
## 运行时问题
### 应用窗口太小/太大
**解决方案:**
构建时指定自定义尺寸:
```bash
pake https://example.com --width 1200 --height 800
```
查看 [CLI 使用指南](cli-usage_CN.md#窗口选项) 了解所有窗口选项。
---
### 应用图标显示不正确
**问题描述:**
自定义图标没有显示或显示默认图标。
**解决方案:**
确保为您的平台使用正确的图标格式:
- **macOS**`.icns` 格式
- **Windows**`.ico` 格式
- **Linux**`.png` 格式
```bash
# macOS
pake https://example.com --icon ./icon.icns
# Windows
pake https://example.com --icon ./icon.ico
# Linux
pake https://example.com --icon ./icon.png
```
Pake 可以自动转换图标,但提供正确的格式更可靠。
---
### 网站功能不工作(登录、上传等)
**问题描述:**
某些网站功能在 Pake 应用中无法工作。
**解决方案:**
这通常是由于 Web 兼容性问题。尝试:
1. **设置自定义 User Agent**
```bash
pake https://example.com --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
```
2. **注入自定义 JavaScript**
```bash
pake https://example.com --inject ./fix.js
```
3. **检查网站是否需要 WebView 中可能不可用的特定权限**
---
## 安装问题
### 全局安装时权限被拒绝
**问题描述:**
`npm install -g pake-cli` 失败,提示权限错误。
**解决方案:**
使用以下方法之一:
```bash
# 方案 1使用 npx无需安装
npx pake-cli https://example.com
# 方案 2修复 npm 权限
npm config set prefix ~/.npm-global
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g pake-cli
# 方案 3使用 pnpm推荐
pnpm install -g pake-cli
```
---
## 获取帮助
如果您的问题未在此处涵盖:
1. 查看 [CLI 使用指南](cli-usage_CN.md) 了解详细参数文档
2. 参阅 [高级用法](advanced-usage_CN.md) 了解前置条件和系统设置
3. 搜索 [现有的 GitHub issues](https://github.com/tw93/Pake/issues)
4. [提交新 issue](https://github.com/tw93/Pake/issues/new) 时请包含:
- 您的操作系统和版本
- Node.js 和 Rust 版本(`node --version`、`rustc --version`
- 完整的错误信息
- 您使用的构建命令