pake-cli 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -82
- package/dist/cli.js +88 -67
- package/package.json +12 -5
- package/src-tauri/Cargo.lock +59 -188
- package/src-tauri/Cargo.toml +5 -4
- package/src-tauri/assets/main.wxs +310 -0
- package/src-tauri/icons/chatgpt.icns +0 -0
- package/src-tauri/png/chatgpt_256.ico +0 -0
- package/src-tauri/png/chatgpt_32.ico +0 -0
- package/src-tauri/png/chatgpt_512.png +0 -0
- package/src-tauri/src/main.rs +101 -155
- package/src-tauri/src/pake.js +19 -9
- package/src-tauri/tauri.linux.conf.json +4 -2
- package/src-tauri/tauri.windows.conf.json +2 -1
- package/pake-default.icns +0 -0
- package/src-tauri/tauri.conf.json.bak +0 -30
package/README.md
CHANGED
|
@@ -14,29 +14,29 @@
|
|
|
14
14
|
<a href="https://github.com/tw93/Pake/issues?q=is%3Aissue+is%3Aclosed" target="_blank">
|
|
15
15
|
<img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/tw93/Pake.svg?style=flat-square"></a>
|
|
16
16
|
</div>
|
|
17
|
-
<div align="left">很简单的用 Rust 打包网页生成很小的桌面 App,支持 Mac / Windows / Linux 系统,常用包下载、<a href="
|
|
17
|
+
<div align="left">很简单的用 Rust 打包网页生成很小的桌面 App,支持 Mac / Windows / Linux 系统,常用包下载、<a href="#命令行一键打包">命令行一键打包</a>、<a href="#定制开发">定制开发</a> 可见下面文档,也欢迎去 <a href=https://github.com/tw93/Pake/discussions>讨论区</a> 交流。</div>
|
|
18
18
|
</p>
|
|
19
19
|
|
|
20
20
|
## 特征
|
|
21
21
|
|
|
22
|
-
🏂 **小**:相比传统的 Electron 套壳打包,要小将近 40 倍,不到 3M
|
|
23
|
-
😂 **快**:Pake 的底层使用的 Rust Tauri 框架,性能体验较 JS
|
|
24
|
-
🩴
|
|
25
|
-
🐶 **玩**:只是一个很简单的小玩具,用 Rust 替代之前套壳网页打包的老思路,其实 PWA
|
|
22
|
+
🏂 **小**:相比传统的 Electron 套壳打包,要小将近 40 倍,不到 3M。
|
|
23
|
+
😂 **快**:Pake 的底层使用的 Rust Tauri 框架,性能体验较 JS 框架要轻快不少,内存小很多。
|
|
24
|
+
🩴 **特**:不是单纯打包,实现了快捷键的透传、沉浸式的窗口、拖动、样式改写、去广告、产品的极简风格定制。
|
|
25
|
+
🐶 **玩**:只是一个很简单的小玩具,用 Rust 替代之前套壳网页打包的老思路,其实 PWA 也很好。
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## 常用包下载
|
|
28
28
|
|
|
29
29
|
<table>
|
|
30
30
|
<tr>
|
|
31
31
|
<td>WeRead
|
|
32
32
|
<a href="https://github.com/tw93/Pake/releases/latest/download/WeRead.dmg">Mac</a>
|
|
33
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/WeRead_amd64.deb">Linux</a>
|
|
34
33
|
<a href="https://github.com/tw93/Pake/releases/latest/download/WeRead_x64.msi">Windows</a>
|
|
34
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/WeRead_amd64.deb">Linux</a>
|
|
35
35
|
</td>
|
|
36
36
|
<td>Twitter
|
|
37
37
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Twitter.dmg">Mac</a>
|
|
38
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/Twitter_amd64.deb">Linux</a>
|
|
39
38
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Twitter_x64.msi">Windows</a>
|
|
39
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Twitter_amd64.deb">Linux</a>
|
|
40
40
|
</td>
|
|
41
41
|
</tr>
|
|
42
42
|
<tr>
|
|
@@ -44,63 +44,87 @@
|
|
|
44
44
|
<td><img src=https://cdn.fliggy.com/upic/mc41xq.jpg width=600/></td>
|
|
45
45
|
</tr>
|
|
46
46
|
<tr>
|
|
47
|
-
<td>
|
|
48
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/
|
|
49
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/
|
|
50
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/
|
|
47
|
+
<td>ChatGPT(代理被封已换官方)
|
|
48
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/ChatGPT.dmg">Mac</a>
|
|
49
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/ChatGPT_x64.msi">Windows</a>
|
|
50
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/ChatGPT_amd64.deb">Linux</a>
|
|
51
51
|
</td>
|
|
52
|
-
|
|
53
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/
|
|
54
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/
|
|
55
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/
|
|
52
|
+
<td>Qwerty
|
|
53
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Qwerty.dmg">Mac</a>
|
|
54
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Qwerty_x64.msi">Windows</a>
|
|
55
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Qwerty_amd64.deb">Linux</a>
|
|
56
56
|
</td>
|
|
57
57
|
</tr>
|
|
58
58
|
<tr>
|
|
59
|
-
<td><img src=https://cdn.fliggy.com/upic/
|
|
60
|
-
<td><img src=https://cdn.fliggy.com/upic/
|
|
59
|
+
<td><img src=https://cdn.fliggy.com/upic/sfnTXf.png width=600/></td>
|
|
60
|
+
<td><img src=https://cdn.fliggy.com/upic/CJjagn.jpg width=600/></td>
|
|
61
61
|
</tr>
|
|
62
62
|
<tr>
|
|
63
|
-
<td>Code
|
|
63
|
+
<td>Code
|
|
64
64
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Code.dmg">Mac</a>
|
|
65
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/Code_amd64.deb">Linux</a>
|
|
66
65
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Code_x64.msi">Windows</a>
|
|
66
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Code_amd64.deb">Linux</a>
|
|
67
67
|
</td>
|
|
68
|
-
|
|
69
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/
|
|
70
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/
|
|
71
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/
|
|
68
|
+
<td>Reference
|
|
69
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Reference.dmg">Mac</a>
|
|
70
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Reference_x64.msi">Windows</a>
|
|
71
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Reference_amd64.deb">Linux</a>
|
|
72
72
|
</td>
|
|
73
73
|
</tr>
|
|
74
74
|
<tr>
|
|
75
75
|
<td><img src=https://cdn.fliggy.com/upic/EB1OYP.jpg width=600/></td>
|
|
76
|
-
<td><img src=https://cdn.fliggy.com/upic/
|
|
76
|
+
<td><img src=https://cdn.fliggy.com/upic/KFsZIY.png width=600/></td>
|
|
77
77
|
</tr>
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
<tr>
|
|
79
|
+
<td>YouTube
|
|
80
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/YouTube.dmg">Mac</a>
|
|
81
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/YouTube_x64.msi">Windows</a>
|
|
82
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/YouTube_amd64.deb">Linux</a>
|
|
83
|
+
</td>
|
|
84
|
+
<td>Flomo
|
|
80
85
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Flomo.dmg">Mac</a>
|
|
81
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/Flomo_amd64.deb">Linux</a>
|
|
82
86
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Flomo_x64.msi">Windows</a>
|
|
83
|
-
|
|
84
|
-
<td>YuQue
|
|
85
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/YuQue.dmg">Mac</a>
|
|
86
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/YuQue_amd64.deb">Linux</a>
|
|
87
|
-
<a href="https://github.com/tw93/Pake/releases/latest/download/YuQue_x64.msi">Windows</a>
|
|
87
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Flomo_amd64.deb">Linux</a>
|
|
88
88
|
</td>
|
|
89
89
|
</tr>
|
|
90
90
|
<tr>
|
|
91
|
+
<td><img src=https://cdn.fliggy.com/upic/Ea5ZRw.png width=600/></td>
|
|
91
92
|
<td><img src=https://cdn.fliggy.com/upic/jg9Eeu.jpg width=600/></td>
|
|
92
|
-
<td><img src=https://cdn.fliggy.com/upic/02SZQl.png width=600/></td>
|
|
93
93
|
</tr>
|
|
94
94
|
</table>
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
<details>
|
|
97
|
+
<summary>🏂 <b>点击展开快捷键说明</b></summary>
|
|
98
|
+
|
|
99
|
+
<br/>
|
|
100
|
+
|
|
101
|
+
| Mac | Windows/Linux | 功能 |
|
|
102
|
+
| --------------------------- | ------------------------------ | ------------------ |
|
|
103
|
+
| <kbd>⌘</kbd> + <kbd>[</kbd> | <kbd>Ctrl</kbd> + <kbd>←</kbd> | 返回上一个页面 |
|
|
104
|
+
| <kbd>⌘</kbd> + <kbd>]</kbd> | <kbd>Ctrl</kbd> + <kbd>→</kbd> | 去下一个页面 |
|
|
105
|
+
| <kbd>⌘</kbd> + <kbd>↑</kbd> | <kbd>Ctrl</kbd> + <kbd>↑</kbd> | 自动滚动到页面顶部 |
|
|
106
|
+
| <kbd>⌘</kbd> + <kbd>↓</kbd> | <kbd>Ctrl</kbd> + <kbd>↓</kbd> | 自动滚动到页面底部 |
|
|
107
|
+
| <kbd>⌘</kbd> + <kbd>r</kbd> | <kbd>Ctrl</kbd> + <kbd>r</kbd> | 刷新页面 |
|
|
108
|
+
| <kbd>⌘</kbd> + <kbd>w</kbd> | <kbd>Ctrl</kbd> + <kbd>w</kbd> | 隐藏窗口,非退出 |
|
|
109
|
+
| <kbd>⌘</kbd> + <kbd>-</kbd> | <kbd>Ctrl</kbd> + <kbd>-</kbd> | 缩小页面 |
|
|
110
|
+
| <kbd>⌘</kbd> + <kbd>+</kbd> | <kbd>Ctrl</kbd> + <kbd>+</kbd> | 放大页面 |
|
|
111
|
+
| <kbd>⌘</kbd> + <kbd>=</kbd> | <kbd>Ctrl</kbd> + <kbd>=</kbd> | 放大页面 |
|
|
112
|
+
| <kbd>⌘</kbd> + <kbd>0</kbd> | <kbd>Ctrl</kbd> + <kbd>0</kbd> | 重置页面缩放 |
|
|
113
|
+
|
|
114
|
+
此外还支持双击头部进行全屏切换,拖拽头部进行移动窗口,Mac 用户支持手势方式返回和去下一页,还有其他需求,欢迎提过来。
|
|
115
|
+
|
|
116
|
+
</details>
|
|
117
|
+
|
|
118
|
+
## 开始之前
|
|
97
119
|
|
|
98
|
-
|
|
120
|
+
1. **小白用户**:使用 「常用包下载」 方式来把玩 Pake 的能力,可去 [讨论群](https://github.com/tw93/Pake/discussions) 寻求帮助,也可试试 [Action](https://github.com/tw93/Pake/wiki/GitHub-Actions-%E5%9C%A8%E7%BA%BF%E7%BC%96%E8%AF%91%E5%A4%9A%E7%B3%BB%E7%BB%9F%E7%89%88%E6%9C%AC)方式。
|
|
121
|
+
2. **开发用户**:使用 「命令行一键打包」,对 Mac 友好,Windows / Linux 需折腾下,均需 [环境配置](https://tauri.app/v1/guides/getting-started/prerequisites)。
|
|
122
|
+
3. **折腾用户**:假如你前端和 Rust 都会,那可试试下面的 「[定制开发](#定制开发)」,可深度二次开发定制你的功能。
|
|
99
123
|
|
|
100
|
-
##
|
|
124
|
+
## 命令行一键打包
|
|
101
125
|
|
|
102
126
|
<kbd>
|
|
103
|
-
<img src="https://
|
|
127
|
+
<img src="https://gw.alipayobjects.com/zos/k/zd/pake.gif" width="100%">
|
|
104
128
|
</kbd>
|
|
105
129
|
<br/><br/>
|
|
106
130
|
|
|
@@ -117,26 +141,11 @@ pake url [options]
|
|
|
117
141
|
pake https://weekly.tw93.fun --name Weekly --transparent
|
|
118
142
|
```
|
|
119
143
|
|
|
120
|
-
|
|
144
|
+
假如你不太会使用命令行,或许使用 **GitHub Actions 在线编译多系统版本** 是一个不错的选择,可查看[文档](https://github.com/tw93/Pake/wiki/GitHub-Actions-%E5%9C%A8%E7%BA%BF%E7%BC%96%E8%AF%91%E5%A4%9A%E7%B3%BB%E7%BB%9F%E7%89%88%E6%9C%AC)。
|
|
121
145
|
|
|
122
|
-
|
|
123
|
-
| --------------------------- | ------------------------------ | ------------------ |
|
|
124
|
-
| <kbd>⌘</kbd> + <kbd>[</kbd> | <kbd>Ctrl</kbd> + <kbd>←</kbd> | 返回上一个页面 |
|
|
125
|
-
| <kbd>⌘</kbd> + <kbd>]</kbd> | <kbd>Ctrl</kbd> + <kbd>→</kbd> | 去下一个页面 |
|
|
126
|
-
| <kbd>⌘</kbd> + <kbd>↑</kbd> | <kbd>Ctrl</kbd> + <kbd>↑</kbd> | 自动滚动到页面顶部 |
|
|
127
|
-
| <kbd>⌘</kbd> + <kbd>↓</kbd> | <kbd>Ctrl</kbd> + <kbd>↓</kbd> | 自动滚动到页面底部 |
|
|
128
|
-
| <kbd>⌘</kbd> + <kbd>r</kbd> | <kbd>Ctrl</kbd> + <kbd>r</kbd> | 刷新页面 |
|
|
129
|
-
| <kbd>⌘</kbd> + <kbd>w</kbd> | <kbd>Ctrl</kbd> + <kbd>w</kbd> | 隐藏窗口,非退出 |
|
|
130
|
-
| <kbd>⌘</kbd> + <kbd>-</kbd> | <kbd>Ctrl</kbd> + <kbd>-</kbd> | 缩小页面 |
|
|
131
|
-
| <kbd>⌘</kbd> + <kbd>+</kbd> | <kbd>Ctrl</kbd> + <kbd>+</kbd> | 放大页面 |
|
|
132
|
-
| <kbd>⌘</kbd> + <kbd>=</kbd> | <kbd>Ctrl</kbd> + <kbd>=</kbd> | 放大页面 |
|
|
133
|
-
| <kbd>⌘</kbd> + <kbd>0</kbd> | <kbd>Ctrl</kbd> + <kbd>0</kbd> | 重置页面缩放 |
|
|
146
|
+
## 定制开发
|
|
134
147
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
## 开发
|
|
138
|
-
|
|
139
|
-
开始前参考 [Tauri](https://tauri.app/v1/guides/getting-started/prerequisites) 快速配置好环境。
|
|
148
|
+
开始前请确保电脑已经安装了 Rust 和 Node 的环境,此外需参考 [Tauri 文档](https://tauri.app/v1/guides/getting-started/prerequisites) 快速配置好环境才可以开始使用,假如你太不懂,使用上面的命令行打包会更加合适。
|
|
140
149
|
|
|
141
150
|
```sh
|
|
142
151
|
// 安装依赖
|
|
@@ -146,30 +155,16 @@ npm i
|
|
|
146
155
|
npm run dev
|
|
147
156
|
|
|
148
157
|
// 打包应用
|
|
149
|
-
npm run build
|
|
158
|
+
npm run build
|
|
150
159
|
|
|
151
160
|
```
|
|
152
161
|
|
|
153
|
-
##
|
|
154
|
-
|
|
155
|
-
1. 修改 `src-tauri` 目录下的 `tauri.conf.json` 中的 `url、productName、icon、identifier` 这 4 个字段,其中 icon 可以从 icons 目录选择一个,也可以去 [macOSicons](https://macosicons.com/#/) 下载符合产品名称的
|
|
156
|
-
2. 关于窗口属性设置,可以在 `tauri.conf.json` 修改 `windows` 属性对应的 `width/height`,是否全屏 `fullscreen`,是否可以调整大小 `resizable`,假如想适配 Mac 沉浸式头部,可以将 `transparent` 设置成 `true`,找到 Header 元素加一个 `padding-top` 样式即可,不想适配改成 `false` 也行
|
|
157
|
-
3. `npm run dev` 本地调试看看效果,此外可以使用 `npm run dev:debug` 进行容器调试
|
|
158
|
-
4. `npm run build` 运行即可打生产包
|
|
159
|
-
|
|
160
|
-
## 高级用法
|
|
161
|
-
|
|
162
|
-
#### 1. 如何改写样式,如去掉原站广告、不想要的模块、甚至重新设计?
|
|
162
|
+
## 高级使用
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
参考 `pake.js` 中事件监听 `document.addEventListener`,直接编写即可,这里更多是基础前端的技术。
|
|
169
|
-
|
|
170
|
-
#### 3. 如何进行容器内的事件和 Pake 通信,比如说 Web 的拖拽、滚动、特殊点击传递啥的?
|
|
171
|
-
|
|
172
|
-
参考 `pake.js` 中通信代码 `postMessage`,写好事件监听,然后用 `window.ipc.postMessage` 将事件以及参数传递出来,然后参考容器接收事件 `window.drag_window`,自己处理即可,更多可以参考 tauri 以及 wry 的官方文档。
|
|
164
|
+
1. 修改 `src-tauri` 目录下的 `tauri.conf.json` 中的 `url、productName、icon、identifier` 这 4 个字段,其中 icon 可以从 icons 目录选择一个,也可以去 [macOSicons](https://macosicons.com/#/) 下载符合产品名称的。
|
|
165
|
+
2. 关于窗口属性设置,可以在 `tauri.conf.json` 修改 `windows` 属性对应的 `width/height`,是否全屏 `fullscreen`,是否可以调整大小 `resizable`,假如想适配 Mac 沉浸式头部,可以将 `transparent` 设置成 `true`,找到 Header 元素加一个 `padding-top` 样式即可,不想适配改成 `false` 也行。
|
|
166
|
+
3. `npm run dev` 本地调试看看效果,此外可以使用 `npm run dev:debug` 进行容器调试,`npm run build` 运行即可打生产包。
|
|
167
|
+
4. 代码结构可参考 [文档](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),关于样式改写、屏蔽广告、逻辑代码注入、容器消息通信、自定义快捷键可见 [高级用法](https://github.com/tw93/Pake/wiki/Pake-%E7%9A%84%E9%AB%98%E7%BA%A7%E7%94%A8%E6%B3%95)。
|
|
173
168
|
|
|
174
169
|
## 开发者
|
|
175
170
|
|
|
@@ -249,6 +244,20 @@ Pake 的发展离不开这些 Hacker 们,一起贡献了大量能力,也欢
|
|
|
249
244
|
<sub><b>Aiello</b></sub>
|
|
250
245
|
</a>
|
|
251
246
|
</td>
|
|
247
|
+
<td align="center">
|
|
248
|
+
<a href="https://github.com/nekomeowww">
|
|
249
|
+
<img src="https://avatars.githubusercontent.com/u/11081491?v=4" width="90;" alt="nekomeowww"/>
|
|
250
|
+
<br />
|
|
251
|
+
<sub><b>Ayaka Neko</b></sub>
|
|
252
|
+
</a>
|
|
253
|
+
</td>
|
|
254
|
+
<td align="center">
|
|
255
|
+
<a href="https://github.com/princemaple">
|
|
256
|
+
<img src="https://avatars.githubusercontent.com/u/1329716?v=4" width="90;" alt="princemaple"/>
|
|
257
|
+
<br />
|
|
258
|
+
<sub><b>Po Chen</b></sub>
|
|
259
|
+
</a>
|
|
260
|
+
</td>
|
|
252
261
|
<td align="center">
|
|
253
262
|
<a href="https://github.com/houhoz">
|
|
254
263
|
<img src="https://avatars.githubusercontent.com/u/19684376?v=4" width="90;" alt="houhoz"/>
|
|
@@ -262,7 +271,8 @@ Pake 的发展离不开这些 Hacker 们,一起贡献了大量能力,也欢
|
|
|
262
271
|
<br />
|
|
263
272
|
<sub><b>Liusishan</b></sub>
|
|
264
273
|
</a>
|
|
265
|
-
</td>
|
|
274
|
+
</td></tr>
|
|
275
|
+
<tr>
|
|
266
276
|
<td align="center">
|
|
267
277
|
<a href="https://github.com/piaoyidage">
|
|
268
278
|
<img src="https://avatars.githubusercontent.com/u/5135405?v=4" width="90;" alt="piaoyidage"/>
|
|
@@ -275,11 +285,11 @@ Pake 的发展离不开这些 Hacker 们,一起贡献了大量能力,也欢
|
|
|
275
285
|
|
|
276
286
|
## 支持
|
|
277
287
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
288
|
+
1. 我有两只猫,一只叫汤圆,一只叫可乐,假如觉得 Pake 让你生活更美好,可以给汤圆可乐 <a href="https://miaoyan.app/cats.html?name=Pake" target="_blank">喂罐头 🥩🍤</a>。
|
|
289
|
+
2. 如果你喜欢 Pake,可以在 Github Star,更欢迎 [推荐](https://twitter.com/intent/tweet?url=https://github.com/tw93/Pake&text=Pake%20%E4%B8%80%E4%B8%AA%E5%BE%88%E7%AE%80%E5%8D%95%E7%9A%84%E7%94%A8%20Rust%20%E6%89%93%E5%8C%85%E7%BD%91%E9%A1%B5%E7%94%9F%E6%88%90%20Mac%20App%20%E7%9A%84%E5%B7%A5%E5%85%B7%EF%BC%8C%E7%9B%B8%E6%AF%94%E4%BC%A0%E7%BB%9F%E7%9A%84%20Electron%20%E5%A5%97%E5%A3%B3%E6%89%93%E5%8C%85%EF%BC%8C%E5%A4%A7%E5%B0%8F%E8%A6%81%E5%B0%8F%E5%B0%86%E8%BF%91%2040%20%E5%80%8D%EF%BC%8C%E4%B8%80%E8%88%AC%202M%20%E5%B7%A6%E5%8F%B3%EF%BC%8C%E5%BA%95%E5%B1%82%E4%BD%BF%E7%94%A8Tauri%20%EF%BC%8C%E6%80%A7%E8%83%BD%E4%BD%93%E9%AA%8C%E8%BE%83%20JS%20%E6%A1%86%E6%9E%B6%E8%A6%81%E8%BD%BB%E5%BF%AB%E4%B8%8D%E5%B0%91%EF%BC%8C%E5%86%85%E5%AD%98%E5%B0%8F%E5%BE%88%E5%A4%9A%EF%BC%8C%E6%94%AF%E6%8C%81%E5%BE%AE%E4%BF%A1%E8%AF%BB%E4%B9%A6%E3%80%81Twitter%E3%80%81Youtube%E3%80%81RunCode%E3%80%81Flomo%E3%80%81%E8%AF%AD%E9%9B%80%E7%AD%89%EF%BC%8C%E5%8F%AF%E4%BB%A5%E5%BE%88%E6%96%B9%E4%BE%BF%E4%BA%8C%E6%AC%A1%E5%BC%80%E5%8F%91~) 给你志同道合的朋友使用。
|
|
290
|
+
3. 可以关注我的 [Twitter](https://twitter.com/HiTw93) 获取到最新的 Pake 更新消息,也欢迎加入 [Telegram](https://t.me/miaoyan) 聊天群。
|
|
281
291
|
|
|
282
292
|
## 最后
|
|
283
293
|
|
|
284
|
-
1.
|
|
285
|
-
2. 假如你发现有很适合做成桌面 App
|
|
294
|
+
1. 希望大伙玩的过程中有一种学习新技术的喜悦感,如果有新点子欢迎告诉我。
|
|
295
|
+
2. 假如你发现有很适合做成桌面 App 的网页也很欢迎告诉我,我给加到里面来。
|
package/dist/cli.js
CHANGED
|
@@ -6,11 +6,11 @@ import isurl from 'is-url';
|
|
|
6
6
|
import prompts from 'prompts';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import fs from 'fs/promises';
|
|
9
|
+
import chalk from 'chalk';
|
|
9
10
|
import crypto from 'crypto';
|
|
10
11
|
import axios from 'axios';
|
|
11
12
|
import { fileTypeFromBuffer } from 'file-type';
|
|
12
13
|
import { dir } from 'tmp-promise';
|
|
13
|
-
import chalk from 'chalk';
|
|
14
14
|
import ora from 'ora';
|
|
15
15
|
import shelljs from 'shelljs';
|
|
16
16
|
import updateNotifier from 'update-notifier';
|
|
@@ -1593,6 +1593,24 @@ function validateUrlInput(url) {
|
|
|
1593
1593
|
|
|
1594
1594
|
const npmDirectory = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
1595
1595
|
|
|
1596
|
+
const logger = {
|
|
1597
|
+
info(...msg) {
|
|
1598
|
+
log.info(...msg.map((m) => chalk.blue.bold(m)));
|
|
1599
|
+
},
|
|
1600
|
+
debug(...msg) {
|
|
1601
|
+
log.debug(...msg);
|
|
1602
|
+
},
|
|
1603
|
+
error(...msg) {
|
|
1604
|
+
log.error(...msg.map((m) => chalk.red.bold(m)));
|
|
1605
|
+
},
|
|
1606
|
+
warn(...msg) {
|
|
1607
|
+
log.info(...msg.map((m) => chalk.yellow.bold(m)));
|
|
1608
|
+
},
|
|
1609
|
+
success(...msg) {
|
|
1610
|
+
log.info(...msg.map((m) => chalk.green.bold(m)));
|
|
1611
|
+
}
|
|
1612
|
+
};
|
|
1613
|
+
|
|
1596
1614
|
function promptText(message, initial) {
|
|
1597
1615
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1598
1616
|
const response = yield prompts({
|
|
@@ -1617,19 +1635,43 @@ function mergeTauriConfig(url, options, tauriConf) {
|
|
|
1617
1635
|
Object.assign(tauriConf.tauri.windows[0], Object.assign({ url }, tauriConfWindowOptions));
|
|
1618
1636
|
tauriConf.package.productName = name;
|
|
1619
1637
|
tauriConf.tauri.bundle.identifier = identifier;
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1638
|
+
const exists = yield fs.stat(options.icon)
|
|
1639
|
+
.then(() => true)
|
|
1640
|
+
.catch(() => false);
|
|
1641
|
+
if (exists) {
|
|
1642
|
+
let updateIconPath = true;
|
|
1643
|
+
let customIconExt = path.extname(options.icon).toLowerCase();
|
|
1644
|
+
if (process.platform === "win32") {
|
|
1645
|
+
if (customIconExt === ".ico") {
|
|
1646
|
+
const ico_path = path.join(npmDirectory, `src-tauri/png/${name.toLowerCase()}_32.ico`);
|
|
1647
|
+
tauriConf.tauri.bundle.resources = [`png/${name.toLowerCase()}_32.ico`];
|
|
1648
|
+
yield fs.copyFile(options.icon, ico_path);
|
|
1649
|
+
}
|
|
1650
|
+
else {
|
|
1651
|
+
updateIconPath = false;
|
|
1652
|
+
logger.warn(`icon file in Windows must be 256 * 256 pix with .ico type, but you give ${customIconExt}`);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
if (process.platform === "linux") {
|
|
1656
|
+
delete tauriConf.tauri.bundle.deb.files;
|
|
1657
|
+
if (customIconExt != ".png") {
|
|
1658
|
+
updateIconPath = false;
|
|
1659
|
+
logger.warn(`icon file in Linux must be 512 * 512 pix with .png type, but you give ${customIconExt}`);
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
if (process.platform === "darwin" && customIconExt !== ".icns") {
|
|
1663
|
+
updateIconPath = false;
|
|
1664
|
+
logger.warn(`icon file in MacOS must be .icns type, but you give ${customIconExt}`);
|
|
1665
|
+
}
|
|
1666
|
+
if (updateIconPath) {
|
|
1667
|
+
tauriConf.tauri.bundle.icon = [options.icon];
|
|
1668
|
+
}
|
|
1669
|
+
else {
|
|
1670
|
+
logger.warn(`icon file will not change with default.`);
|
|
1671
|
+
}
|
|
1625
1672
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
const assertSrc = `src-tauri/assets/${name}.desktop`;
|
|
1629
|
-
const assertPath = path.join(npmDirectory, assertSrc);
|
|
1630
|
-
tauriConf.tauri.bundle.deb.files = {
|
|
1631
|
-
[installSrc]: assertPath
|
|
1632
|
-
};
|
|
1673
|
+
else {
|
|
1674
|
+
logger.warn("the custom icon path may not exists. we will use default icon to replace it");
|
|
1633
1675
|
}
|
|
1634
1676
|
let configPath = "";
|
|
1635
1677
|
switch (process.platform) {
|
|
@@ -1660,23 +1702,9 @@ function getIdentifier(name, url) {
|
|
|
1660
1702
|
return `pake-${postFixHash}`;
|
|
1661
1703
|
}
|
|
1662
1704
|
|
|
1663
|
-
const
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
},
|
|
1667
|
-
debug(...msg) {
|
|
1668
|
-
log.debug(...msg);
|
|
1669
|
-
},
|
|
1670
|
-
error(...msg) {
|
|
1671
|
-
log.error(...msg.map((m) => chalk.red.bold(m)));
|
|
1672
|
-
},
|
|
1673
|
-
warn(...msg) {
|
|
1674
|
-
log.info(...msg.map((m) => chalk.yellow.bold(m)));
|
|
1675
|
-
},
|
|
1676
|
-
success(...msg) {
|
|
1677
|
-
log.info(...msg.map((m) => chalk.green.bold(m)));
|
|
1678
|
-
}
|
|
1679
|
-
};
|
|
1705
|
+
const IS_MAC = process.platform === 'darwin';
|
|
1706
|
+
const IS_WIN = process.platform === 'win32';
|
|
1707
|
+
const IS_LINUX = process.platform === 'linux';
|
|
1680
1708
|
|
|
1681
1709
|
function handleIcon(options, url) {
|
|
1682
1710
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1689,15 +1717,21 @@ function handleIcon(options, url) {
|
|
|
1689
1717
|
}
|
|
1690
1718
|
}
|
|
1691
1719
|
if (!options.icon) {
|
|
1692
|
-
return
|
|
1720
|
+
return getDefaultIcon();
|
|
1693
1721
|
}
|
|
1694
1722
|
});
|
|
1695
1723
|
}
|
|
1696
|
-
function
|
|
1724
|
+
function getDefaultIcon() {
|
|
1697
1725
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1698
1726
|
logger.info('You have not provided an app icon, use the default icon.(use --icon option to assign an icon)');
|
|
1699
|
-
|
|
1700
|
-
|
|
1727
|
+
let iconPath = 'src-tauri/icons/icon.icns';
|
|
1728
|
+
if (IS_WIN) {
|
|
1729
|
+
iconPath = 'src-tauri/png/icon_256.ico';
|
|
1730
|
+
}
|
|
1731
|
+
else if (IS_LINUX) {
|
|
1732
|
+
iconPath = 'src-tauri/png/icon_512.png';
|
|
1733
|
+
}
|
|
1734
|
+
return path.join(npmDirectory, iconPath);
|
|
1701
1735
|
});
|
|
1702
1736
|
}
|
|
1703
1737
|
// export async function getIconFromPageUrl(url: string) {
|
|
@@ -1773,10 +1807,6 @@ function handleOptions(options, url) {
|
|
|
1773
1807
|
});
|
|
1774
1808
|
}
|
|
1775
1809
|
|
|
1776
|
-
const IS_MAC = process.platform === 'darwin';
|
|
1777
|
-
const IS_WIN = process.platform === 'win32';
|
|
1778
|
-
const IS_LINUX = process.platform === 'linux';
|
|
1779
|
-
|
|
1780
1810
|
function shellExec(command) {
|
|
1781
1811
|
return new Promise((resolve, reject) => {
|
|
1782
1812
|
shelljs.exec(command, { async: true, silent: false }, (code) => {
|
|
@@ -1870,7 +1900,8 @@ var tauri$2 = {
|
|
|
1870
1900
|
wix: {
|
|
1871
1901
|
language: [
|
|
1872
1902
|
"en-US"
|
|
1873
|
-
]
|
|
1903
|
+
],
|
|
1904
|
+
template: "assets/main.wxs"
|
|
1874
1905
|
}
|
|
1875
1906
|
}
|
|
1876
1907
|
}
|
|
@@ -1943,7 +1974,8 @@ var tauri = {
|
|
|
1943
1974
|
],
|
|
1944
1975
|
shortDescription: "",
|
|
1945
1976
|
targets: [
|
|
1946
|
-
"deb"
|
|
1977
|
+
"deb",
|
|
1978
|
+
"appimage"
|
|
1947
1979
|
]
|
|
1948
1980
|
}
|
|
1949
1981
|
};
|
|
@@ -1996,7 +2028,7 @@ class MacBuilder {
|
|
|
1996
2028
|
log.debug('PakeAppOptions', options);
|
|
1997
2029
|
const { name } = options;
|
|
1998
2030
|
yield mergeTauriConfig(url, options, tauriConf);
|
|
1999
|
-
yield shellExec(`cd ${npmDirectory} && npm install && npm run build
|
|
2031
|
+
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
|
|
2000
2032
|
let arch = "x64";
|
|
2001
2033
|
if (process.arch === "arm64") {
|
|
2002
2034
|
arch = "aarch64";
|
|
@@ -2046,7 +2078,7 @@ class WinBuilder {
|
|
|
2046
2078
|
logger.debug('PakeAppOptions', options);
|
|
2047
2079
|
const { name } = options;
|
|
2048
2080
|
yield mergeTauriConfig(url, options, tauriConf);
|
|
2049
|
-
yield shellExec(`cd ${npmDirectory} && npm install && npm run build
|
|
2081
|
+
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
|
|
2050
2082
|
const language = tauriConf.tauri.bundle.windows.wix.language[0];
|
|
2051
2083
|
const arch = process.arch;
|
|
2052
2084
|
const msiName = `${name}_${tauriConf.package.version}_${arch}_${language}.msi`;
|
|
@@ -2091,22 +2123,7 @@ class LinuxBuilder {
|
|
|
2091
2123
|
logger.debug('PakeAppOptions', options);
|
|
2092
2124
|
const { name } = options;
|
|
2093
2125
|
yield mergeTauriConfig(url, options, tauriConf);
|
|
2094
|
-
|
|
2095
|
-
const assertSrc = `src-tauri/assets/${name}.desktop`;
|
|
2096
|
-
const assertPath = path.join(npmDirectory, assertSrc);
|
|
2097
|
-
const desktopStr = `
|
|
2098
|
-
[Desktop Entry]
|
|
2099
|
-
Encoding=UTF-8
|
|
2100
|
-
Categories=Office
|
|
2101
|
-
Exec=${name}
|
|
2102
|
-
Icon=${name}
|
|
2103
|
-
Name=${name}
|
|
2104
|
-
StartupNotify=true
|
|
2105
|
-
Terminal=false
|
|
2106
|
-
Type=Application
|
|
2107
|
-
`;
|
|
2108
|
-
yield fs.writeFile(assertPath, desktopStr);
|
|
2109
|
-
yield shellExec(`cd ${npmDirectory} && npm install && npm run build:release`);
|
|
2126
|
+
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
|
|
2110
2127
|
let arch = "";
|
|
2111
2128
|
if (process.arch === "x64") {
|
|
2112
2129
|
arch = "amd64";
|
|
@@ -2115,22 +2132,27 @@ Type=Application
|
|
|
2115
2132
|
arch = process.arch;
|
|
2116
2133
|
}
|
|
2117
2134
|
const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
|
|
2118
|
-
const appPath = this.getBuildedAppPath(npmDirectory, debName);
|
|
2135
|
+
const appPath = this.getBuildedAppPath(npmDirectory, "deb", debName);
|
|
2119
2136
|
const distPath = path.resolve(`${name}.deb`);
|
|
2120
2137
|
yield fs.copyFile(appPath, distPath);
|
|
2121
2138
|
yield fs.unlink(appPath);
|
|
2139
|
+
const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`;
|
|
2140
|
+
const appImagePath = this.getBuildedAppPath(npmDirectory, "appimage", appImageName);
|
|
2141
|
+
const distAppPath = path.resolve(`${name}.AppImage`);
|
|
2142
|
+
yield fs.copyFile(appImagePath, distAppPath);
|
|
2143
|
+
yield fs.unlink(appImagePath);
|
|
2122
2144
|
logger.success('Build success!');
|
|
2123
|
-
logger.success('You can find the app installer in', distPath);
|
|
2145
|
+
logger.success('You can find the deb app installer in', distPath);
|
|
2146
|
+
logger.success('You can find the Appimage app installer in', distAppPath);
|
|
2124
2147
|
});
|
|
2125
2148
|
}
|
|
2126
|
-
getBuildedAppPath(npmDirectory,
|
|
2127
|
-
return path.join(npmDirectory, 'src-tauri/target/release/bundle/
|
|
2149
|
+
getBuildedAppPath(npmDirectory, packageType, packageName) {
|
|
2150
|
+
return path.join(npmDirectory, 'src-tauri/target/release/bundle/', packageType, packageName);
|
|
2128
2151
|
}
|
|
2129
2152
|
}
|
|
2130
2153
|
|
|
2131
2154
|
class BuilderFactory {
|
|
2132
2155
|
static create() {
|
|
2133
|
-
console.log("now platform is ", process.platform);
|
|
2134
2156
|
if (IS_MAC) {
|
|
2135
2157
|
return new MacBuilder();
|
|
2136
2158
|
}
|
|
@@ -2145,7 +2167,7 @@ class BuilderFactory {
|
|
|
2145
2167
|
}
|
|
2146
2168
|
|
|
2147
2169
|
var name = "pake-cli";
|
|
2148
|
-
var version = "0.1.
|
|
2170
|
+
var version = "0.1.2";
|
|
2149
2171
|
var description = "🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App 🤱🏻 A simple way to make any web page a desktop application using Rust.";
|
|
2150
2172
|
var bin = {
|
|
2151
2173
|
pake: "./cli.js"
|
|
@@ -2161,14 +2183,13 @@ var author = {
|
|
|
2161
2183
|
var files = [
|
|
2162
2184
|
"dist",
|
|
2163
2185
|
"src-tauri",
|
|
2164
|
-
"cli.js"
|
|
2165
|
-
"pake-default.icns"
|
|
2186
|
+
"cli.js"
|
|
2166
2187
|
];
|
|
2167
2188
|
var scripts = {
|
|
2168
2189
|
start: "npm run dev",
|
|
2169
2190
|
dev: "npm run tauri dev",
|
|
2170
2191
|
"dev:debug": "npm run tauri dev -- --features devtools",
|
|
2171
|
-
|
|
2192
|
+
build: "npm run tauri build --release",
|
|
2172
2193
|
"build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
|
|
2173
2194
|
"build:all-windows": ".\\script\\build.bat",
|
|
2174
2195
|
tauri: "tauri",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pake-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App 🤱🏻 A simple way to make any web page a desktop application using Rust.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"pake": "./cli.js"
|
|
@@ -13,17 +13,24 @@
|
|
|
13
13
|
"name": "Tw93",
|
|
14
14
|
"email": "tw93@qq.com"
|
|
15
15
|
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"pake",
|
|
18
|
+
"pake-cli",
|
|
19
|
+
"rust",
|
|
20
|
+
"tauri",
|
|
21
|
+
"no-electron",
|
|
22
|
+
"productivity"
|
|
23
|
+
],
|
|
16
24
|
"files": [
|
|
17
25
|
"dist",
|
|
18
26
|
"src-tauri",
|
|
19
|
-
"cli.js"
|
|
20
|
-
"pake-default.icns"
|
|
27
|
+
"cli.js"
|
|
21
28
|
],
|
|
22
29
|
"scripts": {
|
|
23
30
|
"start": "npm run dev",
|
|
24
31
|
"dev": "npm run tauri dev",
|
|
25
32
|
"dev:debug": "npm run tauri dev -- --features devtools",
|
|
26
|
-
"build
|
|
33
|
+
"build": "npm run tauri build --release",
|
|
27
34
|
"build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
|
|
28
35
|
"build:all-windows": ".\\script\\build.bat",
|
|
29
36
|
"tauri": "tauri",
|
|
@@ -36,7 +43,7 @@
|
|
|
36
43
|
"license": "MIT",
|
|
37
44
|
"dependencies": {
|
|
38
45
|
"@tauri-apps/api": "^1.2.0",
|
|
39
|
-
"@tauri-apps/cli": "^1.2.
|
|
46
|
+
"@tauri-apps/cli": "^1.2.2",
|
|
40
47
|
"axios": "^1.1.3",
|
|
41
48
|
"chalk": "^5.1.2",
|
|
42
49
|
"commander": "^9.4.1",
|