🎨 Refactor document

This commit is contained in:
Tw93
2025-09-07 00:06:13 +08:00
parent d52238f8fd
commit 80bb412047
7 changed files with 96 additions and 68 deletions

View File

@@ -161,10 +161,10 @@ In addition, double-click the title bar to switch to full-screen mode. For Mac u
# Install
pnpm install -g pake-cli
# Basic usage
# Basic usage (auto-fetch website icon)
pake https://weekly.tw93.fun --name Weekly
# Common options: --name app name, --icon icon, --width/--height window size, --hide-title-bar macOS immersive
# Common options: --name app name, --icon custom icon, --width/--height window size, --hide-title-bar macOS immersive
pake https://weekly.tw93.fun --name Weekly --icon https://cdn.tw93.fun/pake/weekly.icns --hide-title-bar
```

View File

@@ -162,10 +162,10 @@
# 安装
pnpm install -g pake-cli
# 基础使用
# 基础使用(自动获取网站图标)
pake https://weekly.tw93.fun --name Weekly
# 常用参数:--name 应用名称,--icon 图标,--width/--height 窗口尺寸,--hide-title-bar macOS沉浸式
# 常用参数:--name 应用名称,--icon 自定义图标,--width/--height 窗口尺寸,--hide-title-bar macOS沉浸式
pake https://weekly.tw93.fun --name Weekly --icon https://cdn.tw93.fun/pake/weekly.icns --hide-title-bar
```

View File

@@ -161,10 +161,10 @@
# インストール
pnpm install -g pake-cli
# 基本使用
# 基本使用(ウェブサイトのアイコンを自動取得)
pake https://weekly.tw93.fun --name Weekly
# よく使うパラメータ:--name アプリ名、--icon アイコン、--width/--height ウィンドウサイズ、--hide-title-bar macOS没入型
# よく使うパラメータ:--name アプリ名、--icon カスタムアイコン、--width/--height ウィンドウサイズ、--hide-title-bar macOS没入型
pake https://weekly.tw93.fun --name Weekly --icon https://cdn.tw93.fun/pake/weekly.icns --hide-title-bar
```

50
bin/options/icon.ts vendored
View File

@@ -20,14 +20,7 @@ type PlatformIconConfig = {
};
const ICON_CONFIG = {
minFileSize: 100,
supportedFormats: [
'png',
'ico',
'jpeg',
'jpg',
'webp',
'icns',
] as const,
supportedFormats: ['png', 'ico', 'jpeg', 'jpg', 'webp', 'icns'] as const,
whiteBackground: { r: 255, g: 255, b: 255 },
transparentBackground: { r: 255, g: 255, b: 255, alpha: 0 },
downloadTimeout: {
@@ -43,14 +36,8 @@ const PLATFORM_CONFIG: Record<'win' | 'linux' | 'macos', PlatformIconConfig> = {
};
const API_KEYS = {
logoDev: [
'pk_JLLMUKGZRpaG5YclhXaTkg',
'pk_Ph745P8mQSeYFfW2Wk039A',
],
brandfetch: [
'1idqvJC0CeFSeyp3Yf7',
'1idej-yhU_ThggIHFyG',
],
logoDev: ['pk_JLLMUKGZRpaG5YclhXaTkg', 'pk_Ph745P8mQSeYFfW2Wk039A'],
brandfetch: ['1idqvJC0CeFSeyp3Yf7', '1idej-yhU_ThggIHFyG'],
};
/**
@@ -83,7 +70,9 @@ async function copyWindowsIconIfNeeded(
await fsExtra.copy(convertedPath, finalIconPath);
return finalIconPath;
} catch (error) {
logger.warn(`Failed to copy Windows icon: ${error instanceof Error ? error.message : 'Unknown error'}`);
logger.warn(
`Failed to copy Windows icon: ${error instanceof Error ? error.message : 'Unknown error'}`,
);
return convertedPath;
}
}
@@ -188,7 +177,10 @@ async function convertIconFormat(
/**
* Processes downloaded or local icon for platform-specific format
*/
async function processIcon(iconPath: string, appName: string): Promise<string | null> {
async function processIcon(
iconPath: string,
appName: string,
): Promise<string | null> {
if (!iconPath || !appName) return iconPath;
// Check if already in correct platform format
@@ -219,7 +211,10 @@ async function getDefaultIcon(): Promise<string> {
if (IS_WIN) {
const defaultIcoPath = generateIconPath('icon', true);
const defaultPngPath = path.join(npmDirectory, 'src-tauri/png/icon_512.png');
const defaultPngPath = path.join(
npmDirectory,
'src-tauri/png/icon_512.png',
);
// Try default ico first
if (await fsExtra.pathExists(defaultIcoPath)) {
@@ -235,7 +230,9 @@ async function getDefaultIcon(): Promise<string> {
return await copyWindowsIconIfNeeded(convertedPath, 'icon');
}
} catch (error) {
logger.warn(`Failed to convert default png to ico: ${error instanceof Error ? error.message : 'Unknown error'}`);
logger.warn(
`Failed to convert default png to ico: ${error instanceof Error ? error.message : 'Unknown error'}`,
);
}
}
@@ -250,7 +247,9 @@ async function getDefaultIcon(): Promise<string> {
}
// Linux and macOS defaults
const iconPath = IS_LINUX ? 'src-tauri/png/icon_512.png' : 'src-tauri/icons/icon.icns';
const iconPath = IS_LINUX
? 'src-tauri/png/icon_512.png'
: 'src-tauri/icons/icon.icns';
return path.join(npmDirectory, iconPath);
}
@@ -343,8 +342,13 @@ async function tryGetFavicon(
const convertedPath = await convertIconFormat(faviconPath, appName);
if (convertedPath) {
const finalPath = await copyWindowsIconIfNeeded(convertedPath, appName);
spinner.succeed(chalk.green('Icon fetched and converted successfully!'));
const finalPath = await copyWindowsIconIfNeeded(
convertedPath,
appName,
);
spinner.succeed(
chalk.green('Icon fetched and converted successfully!'),
);
return finalPath;
}
} catch (error) {

View File

@@ -41,7 +41,7 @@ source ~/.bashrc
## Quick Start
```bash
# Basic usage - just provide a URL
# Basic usage - just provide a URL (auto-fetch website icon)
pake https://weekly.tw93.fun --name "Weekly"
# With custom icon and window size (macOS example)
@@ -49,6 +49,12 @@ pake https://weekly.tw93.fun --name "Weekly" --icon https://cdn.tw93.fun/pake/we
# macOS immersive experience
pake https://weekly.tw93.fun --name "Weekly" --hide-title-bar
# Complete example with multiple options
pake https://github.com --name "GitHub Desktop" --width 1400 --height 900 --show-system-tray --debug
# Privacy-focused app with incognito mode
pake https://duckduckgo.com --name "DuckDuckGo" --incognito --always-on-top
```
## CLI Usage
@@ -71,14 +77,14 @@ The URL is the link to the web page you want to package or the path to a local H
Various options are available for customization. Here are the most commonly used ones:
| Option | Description | Example |
| ------------------ | ------------------------------ | ---------------------------------------------- |
| `--name` | Application name | `--name "Weekly"` |
| `--icon` | Application icon | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
| `--width` | Window width (default: 1200px) | `--width 1400` |
| `--height` | Window height (default: 780px) | `--height 900` |
| `--hide-title-bar` | Immersive header (macOS only) | `--hide-title-bar` |
| `--debug` | Enable development tools | `--debug` |
| Option | Description | Example |
| ------------------ | ----------------------------------------------- | ---------------------------------------------- |
| `--name` | Application name | `--name "Weekly"` |
| `--icon` | Custom icon (optional, auto-fetch website icon) | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
| `--width` | Window width (default: 1200px) | `--width 1400` |
| `--height` | Window height (default: 780px) | `--height 900` |
| `--hide-title-bar` | Immersive header (macOS only) | `--hide-title-bar` |
| `--debug` | Enable development tools | `--debug` |
For complete options, see detailed sections below.
@@ -101,16 +107,22 @@ Specify the application name. If not provided, you will be prompted to enter it.
#### [icon]
Specify the application icon. Supports both local and remote files. If not provided, Pake will intelligently fetch the website's icon. For custom icons, visit [icon-icons](https://icon-icons.com) or [macOSicons](https://macosicons.com/#/).
**Optional parameter**: If not provided, Pake will automatically fetch the website's icon and convert to the appropriate format. For custom icons, visit [icon-icons](https://icon-icons.com) or [macOSicons](https://macosicons.com/#/).
- For macOS, use `.icns` format.
- For Windows, use `.ico` format.
- For Linux, use `.png` format.
Supports both local and remote files, automatically converts to platform-specific formats:
- macOS: `.icns` format
- Windows: `.ico` format
- Linux: `.png` format
```shell
--icon <path>
# Examples:
# Without --icon parameter, auto-fetch website icon
pake https://github.com --name GitHub
# With custom icons
--icon ./my-icon.png
--icon https://cdn.tw93.fun/pake/weekly.icns # Remote icon (.icns for macOS)
```

View File

@@ -41,7 +41,7 @@ source ~/.bashrc
## 快速开始
```bash
# 基础用法 - 只需要提供URL
# 基础用法 - 只需要提供URL(自动获取网站图标)
pake https://weekly.tw93.fun --name "Weekly"
# 自定义图标和窗口大小macOS示例
@@ -49,6 +49,12 @@ pake https://weekly.tw93.fun --name "Weekly" --icon https://cdn.tw93.fun/pake/we
# macOS 沉浸式体验
pake https://weekly.tw93.fun --name "Weekly" --hide-title-bar
# 完整示例:多个选项组合使用
pake https://github.com --name "GitHub Desktop" --width 1400 --height 900 --show-system-tray --debug
# 注重隐私的应用:隐身模式
pake https://duckduckgo.com --name "DuckDuckGo" --incognito --always-on-top
```
## 命令行使用
@@ -71,14 +77,14 @@ pake [url] [options]
您可以通过传递以下选项来定制打包过程。以下是最常用的选项:
| 选项 | 描述 | 示例 |
| ------------------ | ------------------------ | ---------------------------------------------- |
| `--name` | 应用程序名称 | `--name "Weekly"` |
| `--icon` | 应用程序图标 | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
| `--width` | 窗口宽度默认1200px | `--width 1400` |
| `--height` | 窗口高度默认780px | `--height 900` |
| `--hide-title-bar` | 沉浸式标题栏仅macOS | `--hide-title-bar` |
| `--debug` | 启用开发者工具 | `--debug` |
| 选项 | 描述 | 示例 |
| ------------------ | ------------------------------------ | ---------------------------------------------- |
| `--name` | 应用程序名称 | `--name "Weekly"` |
| `--icon` | 自定义图标(可选,自动获取网站图标) | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
| `--width` | 窗口宽度默认1200px | `--width 1400` |
| `--height` | 窗口高度默认780px | `--height 900` |
| `--hide-title-bar` | 沉浸式标题栏仅macOS | `--hide-title-bar` |
| `--debug` | 启用开发者工具 | `--debug` |
完整选项请参见下面的详细说明:
@@ -101,16 +107,22 @@ pake [url] [options]
#### [icon]
指定应用程序的图标,支持本地或远程文件,不传此参数时Pake 会智能获取网站图标自定义图标可访问 [icon-icons](https://icon-icons.com) 或 [macOSicons](https://macosicons.com/#/) 下载。
**可选参数**不传此参数时Pake 会自动获取网站图标并转换为对应格式。如需自定义图标可访问 [icon-icons](https://icon-icons.com) 或 [macOSicons](https://macosicons.com/#/) 下载。
- macOS 要求使用 `.icns` 格式
- Windows 要求使用 `.ico` 格式。
- Linux 要求使用 `.png` 格式
支持本地或远程文件,自动转换为平台所需格式
- macOS`.icns` 格式
- Windows`.ico` 格式
- Linux`.png` 格式
```shell
--icon <path>
# 示例:
# 不传 --icon 参数,自动获取网站图标
pake https://github.com --name GitHub
# 使用自定义图标
--icon ./my-icon.png
--icon https://cdn.tw93.fun/pake/weekly.icns # 远程图标(.icns适用于macOS
```
@@ -275,6 +287,18 @@ pake [url] [options]
--hide-on-close
```
#### [title]
设置窗口标题栏文本macOS 未指定时不显示标题Windows/Linux 回退使用应用名称。
```shell
--title <string>
# 示例:
--title "我的应用"
--title "音乐播放器"
```
#### [incognito]
以隐私/隐身浏览模式启动应用程序。默认为 `false`。启用后webview 将在隐私模式下运行,这意味着它不会存储 cookie、本地存储或浏览历史记录。这对于注重隐私的应用程序很有用。
@@ -320,18 +344,6 @@ pake https://github.com --name GitHub --keep-binary
**输出结果**同时创建安装包和独立可执行文件Unix 系统为 `AppName-binary`Windows 为 `AppName.exe`)。
#### [title]
设置窗口标题栏文本macOS 未指定时不显示标题Windows/Linux 回退使用应用名称。
```shell
--title <string>
# 示例:
--title "我的应用"
--title "音乐播放器"
```
#### [installer-language]
设置 Windows 安装包语言。支持 `zh-CN`、`ja-JP`,更多在 [Tauri 文档](https://tauri.app/distribute/windows-installer/#internationalization)。默认为 `en-US`。
@@ -402,6 +414,6 @@ docker run -it --rm \ # Run interactively, remove container after exit
docker run -it --rm \
-v ./packages:/output \
ghcr.io/tw93/pake \
https://example.com --name myapp --icon ./icon.png
https://example.com --name MyApp --icon ./icon.png
```

Binary file not shown.