🎨 Refactor document
This commit is contained in:
@@ -161,10 +161,10 @@ In addition, double-click the title bar to switch to full-screen mode. For Mac u
|
|||||||
# Install
|
# Install
|
||||||
pnpm install -g pake-cli
|
pnpm install -g pake-cli
|
||||||
|
|
||||||
# Basic usage
|
# Basic usage (auto-fetch website icon)
|
||||||
pake https://weekly.tw93.fun --name Weekly
|
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
|
pake https://weekly.tw93.fun --name Weekly --icon https://cdn.tw93.fun/pake/weekly.icns --hide-title-bar
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -162,10 +162,10 @@
|
|||||||
# 安装
|
# 安装
|
||||||
pnpm install -g pake-cli
|
pnpm install -g pake-cli
|
||||||
|
|
||||||
# 基础使用
|
# 基础使用(自动获取网站图标)
|
||||||
pake https://weekly.tw93.fun --name Weekly
|
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
|
pake https://weekly.tw93.fun --name Weekly --icon https://cdn.tw93.fun/pake/weekly.icns --hide-title-bar
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -161,10 +161,10 @@
|
|||||||
# インストール
|
# インストール
|
||||||
pnpm install -g pake-cli
|
pnpm install -g pake-cli
|
||||||
|
|
||||||
# 基本使用
|
# 基本使用(ウェブサイトのアイコンを自動取得)
|
||||||
pake https://weekly.tw93.fun --name Weekly
|
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
|
pake https://weekly.tw93.fun --name Weekly --icon https://cdn.tw93.fun/pake/weekly.icns --hide-title-bar
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
50
bin/options/icon.ts
vendored
50
bin/options/icon.ts
vendored
@@ -20,14 +20,7 @@ type PlatformIconConfig = {
|
|||||||
};
|
};
|
||||||
const ICON_CONFIG = {
|
const ICON_CONFIG = {
|
||||||
minFileSize: 100,
|
minFileSize: 100,
|
||||||
supportedFormats: [
|
supportedFormats: ['png', 'ico', 'jpeg', 'jpg', 'webp', 'icns'] as const,
|
||||||
'png',
|
|
||||||
'ico',
|
|
||||||
'jpeg',
|
|
||||||
'jpg',
|
|
||||||
'webp',
|
|
||||||
'icns',
|
|
||||||
] as const,
|
|
||||||
whiteBackground: { r: 255, g: 255, b: 255 },
|
whiteBackground: { r: 255, g: 255, b: 255 },
|
||||||
transparentBackground: { r: 255, g: 255, b: 255, alpha: 0 },
|
transparentBackground: { r: 255, g: 255, b: 255, alpha: 0 },
|
||||||
downloadTimeout: {
|
downloadTimeout: {
|
||||||
@@ -43,14 +36,8 @@ const PLATFORM_CONFIG: Record<'win' | 'linux' | 'macos', PlatformIconConfig> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const API_KEYS = {
|
const API_KEYS = {
|
||||||
logoDev: [
|
logoDev: ['pk_JLLMUKGZRpaG5YclhXaTkg', 'pk_Ph745P8mQSeYFfW2Wk039A'],
|
||||||
'pk_JLLMUKGZRpaG5YclhXaTkg',
|
brandfetch: ['1idqvJC0CeFSeyp3Yf7', '1idej-yhU_ThggIHFyG'],
|
||||||
'pk_Ph745P8mQSeYFfW2Wk039A',
|
|
||||||
],
|
|
||||||
brandfetch: [
|
|
||||||
'1idqvJC0CeFSeyp3Yf7',
|
|
||||||
'1idej-yhU_ThggIHFyG',
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,7 +70,9 @@ async function copyWindowsIconIfNeeded(
|
|||||||
await fsExtra.copy(convertedPath, finalIconPath);
|
await fsExtra.copy(convertedPath, finalIconPath);
|
||||||
return finalIconPath;
|
return finalIconPath;
|
||||||
} catch (error) {
|
} 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;
|
return convertedPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,7 +177,10 @@ async function convertIconFormat(
|
|||||||
/**
|
/**
|
||||||
* Processes downloaded or local icon for platform-specific format
|
* 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;
|
if (!iconPath || !appName) return iconPath;
|
||||||
|
|
||||||
// Check if already in correct platform format
|
// Check if already in correct platform format
|
||||||
@@ -219,7 +211,10 @@ async function getDefaultIcon(): Promise<string> {
|
|||||||
|
|
||||||
if (IS_WIN) {
|
if (IS_WIN) {
|
||||||
const defaultIcoPath = generateIconPath('icon', true);
|
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
|
// Try default ico first
|
||||||
if (await fsExtra.pathExists(defaultIcoPath)) {
|
if (await fsExtra.pathExists(defaultIcoPath)) {
|
||||||
@@ -235,7 +230,9 @@ async function getDefaultIcon(): Promise<string> {
|
|||||||
return await copyWindowsIconIfNeeded(convertedPath, 'icon');
|
return await copyWindowsIconIfNeeded(convertedPath, 'icon');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} 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
|
// 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);
|
return path.join(npmDirectory, iconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,8 +342,13 @@ async function tryGetFavicon(
|
|||||||
|
|
||||||
const convertedPath = await convertIconFormat(faviconPath, appName);
|
const convertedPath = await convertIconFormat(faviconPath, appName);
|
||||||
if (convertedPath) {
|
if (convertedPath) {
|
||||||
const finalPath = await copyWindowsIconIfNeeded(convertedPath, appName);
|
const finalPath = await copyWindowsIconIfNeeded(
|
||||||
spinner.succeed(chalk.green('Icon fetched and converted successfully!'));
|
convertedPath,
|
||||||
|
appName,
|
||||||
|
);
|
||||||
|
spinner.succeed(
|
||||||
|
chalk.green('Icon fetched and converted successfully!'),
|
||||||
|
);
|
||||||
return finalPath;
|
return finalPath;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ source ~/.bashrc
|
|||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Basic usage - just provide a URL
|
# Basic usage - just provide a URL (auto-fetch website icon)
|
||||||
pake https://weekly.tw93.fun --name "Weekly"
|
pake https://weekly.tw93.fun --name "Weekly"
|
||||||
|
|
||||||
# With custom icon and window size (macOS example)
|
# 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
|
# macOS immersive experience
|
||||||
pake https://weekly.tw93.fun --name "Weekly" --hide-title-bar
|
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
|
## 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:
|
Various options are available for customization. Here are the most commonly used ones:
|
||||||
|
|
||||||
| Option | Description | Example |
|
| Option | Description | Example |
|
||||||
| ------------------ | ------------------------------ | ---------------------------------------------- |
|
| ------------------ | ----------------------------------------------- | ---------------------------------------------- |
|
||||||
| `--name` | Application name | `--name "Weekly"` |
|
| `--name` | Application name | `--name "Weekly"` |
|
||||||
| `--icon` | Application icon | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
|
| `--icon` | Custom icon (optional, auto-fetch website icon) | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
|
||||||
| `--width` | Window width (default: 1200px) | `--width 1400` |
|
| `--width` | Window width (default: 1200px) | `--width 1400` |
|
||||||
| `--height` | Window height (default: 780px) | `--height 900` |
|
| `--height` | Window height (default: 780px) | `--height 900` |
|
||||||
| `--hide-title-bar` | Immersive header (macOS only) | `--hide-title-bar` |
|
| `--hide-title-bar` | Immersive header (macOS only) | `--hide-title-bar` |
|
||||||
| `--debug` | Enable development tools | `--debug` |
|
| `--debug` | Enable development tools | `--debug` |
|
||||||
|
|
||||||
For complete options, see detailed sections below.
|
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]
|
#### [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.
|
Supports both local and remote files, automatically converts to platform-specific formats:
|
||||||
- For Windows, use `.ico` format.
|
|
||||||
- For Linux, use `.png` format.
|
- macOS: `.icns` format
|
||||||
|
- Windows: `.ico` format
|
||||||
|
- Linux: `.png` format
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
--icon <path>
|
--icon <path>
|
||||||
|
|
||||||
# Examples:
|
# Examples:
|
||||||
|
# Without --icon parameter, auto-fetch website icon
|
||||||
|
pake https://github.com --name GitHub
|
||||||
|
|
||||||
|
# With custom icons
|
||||||
--icon ./my-icon.png
|
--icon ./my-icon.png
|
||||||
--icon https://cdn.tw93.fun/pake/weekly.icns # Remote icon (.icns for macOS)
|
--icon https://cdn.tw93.fun/pake/weekly.icns # Remote icon (.icns for macOS)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ source ~/.bashrc
|
|||||||
## 快速开始
|
## 快速开始
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 基础用法 - 只需要提供URL
|
# 基础用法 - 只需要提供URL(自动获取网站图标)
|
||||||
pake https://weekly.tw93.fun --name "Weekly"
|
pake https://weekly.tw93.fun --name "Weekly"
|
||||||
|
|
||||||
# 自定义图标和窗口大小(macOS示例)
|
# 自定义图标和窗口大小(macOS示例)
|
||||||
@@ -49,6 +49,12 @@ pake https://weekly.tw93.fun --name "Weekly" --icon https://cdn.tw93.fun/pake/we
|
|||||||
|
|
||||||
# macOS 沉浸式体验
|
# macOS 沉浸式体验
|
||||||
pake https://weekly.tw93.fun --name "Weekly" --hide-title-bar
|
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"` |
|
| `--name` | 应用程序名称 | `--name "Weekly"` |
|
||||||
| `--icon` | 应用程序图标 | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
|
| `--icon` | 自定义图标(可选,自动获取网站图标) | `--icon https://cdn.tw93.fun/pake/weekly.icns` |
|
||||||
| `--width` | 窗口宽度(默认:1200px) | `--width 1400` |
|
| `--width` | 窗口宽度(默认:1200px) | `--width 1400` |
|
||||||
| `--height` | 窗口高度(默认:780px) | `--height 900` |
|
| `--height` | 窗口高度(默认:780px) | `--height 900` |
|
||||||
| `--hide-title-bar` | 沉浸式标题栏(仅macOS) | `--hide-title-bar` |
|
| `--hide-title-bar` | 沉浸式标题栏(仅macOS) | `--hide-title-bar` |
|
||||||
| `--debug` | 启用开发者工具 | `--debug` |
|
| `--debug` | 启用开发者工具 | `--debug` |
|
||||||
|
|
||||||
完整选项请参见下面的详细说明:
|
完整选项请参见下面的详细说明:
|
||||||
|
|
||||||
@@ -101,16 +107,22 @@ pake [url] [options]
|
|||||||
|
|
||||||
#### [icon]
|
#### [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
|
```shell
|
||||||
--icon <path>
|
--icon <path>
|
||||||
|
|
||||||
# 示例:
|
# 示例:
|
||||||
|
# 不传 --icon 参数,自动获取网站图标
|
||||||
|
pake https://github.com --name GitHub
|
||||||
|
|
||||||
|
# 使用自定义图标
|
||||||
--icon ./my-icon.png
|
--icon ./my-icon.png
|
||||||
--icon https://cdn.tw93.fun/pake/weekly.icns # 远程图标(.icns适用于macOS)
|
--icon https://cdn.tw93.fun/pake/weekly.icns # 远程图标(.icns适用于macOS)
|
||||||
```
|
```
|
||||||
@@ -275,6 +287,18 @@ pake [url] [options]
|
|||||||
--hide-on-close
|
--hide-on-close
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### [title]
|
||||||
|
|
||||||
|
设置窗口标题栏文本,macOS 未指定时不显示标题,Windows/Linux 回退使用应用名称。
|
||||||
|
|
||||||
|
```shell
|
||||||
|
--title <string>
|
||||||
|
|
||||||
|
# 示例:
|
||||||
|
--title "我的应用"
|
||||||
|
--title "音乐播放器"
|
||||||
|
```
|
||||||
|
|
||||||
#### [incognito]
|
#### [incognito]
|
||||||
|
|
||||||
以隐私/隐身浏览模式启动应用程序。默认为 `false`。启用后,webview 将在隐私模式下运行,这意味着它不会存储 cookie、本地存储或浏览历史记录。这对于注重隐私的应用程序很有用。
|
以隐私/隐身浏览模式启动应用程序。默认为 `false`。启用后,webview 将在隐私模式下运行,这意味着它不会存储 cookie、本地存储或浏览历史记录。这对于注重隐私的应用程序很有用。
|
||||||
@@ -320,18 +344,6 @@ pake https://github.com --name GitHub --keep-binary
|
|||||||
|
|
||||||
**输出结果**:同时创建安装包和独立可执行文件(Unix 系统为 `AppName-binary`,Windows 为 `AppName.exe`)。
|
**输出结果**:同时创建安装包和独立可执行文件(Unix 系统为 `AppName-binary`,Windows 为 `AppName.exe`)。
|
||||||
|
|
||||||
#### [title]
|
|
||||||
|
|
||||||
设置窗口标题栏文本,macOS 未指定时不显示标题,Windows/Linux 回退使用应用名称。
|
|
||||||
|
|
||||||
```shell
|
|
||||||
--title <string>
|
|
||||||
|
|
||||||
# 示例:
|
|
||||||
--title "我的应用"
|
|
||||||
--title "音乐播放器"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### [installer-language]
|
#### [installer-language]
|
||||||
|
|
||||||
设置 Windows 安装包语言。支持 `zh-CN`、`ja-JP`,更多在 [Tauri 文档](https://tauri.app/distribute/windows-installer/#internationalization)。默认为 `en-US`。
|
设置 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 \
|
docker run -it --rm \
|
||||||
-v ./packages:/output \
|
-v ./packages:/output \
|
||||||
ghcr.io/tw93/pake \
|
ghcr.io/tw93/pake \
|
||||||
https://example.com --name myapp --icon ./icon.png
|
https://example.com --name MyApp --icon ./icon.png
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
BIN
src-tauri/icons/githubautoicontest.icns
Normal file
BIN
src-tauri/icons/githubautoicontest.icns
Normal file
Binary file not shown.
Reference in New Issue
Block a user