pake-cli 0.1.2 → 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 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="#命令行打包">命令行一键打包</a>、<a href="#开发">定制开发</a> 可见下面文档,也欢迎去 <a href=https://github.com/tw93/Pake/discussions>讨论区</a> 交流。</div>
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,15 +44,15 @@
44
44
  <td><img src=https://cdn.fliggy.com/upic/mc41xq.jpg width=600/></td>
45
45
  </tr>
46
46
  <tr>
47
- <td>ChatGPT
47
+ <td>ChatGPT(代理被封已换官方)
48
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_amd64.deb">Linux</a>
50
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
52
  <td>Qwerty
53
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_amd64.deb">Linux</a>
55
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>
@@ -62,13 +62,13 @@
62
62
  <tr>
63
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
68
  <td>Reference
69
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_amd64.deb">Linux</a>
71
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>
@@ -78,13 +78,13 @@
78
78
  <tr>
79
79
  <td>YouTube
80
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_amd64.deb">Linux</a>
82
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
83
  </td>
84
84
  <td>Flomo
85
85
  <a href="https://github.com/tw93/Pake/releases/latest/download/Flomo.dmg">Mac</a>
86
- <a href="https://github.com/tw93/Pake/releases/latest/download/Flomo_amd64.deb">Linux</a>
87
86
  <a href="https://github.com/tw93/Pake/releases/latest/download/Flomo_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>
@@ -93,12 +93,38 @@
93
93
  </tr>
94
94
  </table>
95
95
 
96
- 注意:Windows 下不能安装到 `C:\Program File`,会直接闪退,建议安装到其他非管理员权限目录,比如 `D:\Program Files (x86)` 。
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>
97
117
 
98
- ## 命令行打包
118
+ ## 开始之前
119
+
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 都会,那可试试下面的 「[定制开发](#定制开发)」,可深度二次开发定制你的功能。
123
+
124
+ ## 命令行一键打包
99
125
 
100
126
  <kbd>
101
- <img src="https://cdn.fliggy.com/upic/cOC1lF.gif" width="100%">
127
+ <img src="https://gw.alipayobjects.com/zos/k/zd/pake.gif" width="100%">
102
128
  </kbd>
103
129
  <br/><br/>
104
130
 
@@ -115,28 +141,11 @@ pake url [options]
115
141
  pake https://weekly.tw93.fun --name Weekly --transparent
116
142
  ```
117
143
 
118
- 假如你是不太会使用命令行的小白,使用 **GitHub Actions 在线编译多系统版本** 也是一个不错的选择,可查看[文档](./.github/workflows/docs/README.md)。
119
-
120
- ## 快捷键
121
-
122
- | Mac | Windows/Linux | 功能 |
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> | 重置页面缩放 |
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)。
134
145
 
135
- 此外还支持双击头部进行全屏切换,拖拽头部进行移动窗口,还有其他需求,欢迎提过来。
146
+ ## 定制开发
136
147
 
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
  // 安装依赖
@@ -150,26 +159,12 @@ 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. 如何改写样式,如去掉原站广告、不想要的模块、甚至重新设计?
163
-
164
- 首先需要使用 `npm run dev:debug` 打开 devtools 调试模式,找到你需要修改的样式名称,先在 devtools 里面验证效果;找到 `pake.js` 中样式位置 `style.innerHTML` ,将需要覆盖的样式加上即可,有一些案例你可以模仿。
165
-
166
- #### 2. 如何注入 JS 的逻辑,比如实现事件监听,比如说键盘快捷键?
167
-
168
- 参考 `pake.js` 中事件监听 `document.addEventListener`,直接编写即可,这里更多是基础前端的技术。
169
-
170
- #### 3. 如何进行容器内的事件和 Pake 通信,比如说 Web 的拖拽、滚动、特殊点击传递啥的?
162
+ ## 高级使用
171
163
 
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
 
@@ -256,6 +251,13 @@ Pake 的发展离不开这些 Hacker 们,一起贡献了大量能力,也欢
256
251
  <sub><b>Ayaka Neko</b></sub>
257
252
  </a>
258
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>
259
261
  <td align="center">
260
262
  <a href="https://github.com/houhoz">
261
263
  <img src="https://avatars.githubusercontent.com/u/19684376?v=4" width="90;" alt="houhoz"/>
@@ -269,7 +271,8 @@ Pake 的发展离不开这些 Hacker 们,一起贡献了大量能力,也欢
269
271
  <br />
270
272
  <sub><b>Liusishan</b></sub>
271
273
  </a>
272
- </td>
274
+ </td></tr>
275
+ <tr>
273
276
  <td align="center">
274
277
  <a href="https://github.com/piaoyidage">
275
278
  <img src="https://avatars.githubusercontent.com/u/5135405?v=4" width="90;" alt="piaoyidage"/>
@@ -282,11 +285,11 @@ Pake 的发展离不开这些 Hacker 们,一起贡献了大量能力,也欢
282
285
 
283
286
  ## 支持
284
287
 
285
- - 我有两只猫,一只叫汤圆,一只叫可乐,假如觉得 Pake 让你生活更美好,可以给汤圆可乐 <a href="https://miaoyan.app/cats.html?name=Pake" target="_blank">喂罐头 🥩🍤</a>。
286
- - 如果你喜欢 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~) 给你志同道合的朋友使用。
287
- - 可以关注我的 [Twitter](https://twitter.com/HiTw93) 获取到最新的 Pake 更新消息,也欢迎加入 [Telegram](https://t.me/miaoyan) 聊天群。
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) 聊天群。
288
291
 
289
292
  ## 最后
290
293
 
291
- 1. 希望大伙玩的过程中有一种学习新技术的喜悦感,如果有新点子欢迎告诉我
292
- 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
- tauriConf.tauri.bundle.icon = [options.icon];
1621
- if (process.platform === "win32") {
1622
- const ico_path = path.join(npmDirectory, `src-tauri/png/${name.toLowerCase()}_32.ico`);
1623
- tauriConf.tauri.bundle.resources = [`png/${name.toLowerCase()}_32.ico`];
1624
- yield fs.copyFile(options.icon, ico_path);
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
- if (process.platform === "linux") {
1627
- const installSrc = `/usr/share/applications/${name}.desktop`;
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,24 +1702,6 @@ function getIdentifier(name, url) {
1660
1702
  return `pake-${postFixHash}`;
1661
1703
  }
1662
1704
 
1663
- const logger = {
1664
- info(...msg) {
1665
- log.info(...msg.map((m) => chalk.blue.bold(m)));
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
- };
1680
-
1681
1705
  const IS_MAC = process.platform === 'darwin';
1682
1706
  const IS_WIN = process.platform === 'win32';
1683
1707
  const IS_LINUX = process.platform === 'linux';
@@ -1876,7 +1900,8 @@ var tauri$2 = {
1876
1900
  wix: {
1877
1901
  language: [
1878
1902
  "en-US"
1879
- ]
1903
+ ],
1904
+ template: "assets/main.wxs"
1880
1905
  }
1881
1906
  }
1882
1907
  }
@@ -2098,21 +2123,6 @@ class LinuxBuilder {
2098
2123
  logger.debug('PakeAppOptions', options);
2099
2124
  const { name } = options;
2100
2125
  yield mergeTauriConfig(url, options, tauriConf);
2101
- // write desktop
2102
- const assertSrc = `src-tauri/assets/${name}.desktop`;
2103
- const assertPath = path.join(npmDirectory, assertSrc);
2104
- const desktopStr = `
2105
- [Desktop Entry]
2106
- Encoding=UTF-8
2107
- Categories=Office
2108
- Exec=${name}
2109
- Icon=${name}
2110
- Name=${name}
2111
- StartupNotify=true
2112
- Terminal=false
2113
- Type=Application
2114
- `;
2115
- yield fs.writeFile(assertPath, desktopStr);
2116
2126
  yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
2117
2127
  let arch = "";
2118
2128
  if (process.arch === "x64") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pake-cli",
3
- "version": "0.1.2",
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,6 +13,14 @@
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",
@@ -35,7 +43,7 @@
35
43
  "license": "MIT",
36
44
  "dependencies": {
37
45
  "@tauri-apps/api": "^1.2.0",
38
- "@tauri-apps/cli": "^1.2.1",
46
+ "@tauri-apps/cli": "^1.2.2",
39
47
  "axios": "^1.1.3",
40
48
  "chalk": "^5.1.2",
41
49
  "commander": "^9.4.1",