Skip to content

Commit

Permalink
🔖 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tw93 committed May 9, 2024
2 parents 817c117 + b37b06e commit 99c8167
Show file tree
Hide file tree
Showing 23 changed files with 241 additions and 118 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pake-cli.yaml
Expand Up @@ -28,8 +28,8 @@ on:
description: '[Height, Optional]'
required: false
default: '780'
transparent:
description: '[Transparent, Optional, MacOS only]'
hide_title_bar:
description: '[Hide TitleBar, Optional, MacOS only]'
required: false
type: boolean
default: false
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
ICON: ${{ inputs.icon }}
HEIGHT: ${{ inputs.height }}
WIDTH: ${{ inputs.width }}
TRANSPARENT: ${{ inputs.transparent }}
HIDE_TITLE_BAR: ${{ inputs.hide_title_bar }}
FULLSCREEN: ${{ inputs.fullscreen }}
RESIZE: ${{ inputs.resize }}
MULTI_ARCH: ${{ inputs.multi_arch }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -171,7 +171,7 @@ npm install -g pake-cli
pake url [OPTIONS]...

# Feel free to play with Pake! It might take a while to prepare the environment the first time you launch Pake.
pake https://weekly.tw93.fun --name Weekly --transparent
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.
Expand All @@ -197,7 +197,7 @@ npm run build

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) of the `windows` property. To adapt to the immersive header on Mac, change `transparent` to `true`, look for the `Header` element, and add the `padding-top` property.
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) 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).

## Developers
Expand Down
4 changes: 2 additions & 2 deletions README_CN.md
Expand Up @@ -174,7 +174,7 @@ npm install -g pake-cli
pake url [OPTIONS]...

# 随便玩玩,首次由于安装环境会有些慢,后面就快了
pake https://weekly.tw93.fun --name Weekly --transparent
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)
Expand All @@ -199,7 +199,7 @@ npm 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 是否可以调整大小,假如想适配 Mac 沉浸式头部,可以将 transparent 设置成 `true`,找到 Header 元素加一个 padding-top 样式即可,不想适配改成 `false` 也行。
3. 关于窗口属性设置,可以在 `pake.json` 修改 windows 属性对应的 `width/height`,fullscreen 是否全屏,resizable 是否可以调整大小,假如想适配 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)

## 开发者
Expand Down
6 changes: 0 additions & 6 deletions apps.conf.json
Expand Up @@ -18,12 +18,6 @@
"name_zh": "YouTube",
"url": "https://www.youtube.com"
},
{
"name": "reference",
"title": "Reference",
"name_zh": "Reference",
"url": "https://quickref.me/zh-CN/"
},
{
"name": "coderunner",
"title": "CodeRunner",
Expand Down
64 changes: 49 additions & 15 deletions bin/README.md
Expand Up @@ -2,7 +2,7 @@

## Installation

Ensure that your Node.js version is 16.0 or higher (e.g., 16.8). Avoid using `sudo` for the installation. If you encounter permission issues with npm, refer to [How to fix npm throwing error without sudo](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo).
Ensure that your Node.js version is 18.0 or higher (e.g., 18.20.2). Avoid using `sudo` for the installation. If you encounter permission issues with npm, refer to [How to fix npm throwing error without sudo](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo).

```bash
npm install pake-cli -g
Expand Down Expand Up @@ -52,12 +52,11 @@ export const DEFAULT_DEV_PAKE_OPTIONS: PakeCliOptions & {url: string} = {

then


```bash
yarn cli:dev
```

The script will reads the above configuration and packages the specified `app` using `watch` mode, and changes to the `pake-cli` code and `pake` are hot updated in real time.
The script will read the above configuration and packages the specified `app` using `watch` mode, and changes to the `pake-cli` code and `pake` are hot updated in real time.

### CLI Usage

Expand All @@ -82,7 +81,7 @@ Various options are available for customization. You can pass corresponding argu
Specify the application name. If not provided, you will be prompted to enter it. It is recommended to use English.

```shell
--name <value>
--name <string>
```

#### [icon]
Expand Down Expand Up @@ -113,22 +112,48 @@ Set the width of the application window. Default is `1200px`.
--width <number>
```

#### [transparent]
#### [hide-title-bar]

Enable or disable immersive header. Default is `false`. Use the following command to enable this feature, macOS only.

```shell
--transparent
--hide-title-bar
```

#### [fullscreen]

Determine whether the application launches in full screen. Default is `false`. Use the following command to enable full screen.
Determine whether the application launches in full screen. Default is `false`. Use the following command to enable full
screen.

```shell
--fullscreen
```


#### [activation-shortcut]

Set the activation shortcut for the application. Default is ` `, it does not take effect, you can customize the activation shortcut with the following commands, e.g. `CmdOrControl+Shift+P`, use can refer to [available-modifiers](https://www.electronjs.org/docs/latest/api/accelerator#available-modifiers).

```shell
--activation-shortcut <string>
```

#### [always-on-top]

Sets whether the window is always at the top level, defaults to `false`.

```shell
--always-on-top
```

#### [disabled-web-shortcuts]

Sets whether to disable web shortcuts in the original Pake container, defaults to `false`.

```shell
--disabled-web-shortcuts
```

#### [multi-arch]

Package the application to support both Intel and M1 chips, exclusively for macOS. Default is `false`.
Expand All @@ -138,15 +163,15 @@ Package the application to support both Intel and M1 chips, exclusively for macO
- Note: After enabling this option, Rust must be installed using rustup from the official Rust website. Installation via brew is not supported.
- For Intel chip users, install the arm64 cross-platform package to support M1 chips using the following command:

```shell
rustup target add aarch64-apple-darwin
```
```shell
rustup target add aarch64-apple-darwin
```

- For M1 chip users, install the x86 cross-platform package to support Intel chips using the following command:

```shell
rustup target add x86_64-apple-darwin
```
```shell
rustup target add x86_64-apple-darwin
```

##### Usage

Expand All @@ -167,7 +192,7 @@ Select the output package format for Linux. Options include `deb`, `appimage`, o
Customize the browser user agent. Default is empty.

```shell
--user-agent <value>
--user-agent <string>
```

#### [show-system-tray]
Expand Down Expand Up @@ -195,22 +220,31 @@ Enable recursive copying. When the URL is a local file path, enabling this optio
```

#### [inject]

Using `inject`, you can inject local absolute and relative path `css` and `js` files into the page you specify the `url` to customize it. For example, an adblock script that can be applied to any web page, or a `css` that optimizes the `UI` of a page, you can write it once to customize it. would only need to write the `app` once to generalize it to any other page.

```shell
--inject ./tools/style.css,./tools/hotkey.js
```

#### [safe-domain]

This secure domain is a domain other than your currently configured `url` to which you may be redirected or jumped to, and only in domains that have been configured as secure can you use `tauri` to expose `api` to browsers to ensure that pake's built-in enhancements work correctly. Only in a domain that has been configured as secure can you use the `tauri` to expose the `api` to the browser, ensuring that `pake's` built-in enhancements work correctly.

PS: Secure domains do not need to carry protocols.


```shell
--safe-domain weread.qq.com,google.com
```

#### [debug]

The typed package has dev-tools for debugging, in addition to outputting more log messages for debugging.

```shell
--debug
```

## Conclusion

After completing the above steps, your application should be successfully packaged. Please note that the packaging process may take some time depending on your system configuration and network conditions. Be patient, and once the packaging is complete, you can find the application installer in the specified directory.
Expand Down
60 changes: 46 additions & 14 deletions bin/README_CN.md
Expand Up @@ -2,7 +2,7 @@

## 安装

请确保您的 Node.js 版本为 16 或更高版本(例如 16.8)。请避免使用 `sudo` 进行安装。如果 npm 报告权限问题,请参考 [如何在不使用 sudo 的情况下修复 npm 报错](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo)
请确保您的 Node.js 版本为 18 或更高版本(例如 18.7)。请避免使用 `sudo` 进行安装。如果 npm 报告权限问题,请参考 [如何在不使用 sudo 的情况下修复 npm 报错](https://stackoverflow.com/questions/16151018/how-to-fix-npm-throwing-error-without-sudo)

```bash
npm install pake-cli -g
Expand Down Expand Up @@ -40,6 +40,7 @@ npm install pake-cli -g
## 使用方法

### 开发

开发时可以修改 `bin/defaults.ts``DEFAULT_DEV_PAKE_OPTIONS` 配置,配置项和 `pake-cli` 配置说明保持一致

```typescript
Expand All @@ -58,7 +59,6 @@ yarn cli:dev

脚本会读取上述配置并使用 `watch` 模式打包指定的 `app`,对 `pake-cli` 代码和 `pake` 的修改都会实时热更新。


### 使用 CLI

```bash
Expand All @@ -79,10 +79,10 @@ pake [url] [options]

#### [name]

指定应用程序的名称如果在输入时未指定,系统会提示您输入。建议使用英文名称
指定应用程序的名称如果在输入时未指定,系统会提示您输入,建议使用单个英文名称,不要出现下划线或者中文

```shell
--name <value>
--name <string>
```

#### [icon]
Expand Down Expand Up @@ -114,12 +114,12 @@ pake [url] [options]
--width <number>
```

#### [transparent]
#### [hide-title-bar]

设置是否启用沉浸式头部,默认为 `false`(不启用)。当前只对 macOS 上有效。

```shell
--transparent
--hide-title-bar
```

#### [fullscreen]
Expand All @@ -130,6 +130,30 @@ pake [url] [options]
--fullscreen
```

#### [activation-shortcut]

设置应用程序的激活快捷键。默认为空,不生效,可以使用以下命令自定义激活快捷键,例如 `CmdOrControl+Shift+P`,使用可参考 [available-modifiers](https://www.electronjs.org/docs/latest/api/accelerator#available-modifiers)

```shell
--activation-shortcut <string>
```

#### [always-on-top]

设置是否窗口一直在最顶层,默认为 `false`

```shell
--always-on-top
```

#### [disabled-web-shortcuts]

设置是否禁用原有 Pake 容器里面的网页操作快捷键,默认为 `false`

```shell
--disabled-web-shortcuts
```

#### [multi-arch]

设置打包结果同时支持 Intel 和 M1 芯片,仅适用于 macOS,默认为 `false`
Expand All @@ -139,15 +163,15 @@ pake [url] [options]
- 注意:启用此选项后,需要使用 rust 官网的 rustup 安装 rust,不支持通过 brew 安装。
- 对于 Intel 芯片用户,需要安装 arm64 跨平台包,以使安装包支持 M1 芯片。使用以下命令安装:

```shell
rustup target add aarch64-apple-darwin
```
```shell
rustup target add aarch64-apple-darwin
```

- 对于 M1 芯片用户,需要安装 x86 跨平台包,以使安装包支持 Intel 芯片。使用以下命令安装:

```shell
rustup target add x86_64-apple-darwin
```
```shell
rustup target add x86_64-apple-darwin
```

##### 使用方法

Expand All @@ -161,15 +185,15 @@ rustup target add x86_64-apple-darwin
Linux,默认为 `all`

```shell
--targets <value>
--targets <string>
```

#### [user-agent]

自定义浏览器的用户代理请求头,默认为空。

```shell
--user-agent <value>
--user-agent <string>
```

#### [show-system-tray]
Expand Down Expand Up @@ -222,6 +246,14 @@ PS: 安全域名不需要携带协议。
--safe-domain weread.qq.com,google.com
```

#### [debug]

打出来的包具备 deb-tools 的调试模式,此外还会输出更多的日志信息用于调试。

```shell
--debug
```

## 结语

完成上述步骤后,您的应用程序应该已经成功打包。请注意,根据您的系统配置和网络状况,打包过程可能需要一些时间。请耐心等待,一旦打包完成,您就可以在指定的目录中找到应用程序安装包。
7 changes: 4 additions & 3 deletions bin/builders/BaseBuilder.ts
Expand Up @@ -49,7 +49,7 @@ export default abstract class BaseBuilder {
const isChina = await isChinaDomain('www.npmjs.com');
const spinner = getSpinner('Installing package...');
const rustProjectDir = path.join(tauriSrcPath, '.cargo');
const projectConf = path.join(rustProjectDir, 'config');
const projectConf = path.join(rustProjectDir, 'config.toml');
await fsExtra.ensureDir(rustProjectDir);

if (isChina) {
Expand All @@ -73,7 +73,7 @@ export default abstract class BaseBuilder {

async start(url: string) {
await mergeConfig(url, this.options, tauriConfig);
}
}

async buildAndCopy(url: string, target: string) {
const { name } = this.options;
Expand Down Expand Up @@ -107,7 +107,8 @@ export default abstract class BaseBuilder {
}

protected getBasePath(): string {
return 'src-tauri/target/release/bundle/';
const basePath = this.options.debug ? 'debug' : 'release';
return `src-tauri/target/${basePath}/bundle/`;
}

protected getBuildAppPath(npmDirectory: string, fileName: string, fileType: string): string {
Expand Down

0 comments on commit 99c8167

Please sign in to comment.