✨ Refactoring with documentation
This commit is contained in:
22
CLAUDE.md
22
CLAUDE.md
@@ -45,16 +45,16 @@ grep -r "window_config" src-tauri/src/
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
npm i
|
||||
pnpm i
|
||||
|
||||
# Development with hot reload (for testing app functionality)
|
||||
npm run dev
|
||||
pnpm run dev
|
||||
|
||||
# CLI development
|
||||
npm run cli:dev
|
||||
pnpm run cli:dev
|
||||
|
||||
# Production build
|
||||
npm run build
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
### 3. Testing and Validation
|
||||
@@ -63,16 +63,16 @@ npm run build
|
||||
|
||||
```bash
|
||||
# Run comprehensive test suite (unit + integration + builder)
|
||||
npm test
|
||||
pnpm test
|
||||
|
||||
# Build CLI for testing
|
||||
npm run cli:build
|
||||
pnpm run cli:build
|
||||
|
||||
# Debug build for development
|
||||
npm run build:debug
|
||||
pnpm run build:debug
|
||||
|
||||
# Multi-platform testing
|
||||
npm run build:mac # macOS universal build
|
||||
pnpm run build:mac # macOS universal build
|
||||
```
|
||||
|
||||
**Testing Checklist:**
|
||||
@@ -89,7 +89,7 @@ npm run build:mac # macOS universal build
|
||||
|
||||
- Do NOT use `PAKE_NO_CONFIG_OVERWRITE=1` - this environment variable is not implemented
|
||||
- For CLI testing: `node dist/cli.js https://example.com --name TestApp --debug`
|
||||
- **For app functionality testing**: Use `npm run dev` to start development server with hot reload. This allows real-time testing of injected JavaScript changes without rebuilding the entire app.
|
||||
- **For app functionality testing**: Use `pnpm run dev` to start development server with hot reload. This allows real-time testing of injected JavaScript changes without rebuilding the entire app.
|
||||
- The dev server automatically reloads when you modify files in `src-tauri/src/inject/` directory
|
||||
|
||||
## Core Components
|
||||
@@ -110,7 +110,7 @@ npm run build:mac # macOS universal build
|
||||
## 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
|
||||
- **CLI Documentation** (`docs/cli-usage.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.
|
||||
|
||||
@@ -133,7 +133,7 @@ npm run build:mac # macOS universal build
|
||||
|
||||
```bash
|
||||
# 1. Check logs
|
||||
npm run dev 2>&1 | grep -i error
|
||||
pnpm run dev 2>&1 | grep -i error
|
||||
|
||||
# 2. Verify dependencies
|
||||
cargo check --manifest-path=src-tauri/Cargo.toml
|
||||
|
||||
@@ -36,20 +36,20 @@ git clone https://github.com/tw93/Pake.git
|
||||
cd Pake
|
||||
|
||||
# Install dependencies
|
||||
npm install
|
||||
pnpm install
|
||||
|
||||
# Start development
|
||||
npm run dev
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Run all tests (unit + integration + builder)
|
||||
npm test
|
||||
pnpm test
|
||||
|
||||
# Build CLI for testing
|
||||
npm run cli:build
|
||||
pnpm run cli:build
|
||||
```
|
||||
|
||||
## Continuous Integration
|
||||
@@ -81,9 +81,11 @@ This file is already in `.gitignore` and should not be committed to the reposito
|
||||
### Common Build Issues
|
||||
|
||||
- **Rust compilation errors**: Run `cargo clean` in `src-tauri/` directory
|
||||
- **Node dependency issues**: Delete `node_modules` and run `npm install`
|
||||
- **Node dependency issues**: Delete `node_modules` and run `pnpm install`
|
||||
- **Permission errors on macOS**: Run `sudo xcode-select --reset`
|
||||
|
||||
See the [Advanced Usage Guide](docs/advanced-usage.md) for project structure and customization techniques.
|
||||
|
||||
## More
|
||||
|
||||
It is a good habit to create a feature request issue to discuss whether the feature is necessary before you implement it. However, it's unnecessary to create an issue to claim that you found a typo or improved the readability of documentation, just create a pull request.
|
||||
|
||||
18
README.md
18
README.md
@@ -1,4 +1,4 @@
|
||||
<h4 align="right"><strong>English</strong> | <a href="https://github.com/tw93/Pake/blob/main/README_CN.md">简体中文</a> | <a href="https://github.com/tw93/Pake/blob/main/README_JP.md">日本語</a></h4>
|
||||
<h4 align="right"><strong>English</strong> | <a href="README_CN.md">简体中文</a> | <a href="README_JP.md">日本語</a></h4>
|
||||
<p align="center">
|
||||
<img src=https://gw.alipayobjects.com/zos/k/fa/logo-modified.png width=138/>
|
||||
</p>
|
||||
@@ -154,7 +154,7 @@ In addition, double-click the title bar to switch to full-screen mode. For Mac u
|
||||
|
||||
## Before starting
|
||||
|
||||
1. **For beginners**: Play with Popular Packages to find out Pake's capabilities, or try to pack your application with [GitHub Actions](<https://github.com/tw93/Pake/wiki/Online-Compilation-(used-by-ordinary-users)>). Don't hesitate to reach for assistance at [Discussion](https://github.com/tw93/Pake/discussions)!
|
||||
1. **For beginners**: Play with Popular Packages to find out Pake's capabilities, or try to pack your application with [GitHub Actions](docs/github-actions-usage.md). Don't hesitate to reach for assistance at [Discussion](https://github.com/tw93/Pake/discussions)!
|
||||
2. **For developers**: “Command-Line Packaging” supports macOS fully. For Windows/Linux users, it requires some tinkering. [Configure your environment](https://tauri.app/start/prerequisites/) before getting started.
|
||||
3. **For hackers**: For people who are good at both front-end development and Rust, how about customizing your apps' function more with the following [Customized Development](#development)?
|
||||
|
||||
@@ -162,7 +162,7 @@ In addition, double-click the title bar to switch to full-screen mode. For Mac u
|
||||
|
||||

|
||||
|
||||
**Pake provides a command line tool, making the flow of package customization quicker and easier. See the [documentation](./bin/README.md) for more information.**
|
||||
**Pake provides a command line tool, making the flow of package customization quicker and easier. See the [CLI usage guide](docs/cli-usage.md) for more information.**
|
||||
|
||||
```bash
|
||||
# Recommended (pnpm)
|
||||
@@ -178,7 +178,7 @@ pake url [OPTIONS]...
|
||||
pake https://weekly.tw93.fun --name Weekly --hide-title-bar
|
||||
```
|
||||
|
||||
If you are new to the command line, you can compile packages online with _GitHub Actions_. See the [Tutorial](<https://github.com/tw93/Pake/wiki/Online-Compilation-(used-by-ordinary-users)>) for more information.
|
||||
If you are new to the command line, you can compile packages online with _GitHub Actions_. See our [documentation](#documentation) for detailed guides.
|
||||
|
||||
## Development
|
||||
|
||||
@@ -197,12 +197,12 @@ pnpm run dev
|
||||
pnpm run build
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
## Documentation
|
||||
|
||||
1. You can refer to the [codebase structure](https://github.com/tw93/Pake/wiki/Description-of-Pake's-code-structure) before working on Pake, which will help you much in development.
|
||||
2. Modify the `url` and `productName` fields in the `pake.json` file under the src-tauri directory, the "domain" field in the `tauri.config.json` file needs to be modified synchronously, as well as the `icon` and `identifier` fields in the `tauri.xxx.conf.json` file. You can select an `icon` from the `icons` directory or download one from [macOSicons](https://macosicons.com/#/) to match your product needs.
|
||||
3. For configurations on window properties, you can modify the `pake.json` file to change the value of `width`, `height`, `fullscreen` (or not), `resizable` (or not), `hide_on_close` (hide window on close instead of exiting) of the `windows` property. To adapt to the immersive header on Mac, change `hideTitleBar` to `true`, look for the `Header` element, and add the `padding-top` property.
|
||||
4. For advanced usages such as style rewriting, advertisement removal, JS injection, container message communication, and user-defined shortcut keys, see [Advanced Usage of Pake](https://github.com/tw93/Pake/wiki/Advanced-Usage-of-Pake).
|
||||
- **[CLI Usage](docs/cli-usage.md)** ([中文](docs/cli-usage_CN.md)) - Command-line interface reference
|
||||
- **[Advanced Usage](docs/advanced-usage.md)** ([中文](docs/advanced-usage_CN.md)) - Customization and advanced features
|
||||
- **[GitHub Actions](docs/github-actions-usage.md)** ([中文](docs/github-actions-usage_CN.md)) - Build apps online
|
||||
- **[Contributing](CONTRIBUTING.md)** - How to contribute to development
|
||||
|
||||
## Developers
|
||||
|
||||
|
||||
16
README_CN.md
16
README_CN.md
@@ -1,4 +1,4 @@
|
||||
<h4 align="right"><a href="https://github.com/tw93/Pake">English</a> | <strong>简体中文</strong> | <a href="https://github.com/tw93/Pake/blob/main/README_JP.md">日本語</a></h4>
|
||||
<h4 align="right"><a href="README.md">English</a> | <strong>简体中文</strong> | <a href="README_JP.md">日本語</a></h4>
|
||||
<p align="center">
|
||||
<img src=https://gw.alipayobjects.com/zos/k/fa/logo-modified.png width=138/>
|
||||
</p>
|
||||
@@ -162,7 +162,7 @@
|
||||
|
||||

|
||||
|
||||
**Pake 提供了命令行工具,可以更快捷方便地一键自定义打包你需要的应用,详细可见 [文档](./bin/README_CN.md)。**
|
||||
**Pake 提供了命令行工具,可以更快捷方便地一键自定义打包你需要的应用,详细可见 [CLI 使用指南](docs/cli-usage_CN.md)。**
|
||||
|
||||
```bash
|
||||
# 推荐方式 (pnpm)
|
||||
@@ -178,7 +178,7 @@ pake url [OPTIONS]...
|
||||
pake https://weekly.tw93.fun --name Weekly --hide-title-bar
|
||||
```
|
||||
|
||||
假如你不太会使用命令行,或许使用 **GitHub Actions 在线编译多系统版本** 是一个不错的选择,可查看 [文档](https://github.com/tw93/Pake/wiki/%E5%9C%A8%E7%BA%BF%E7%BC%96%E8%AF%91%EF%BC%88%E6%99%AE%E9%80%9A%E7%94%A8%E6%88%B7%E4%BD%BF%E7%94%A8%EF%BC%89)。
|
||||
如果你不太会使用命令行,可以使用 **GitHub Actions 在线编译**,详细步骤请参考[文档](#文档)。
|
||||
|
||||
## 定制开发
|
||||
|
||||
@@ -198,12 +198,12 @@ pnpm run build
|
||||
|
||||
```
|
||||
|
||||
## 高级使用
|
||||
## 文档
|
||||
|
||||
1. 代码结构可参考 [文档](https://github.com/tw93/Pake/wiki/Pake-%E7%9A%84%E4%BB%A3%E7%A0%81%E7%BB%93%E6%9E%84%E8%AF%B4%E6%98%8E),便于你在开发前了解更多。
|
||||
2. 修改 src-tauri 目录下 `pake.json` 中的 `url` 和 `productName` 字段,需同步修改下 `tauri.config.json` 中的 `domain` 字段,以及 `tauri.xxx.conf.json` 中的 `icon` 和 `identifier` 字段,其中 `icon` 可以从 icons 目录选择一个,也可以去 [macOSicons](https://macosicons.com/#/) 下载符合效果的。
|
||||
3. 关于窗口属性设置,可以在 `pake.json` 修改 windows 属性对应的 `width/height`,fullscreen 是否全屏,resizable 是否可以调整大小,hide_on_close 关闭时是否隐藏窗口而不是退出,假如想适配 Mac 沉浸式头部,可以将 hideTitleBar 设置成 `true`,找到 Header 元素加一个 padding-top 样式即可,不想适配改成 `false` 也行。
|
||||
4. 此外样式改写、屏蔽广告、逻辑代码注入、容器消息通信、自定义快捷键可见 [高级用法](https://github.com/tw93/Pake/wiki/Pake-%E7%9A%84%E9%AB%98%E7%BA%A7%E7%94%A8%E6%B3%95)。
|
||||
- **[CLI 使用指南](docs/cli-usage_CN.md)** - 命令行接口参考
|
||||
- **[高级用法指南](docs/advanced-usage_CN.md)** - 自定义和高级功能
|
||||
- **[GitHub Actions 指南](docs/github-actions-usage_CN.md)** - 在线构建应用
|
||||
- **[贡献指南](CONTRIBUTING.md)** - 如何参与开发
|
||||
|
||||
## 开发者
|
||||
|
||||
|
||||
12
README_JP.md
12
README_JP.md
@@ -1,4 +1,4 @@
|
||||
<h4 align="right"><a href="https://github.com/tw93/Pake">English</a> | <a href="https://github.com/tw93/Pake/blob/main/README_CN.md">简体中文</a> | <strong>日本語</strong></h4>
|
||||
<h4 align="right"><a href="README.md">English</a> | <a href="README_CN.md">简体中文</a> | <strong>日本語</strong></h4>
|
||||
<p align="center">
|
||||
<img src=https://gw.alipayobjects.com/zos/k/fa/logo-modified.png width=138/>
|
||||
</p>
|
||||
@@ -154,7 +154,7 @@
|
||||
|
||||
## 始める前に
|
||||
|
||||
1. **初心者の方へ**: 「人気のパッケージ」を使用して Pake の機能を試してみてください。または、[GitHub Actions](<https://github.com/tw93/Pake/wiki/Online-Compilation-(used-by-ordinary-users)>)を使用してアプリケーションをパッケージ化してみてください。[ディスカッション](https://github.com/tw93/Pake/discussions)で助けを求めることもできます!
|
||||
1. **初心者の方へ**: 「人気のパッケージ」を使用して Pake の機能を試してみてください。または、[GitHub Actions](docs/github-actions-usage.md)を使用してアプリケーションをパッケージ化してみてください。[ディスカッション](https://github.com/tw93/Pake/discussions)で助けを求めることもできます!
|
||||
2. **開発者の方へ**: 「コマンドラインパッケージング」を使用してください。macOS では完全にサポートされています。Windows/Linux ユーザーは、[環境を設定](https://tauri.app/start/prerequisites/)する必要があります。
|
||||
3. **ハッカーの方へ**: フロントエンド開発と Rust の両方が得意な方は、以下の[カスタマイズ開発](#開発)でアプリの機能をさらにカスタマイズしてみてください。
|
||||
|
||||
@@ -162,7 +162,7 @@
|
||||
|
||||

|
||||
|
||||
**Pake はコマンドラインツールを提供しており、必要なパッケージをより迅速かつ簡単にカスタマイズすることができます。詳細は[ドキュメント](./bin/README.md)をご覧ください。**
|
||||
**Pake はコマンドラインツールを提供しており、必要なパッケージをより迅速かつ簡単にカスタマイズすることができます。詳細は[CLI使用ガイド](docs/cli-usage.md)をご覧ください。**
|
||||
|
||||
```bash
|
||||
# 推奨方法 (pnpm)
|
||||
@@ -178,7 +178,7 @@ pake url [OPTIONS]...
|
||||
pake https://weekly.tw93.fun --name Weekly --hide-title-bar
|
||||
```
|
||||
|
||||
コマンドラインの使用に不慣れな場合は、_GitHub Actions_ を使用してオンラインでパッケージをコンパイルすることができます。[チュートリアル](<https://github.com/tw93/Pake/wiki/Online-Compilation-(used-by-ordinary-users)>)をご覧ください。
|
||||
コマンドラインの使用に不慣れな場合は、_GitHub Actions_ を使用してオンラインでパッケージをコンパイルすることができます。詳細な手順については [GitHub Actions 使用ガイド](docs/github-actions-usage.md) をご覧ください。
|
||||
|
||||
## 開発
|
||||
|
||||
@@ -199,10 +199,10 @@ pnpm run build
|
||||
|
||||
## 高度な使用法
|
||||
|
||||
1. [コードベースの構造](https://github.com/tw93/Pake/wiki/Description-of-Pake's-code-structure)を参照して、開発前により多くの情報を得ることができます。
|
||||
1. [CONTRIBUTING.md](CONTRIBUTING.md#project-structure)のコードベース構造を参照して、開発前により多くの情報を得ることができます。
|
||||
2. `src-tauri` ディレクトリ内の `pake.json` ファイルの `url` と `productName` フィールドを変更する場合は、`tauri.config.json` ファイル内の `domain` フィールド、および `tauri.xxx.conf.json` ファイル内の `icon` と `identifier` フィールドを同期して変更する必要があります。`icon` は `icons` ディレクトリから選択することも、[macOSicons](https://macosicons.com/#/) から効果に合ったものをダウンロードすることもできます。
|
||||
3. ウィンドウプロパティの設定については、`pake.json` ファイルを変更して `windows` プロパティの `width`、`height`、`fullscreen`(またはしない)、`resizable`(またはしない)の値を変更できます。Mac の没入型ヘッダーに適応するには、`hideTitleBar` を `true` に設定し、`Header` 要素を見つけて `padding-top` プロパティを追加します。
|
||||
4. スタイルの書き換え、広告の除去、JS の注入、コンテナメッセージ通信、ユーザー定義のショートカットキーについては、[高度な使用法](https://github.com/tw93/Pake/wiki/Advanced-Usage-of-Pake)を参照してください。
|
||||
4. スタイルの書き換え、広告の除去、JS の注入、コンテナメッセージ通信、ユーザー定義のショートカットキーについては、[高度な使用法](docs/advanced-usage.md)を参照してください。
|
||||
|
||||
## 開発者
|
||||
|
||||
|
||||
20
docs/README.md
Normal file
20
docs/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Pake Documentation
|
||||
|
||||
Welcome to Pake documentation! Here you'll find comprehensive guides and documentation to help you start working with Pake as quickly as possible.
|
||||
|
||||
## User Guides
|
||||
|
||||
- **[CLI Usage](cli-usage.md)** ([中文](cli-usage_CN.md)) - Command-line interface reference
|
||||
- **[GitHub Actions](github-actions-usage.md)** ([中文](github-actions-usage_CN.md)) - Build apps online without local setup
|
||||
|
||||
## Developer Guides
|
||||
|
||||
- **[Advanced Usage](advanced-usage.md)** ([中文](advanced-usage_CN.md)) - Customization, development, and advanced features
|
||||
- **[Contributing](../CONTRIBUTING.md)** - How to contribute to Pake development
|
||||
|
||||
## Quick Links
|
||||
|
||||
- [Main Repository](https://github.com/tw93/Pake)
|
||||
- [Releases](https://github.com/tw93/Pake/releases)
|
||||
- [Discussions](https://github.com/tw93/Pake/discussions)
|
||||
- [Issues](https://github.com/tw93/Pake/issues)
|
||||
174
docs/advanced-usage.md
Normal file
174
docs/advanced-usage.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# Advanced Usage
|
||||
|
||||
Customize Pake apps with style modifications, JavaScript injection, and container communication.
|
||||
|
||||
## Style Customization
|
||||
|
||||
Remove ads or customize appearance by modifying CSS.
|
||||
|
||||
**Quick Process:**
|
||||
|
||||
1. Run `pnpm run dev` for development
|
||||
2. Use DevTools to find elements to modify
|
||||
3. Edit `src-tauri/src/inject/style.js`:
|
||||
|
||||
```javascript
|
||||
const css = `
|
||||
.ads-banner { display: none !important; }
|
||||
.header { background: #1a1a1a !important; }
|
||||
`;
|
||||
```
|
||||
|
||||
## JavaScript Injection
|
||||
|
||||
Add custom functionality like keyboard shortcuts.
|
||||
|
||||
**Implementation:**
|
||||
|
||||
1. Edit `src-tauri/src/inject/event.js`
|
||||
2. Add event listeners:
|
||||
|
||||
```javascript
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.ctrlKey && e.key === "k") {
|
||||
// Custom action
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Container Communication
|
||||
|
||||
Send messages between web content and Pake container.
|
||||
|
||||
**Web Side (JavaScript):**
|
||||
|
||||
```javascript
|
||||
window.__TAURI__.invoke("handle_scroll", {
|
||||
scrollY: window.scrollY,
|
||||
scrollX: window.scrollX,
|
||||
});
|
||||
```
|
||||
|
||||
**Container Side (Rust):**
|
||||
|
||||
```rust
|
||||
#[tauri::command]
|
||||
fn handle_scroll(scroll_y: f64, scroll_x: f64) {
|
||||
println!("Scroll: {}, {}", scroll_x, scroll_y);
|
||||
}
|
||||
```
|
||||
|
||||
## Window Configuration
|
||||
|
||||
Configure window properties in `pake.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"windows": {
|
||||
"width": 1200,
|
||||
"height": 780,
|
||||
"fullscreen": false,
|
||||
"resizable": true
|
||||
},
|
||||
"hideTitleBar": true
|
||||
}
|
||||
```
|
||||
|
||||
## Static File Packaging
|
||||
|
||||
Package local HTML/CSS/JS files:
|
||||
|
||||
```bash
|
||||
pake ./my-app/index.html --name my-static-app --use-local-file
|
||||
```
|
||||
|
||||
Requirements: Pake CLI >= 3.0.0
|
||||
|
||||
## Project Structure
|
||||
|
||||
Understanding Pake's codebase structure will help you navigate and contribute effectively:
|
||||
|
||||
```tree
|
||||
├── bin/ # CLI source code (TypeScript)
|
||||
│ ├── builders/ # Platform-specific builders
|
||||
│ ├── helpers/ # Utility functions
|
||||
│ └── options/ # CLI option processing
|
||||
├── docs/ # Project documentation
|
||||
├── src-tauri/ # Tauri application core
|
||||
│ ├── src/
|
||||
│ │ ├── app/ # Core modules (window, tray, shortcuts)
|
||||
│ │ ├── inject/ # Web page injection logic
|
||||
│ │ └── lib.rs # Application entry point
|
||||
│ ├── icons/ # macOS icons (.icns)
|
||||
│ ├── png/ # Windows/Linux icons (.ico, .png)
|
||||
│ ├── pake.json # App configuration
|
||||
│ └── tauri.*.conf.json # Platform-specific configs
|
||||
├── scripts/ # Build and utility scripts
|
||||
└── tests/ # Test suites
|
||||
```
|
||||
|
||||
### Key Components
|
||||
|
||||
- **CLI Tool** (`bin/`): TypeScript-based command interface for packaging apps
|
||||
- **Tauri App** (`src-tauri/`): Rust-based desktop framework
|
||||
- **Injection System** (`src-tauri/src/inject/`): Custom CSS/JS injection for webpages
|
||||
- **Configuration**: Multi-platform app settings and build configurations
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Node.js ≥22.0.0 (recommended LTS, older versions ≥16.0.0 may work)
|
||||
- Rust ≥1.89.0 (recommended stable, older versions ≥1.78.0 may work)
|
||||
- Platform-specific build tools:
|
||||
- **macOS**: Xcode Command Line Tools (`xcode-select --install`)
|
||||
- **Windows**: Visual Studio Build Tools with MSVC
|
||||
- **Linux**: `build-essential`, `libwebkit2gtk`, system dependencies
|
||||
|
||||
### Installation
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/tw93/Pake.git
|
||||
cd Pake
|
||||
|
||||
# Install dependencies
|
||||
pnpm install
|
||||
|
||||
# Start development
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
### Development Commands
|
||||
|
||||
1. **CLI Changes**: Edit files in `bin/`, then run `pnpm run cli:build`
|
||||
2. **Core App Changes**: Edit files in `src-tauri/src/`, then run `pnpm run dev`
|
||||
3. **Injection Logic**: Modify files in `src-tauri/src/inject/` for web customizations
|
||||
4. **Testing**: Run `pnpm test` for comprehensive validation
|
||||
|
||||
- **Dev mode**: `pnpm run dev` (hot reload)
|
||||
- **Build**: `pnpm run build`
|
||||
- **Debug build**: `pnpm run build:debug`
|
||||
- **CLI build**: `pnpm run cli:build`
|
||||
|
||||
### Testing
|
||||
|
||||
```bash
|
||||
# Run all tests (unit + integration + builder)
|
||||
pnpm test
|
||||
|
||||
# Build CLI for testing
|
||||
pnpm run cli:build
|
||||
```
|
||||
|
||||
### Common Build Issues
|
||||
|
||||
- **Rust compilation errors**: Run `cargo clean` in `src-tauri/` directory
|
||||
- **Node dependency issues**: Delete `node_modules` and run `pnpm install`
|
||||
- **Permission errors on macOS**: Run `sudo xcode-select --reset`
|
||||
|
||||
## Links
|
||||
|
||||
- [CLI Documentation](cli-usage.md)
|
||||
- [Testing Guide](testing.md)
|
||||
- [GitHub Discussions](https://github.com/tw93/Pake/discussions)
|
||||
174
docs/advanced-usage_CN.md
Normal file
174
docs/advanced-usage_CN.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# 高级用法
|
||||
|
||||
通过样式修改、JavaScript 注入和容器通信等方式自定义 Pake 应用。
|
||||
|
||||
## 样式自定义
|
||||
|
||||
通过修改 CSS 移除广告或自定义外观。
|
||||
|
||||
**快速流程:**
|
||||
|
||||
1. 运行 `pnpm run dev` 进入开发模式
|
||||
2. 使用开发者工具找到要修改的元素
|
||||
3. 编辑 `src-tauri/src/inject/style.js`:
|
||||
|
||||
```javascript
|
||||
const css = `
|
||||
.ads-banner { display: none !important; }
|
||||
.header { background: #1a1a1a !important; }
|
||||
`;
|
||||
```
|
||||
|
||||
## JavaScript 注入
|
||||
|
||||
添加自定义功能,如键盘快捷键。
|
||||
|
||||
**实现方式:**
|
||||
|
||||
1. 编辑 `src-tauri/src/inject/event.js`
|
||||
2. 添加事件监听器:
|
||||
|
||||
```javascript
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.ctrlKey && e.key === "k") {
|
||||
// 自定义操作
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## 容器通信
|
||||
|
||||
在网页内容和 Pake 容器之间发送消息。
|
||||
|
||||
**网页端(JavaScript):**
|
||||
|
||||
```javascript
|
||||
window.__TAURI__.invoke("handle_scroll", {
|
||||
scrollY: window.scrollY,
|
||||
scrollX: window.scrollX,
|
||||
});
|
||||
```
|
||||
|
||||
**容器端(Rust):**
|
||||
|
||||
```rust
|
||||
#[tauri::command]
|
||||
fn handle_scroll(scroll_y: f64, scroll_x: f64) {
|
||||
println!("滚动位置: {}, {}", scroll_x, scroll_y);
|
||||
}
|
||||
```
|
||||
|
||||
## 窗口配置
|
||||
|
||||
在 `pake.json` 中配置窗口属性:
|
||||
|
||||
```json
|
||||
{
|
||||
"windows": {
|
||||
"width": 1200,
|
||||
"height": 780,
|
||||
"fullscreen": false,
|
||||
"resizable": true
|
||||
},
|
||||
"hideTitleBar": true
|
||||
}
|
||||
```
|
||||
|
||||
## 静态文件打包
|
||||
|
||||
打包本地 HTML/CSS/JS 文件:
|
||||
|
||||
```bash
|
||||
pake ./my-app/index.html --name my-static-app --use-local-file
|
||||
```
|
||||
|
||||
要求:Pake CLI >= 3.0.0
|
||||
|
||||
## 项目结构
|
||||
|
||||
了解 Pake 的代码库结构将帮助您有效地进行导航和贡献:
|
||||
|
||||
```tree
|
||||
├── bin/ # CLI 源代码 (TypeScript)
|
||||
│ ├── builders/ # 平台特定的构建器
|
||||
│ ├── helpers/ # 实用函数
|
||||
│ └── options/ # CLI 选项处理
|
||||
├── docs/ # 项目文档
|
||||
├── src-tauri/ # Tauri 应用核心
|
||||
│ ├── src/
|
||||
│ │ ├── app/ # 核心模块(窗口、托盘、快捷键)
|
||||
│ │ ├── inject/ # 网页注入逻辑
|
||||
│ │ └── lib.rs # 应用程序入口点
|
||||
│ ├── icons/ # macOS 图标 (.icns)
|
||||
│ ├── png/ # Windows/Linux 图标 (.ico, .png)
|
||||
│ ├── pake.json # 应用配置
|
||||
│ └── tauri.*.conf.json # 平台特定配置
|
||||
├── scripts/ # 构建和实用脚本
|
||||
└── tests/ # 测试套件
|
||||
```
|
||||
|
||||
### 关键组件
|
||||
|
||||
- **CLI 工具** (`bin/`): 基于 TypeScript 的命令接口,用于打包应用
|
||||
- **Tauri 应用** (`src-tauri/`): 基于 Rust 的桌面框架
|
||||
- **注入系统** (`src-tauri/src/inject/`): 用于网页的自定义 CSS/JS 注入
|
||||
- **配置**: 多平台应用设置和构建配置
|
||||
|
||||
## 开发工作流
|
||||
|
||||
### 前置条件
|
||||
|
||||
- Node.js ≥22.0.0 (推荐 LTS,较旧版本 ≥16.0.0 可能可用)
|
||||
- Rust ≥1.89.0 (推荐稳定版,较旧版本 ≥1.78.0 可能可用)
|
||||
- 平台特定构建工具:
|
||||
- **macOS**: Xcode 命令行工具 (`xcode-select --install`)
|
||||
- **Windows**: Visual Studio 构建工具与 MSVC
|
||||
- **Linux**: `build-essential`、`libwebkit2gtk`、系统依赖
|
||||
|
||||
### 安装
|
||||
|
||||
```bash
|
||||
# 克隆仓库
|
||||
git clone https://github.com/tw93/Pake.git
|
||||
cd Pake
|
||||
|
||||
# 安装依赖
|
||||
pnpm install
|
||||
|
||||
# 开始开发
|
||||
pnpm run dev
|
||||
```
|
||||
|
||||
### 开发命令
|
||||
|
||||
1. **CLI 更改**: 编辑 `bin/` 中的文件,然后运行 `pnpm run cli:build`
|
||||
2. **核心应用更改**: 编辑 `src-tauri/src/` 中的文件,然后运行 `pnpm run dev`
|
||||
3. **注入逻辑**: 修改 `src-tauri/src/inject/` 中的文件以进行网页自定义
|
||||
4. **测试**: 运行 `pnpm test` 进行综合验证
|
||||
|
||||
- **开发模式**:`pnpm run dev`(热重载)
|
||||
- **构建**:`pnpm run build`
|
||||
- **调试构建**:`pnpm run build:debug`
|
||||
- **CLI 构建**:`pnpm run cli:build`
|
||||
|
||||
### 测试
|
||||
|
||||
```bash
|
||||
# 运行所有测试(单元 + 集成 + 构建器)
|
||||
pnpm test
|
||||
|
||||
# 构建 CLI 以供测试
|
||||
pnpm run cli:build
|
||||
```
|
||||
|
||||
### 常见构建问题
|
||||
|
||||
- **Rust 编译错误**: 在 `src-tauri/` 目录中运行 `cargo clean`
|
||||
- **Node 依赖问题**: 删除 `node_modules` 并运行 `pnpm install`
|
||||
- **macOS 权限错误**: 运行 `sudo xcode-select --reset`
|
||||
|
||||
## 链接
|
||||
|
||||
- [CLI 文档](cli-usage_CN.md)
|
||||
- [测试指南](testing.md)
|
||||
- [GitHub 讨论区](https://github.com/tw93/Pake/discussions)
|
||||
@@ -1,4 +1,4 @@
|
||||
<h4 align="right"><strong>English</strong> | <a href="https://github.com/tw93/Pake/blob/main/bin/README_CN.md">简体中文</a></h4>
|
||||
<h4 align="right"><strong>English</strong> | <a href="cli-usage_CN.md">简体中文</a></h4>
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -346,6 +346,9 @@ Enable recursive copying. When the URL is a local file path, enabling this optio
|
||||
|
||||
```shell
|
||||
--use-local-file
|
||||
|
||||
# Basic static file packaging
|
||||
pake ./my-app/index.html --name "my-app" --use-local-file
|
||||
```
|
||||
|
||||
#### [inject]
|
||||
@@ -1,4 +1,4 @@
|
||||
<h4 align="right"><strong><a href="https://github.com/tw93/Pake/tree/main/bin">English</a></strong> | 简体中文</h4>
|
||||
<h4 align="right"><strong><a href="cli-usage.md">English</a></strong> | 简体中文</h4>
|
||||
|
||||
## 安装
|
||||
|
||||
@@ -345,6 +345,9 @@ pake https://flutter.dev --name FlutterApp --wasm
|
||||
|
||||
```shell
|
||||
--use-local-file
|
||||
|
||||
# 基础静态文件打包
|
||||
pake ./my-app/index.html --name "my-app" --use-local-file
|
||||
```
|
||||
|
||||
#### [inject]
|
||||
43
docs/github-actions-usage.md
Normal file
43
docs/github-actions-usage.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# GitHub Actions Usage Guide
|
||||
|
||||
Build Pake apps online without installing development tools locally.
|
||||
|
||||
## Quick Steps
|
||||
|
||||
### 1. Fork Repository
|
||||
|
||||
[Fork this project](https://github.com/tw93/Pake/fork)
|
||||
|
||||
### 2. Run Workflow
|
||||
|
||||
1. Go to Actions tab in your forked repository
|
||||
2. Select `Build App With Pake CLI`
|
||||
3. Fill in the form (same parameters as [CLI options](cli-usage.md))
|
||||
4. Click `Run Workflow`
|
||||
|
||||

|
||||
|
||||
### 3. Download App
|
||||
|
||||
- Green checkmark = build success
|
||||
- Click the workflow name to view details
|
||||
- Find `Artifacts` section and download your app
|
||||
|
||||

|
||||
|
||||
### 4. Build Times
|
||||
|
||||
- **First run**: ~10-15 minutes (sets up cache)
|
||||
- **Subsequent runs**: ~5 minutes (uses cache)
|
||||
- Cache size: 400-600MB when complete
|
||||
|
||||
## Tips
|
||||
|
||||
- Be patient on first run - let cache build completely
|
||||
- Stable network connection recommended
|
||||
- If build fails, delete cache and retry
|
||||
|
||||
## Links
|
||||
|
||||
- [CLI Documentation](cli-usage.md)
|
||||
- [Advanced Usage](advanced-usage.md)
|
||||
43
docs/github-actions-usage_CN.md
Normal file
43
docs/github-actions-usage_CN.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# GitHub Actions 使用指南
|
||||
|
||||
无需本地安装开发工具,在线构建 Pake 应用。
|
||||
|
||||
## 快速步骤
|
||||
|
||||
### 1. Fork 仓库
|
||||
|
||||
[Fork 此项目](https://github.com/tw93/Pake/fork)
|
||||
|
||||
### 2. 运行工作流
|
||||
|
||||
1. 前往你 Fork 的仓库的 Actions 页面
|
||||
2. 选择 `Build App With Pake CLI`
|
||||
3. 填写表单(参数与 [CLI 选项](cli-usage_CN.md) 相同)
|
||||
4. 点击 `Run Workflow`
|
||||
|
||||

|
||||
|
||||
### 3. 下载应用
|
||||
|
||||
- 绿色勾号 = 构建成功
|
||||
- 点击工作流名称查看详情
|
||||
- 在 `Artifacts` 部分下载应用
|
||||
|
||||

|
||||
|
||||
### 4. 构建时间
|
||||
|
||||
- **首次运行**:约 10-15 分钟(建立缓存)
|
||||
- **后续运行**:约 5 分钟(使用缓存)
|
||||
- 缓存大小:完成时为 400-600MB
|
||||
|
||||
## 提示
|
||||
|
||||
- 首次运行需要耐心等待,让缓存完全建立
|
||||
- 建议网络连接稳定
|
||||
- 如果构建失败,删除缓存后重试
|
||||
|
||||
## 链接
|
||||
|
||||
- [CLI 文档](cli-usage_CN.md)
|
||||
- [高级用法](advanced-usage_CN.md)
|
||||
Reference in New Issue
Block a user