pake-cli 0.1.0 → 0.1.2
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 +34 -27
- package/dist/cli.js +34 -22
- package/package.json +3 -4
- package/src-tauri/Cargo.lock +11 -69
- package/src-tauri/Cargo.toml +1 -1
- 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 +95 -113
- package/src-tauri/src/pake.js +17 -5
- package/src-tauri/tauri.linux.conf.json +1 -1
- package/pake-default.icns +0 -0
- package/src-tauri/tauri.conf.json.bak +0 -30
package/README.md
CHANGED
|
@@ -44,59 +44,57 @@
|
|
|
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_amd64.deb">Linux</a>
|
|
50
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/ChatGPT_x64.msi">Windows</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_amd64.deb">Linux</a>
|
|
55
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Qwerty_x64.msi">Windows</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
65
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Code_amd64.deb">Linux</a>
|
|
66
66
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Code_x64.msi">Windows</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_amd64.deb">Linux</a>
|
|
71
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/Reference_x64.msi">Windows</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_amd64.deb">Linux</a>
|
|
82
|
+
<a href="https://github.com/tw93/Pake/releases/latest/download/YouTube_x64.msi">Windows</a>
|
|
83
|
+
</td>
|
|
84
|
+
<td>Flomo
|
|
80
85
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Flomo.dmg">Mac</a>
|
|
81
86
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Flomo_amd64.deb">Linux</a>
|
|
82
87
|
<a href="https://github.com/tw93/Pake/releases/latest/download/Flomo_x64.msi">Windows</a>
|
|
83
88
|
</td>
|
|
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>
|
|
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
|
注意:Windows 下不能安装到 `C:\Program File`,会直接闪退,建议安装到其他非管理员权限目录,比如 `D:\Program Files (x86)` 。
|
|
97
97
|
|
|
98
|
-
对于轻度使用用户,使用 **GitHub Actions 在线编译多系统版本** 也是一个不错的选择,可查看[文档](/docs/README.md)。
|
|
99
|
-
|
|
100
98
|
## 命令行打包
|
|
101
99
|
|
|
102
100
|
<kbd>
|
|
@@ -117,6 +115,8 @@ pake url [options]
|
|
|
117
115
|
pake https://weekly.tw93.fun --name Weekly --transparent
|
|
118
116
|
```
|
|
119
117
|
|
|
118
|
+
假如你是不太会使用命令行的小白,使用 **GitHub Actions 在线编译多系统版本** 也是一个不错的选择,可查看[文档](./.github/workflows/docs/README.md)。
|
|
119
|
+
|
|
120
120
|
## 快捷键
|
|
121
121
|
|
|
122
122
|
| Mac | Windows/Linux | 功能 |
|
|
@@ -146,7 +146,7 @@ npm i
|
|
|
146
146
|
npm run dev
|
|
147
147
|
|
|
148
148
|
// 打包应用
|
|
149
|
-
npm run build
|
|
149
|
+
npm run build
|
|
150
150
|
|
|
151
151
|
```
|
|
152
152
|
|
|
@@ -249,6 +249,13 @@ Pake 的发展离不开这些 Hacker 们,一起贡献了大量能力,也欢
|
|
|
249
249
|
<sub><b>Aiello</b></sub>
|
|
250
250
|
</a>
|
|
251
251
|
</td>
|
|
252
|
+
<td align="center">
|
|
253
|
+
<a href="https://github.com/nekomeowww">
|
|
254
|
+
<img src="https://avatars.githubusercontent.com/u/11081491?v=4" width="90;" alt="nekomeowww"/>
|
|
255
|
+
<br />
|
|
256
|
+
<sub><b>Ayaka Neko</b></sub>
|
|
257
|
+
</a>
|
|
258
|
+
</td>
|
|
252
259
|
<td align="center">
|
|
253
260
|
<a href="https://github.com/houhoz">
|
|
254
261
|
<img src="https://avatars.githubusercontent.com/u/19684376?v=4" width="90;" alt="houhoz"/>
|
package/dist/cli.js
CHANGED
|
@@ -1619,7 +1619,8 @@ function mergeTauriConfig(url, options, tauriConf) {
|
|
|
1619
1619
|
tauriConf.tauri.bundle.identifier = identifier;
|
|
1620
1620
|
tauriConf.tauri.bundle.icon = [options.icon];
|
|
1621
1621
|
if (process.platform === "win32") {
|
|
1622
|
-
const ico_path = path.join(npmDirectory,
|
|
1622
|
+
const ico_path = path.join(npmDirectory, `src-tauri/png/${name.toLowerCase()}_32.ico`);
|
|
1623
|
+
tauriConf.tauri.bundle.resources = [`png/${name.toLowerCase()}_32.ico`];
|
|
1623
1624
|
yield fs.copyFile(options.icon, ico_path);
|
|
1624
1625
|
}
|
|
1625
1626
|
if (process.platform === "linux") {
|
|
@@ -1677,6 +1678,10 @@ const logger = {
|
|
|
1677
1678
|
}
|
|
1678
1679
|
};
|
|
1679
1680
|
|
|
1681
|
+
const IS_MAC = process.platform === 'darwin';
|
|
1682
|
+
const IS_WIN = process.platform === 'win32';
|
|
1683
|
+
const IS_LINUX = process.platform === 'linux';
|
|
1684
|
+
|
|
1680
1685
|
function handleIcon(options, url) {
|
|
1681
1686
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1682
1687
|
if (options.icon) {
|
|
@@ -1688,15 +1693,21 @@ function handleIcon(options, url) {
|
|
|
1688
1693
|
}
|
|
1689
1694
|
}
|
|
1690
1695
|
if (!options.icon) {
|
|
1691
|
-
return
|
|
1696
|
+
return getDefaultIcon();
|
|
1692
1697
|
}
|
|
1693
1698
|
});
|
|
1694
1699
|
}
|
|
1695
|
-
function
|
|
1700
|
+
function getDefaultIcon() {
|
|
1696
1701
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1697
1702
|
logger.info('You have not provided an app icon, use the default icon.(use --icon option to assign an icon)');
|
|
1698
|
-
|
|
1699
|
-
|
|
1703
|
+
let iconPath = 'src-tauri/icons/icon.icns';
|
|
1704
|
+
if (IS_WIN) {
|
|
1705
|
+
iconPath = 'src-tauri/png/icon_256.ico';
|
|
1706
|
+
}
|
|
1707
|
+
else if (IS_LINUX) {
|
|
1708
|
+
iconPath = 'src-tauri/png/icon_512.png';
|
|
1709
|
+
}
|
|
1710
|
+
return path.join(npmDirectory, iconPath);
|
|
1700
1711
|
});
|
|
1701
1712
|
}
|
|
1702
1713
|
// export async function getIconFromPageUrl(url: string) {
|
|
@@ -1772,10 +1783,6 @@ function handleOptions(options, url) {
|
|
|
1772
1783
|
});
|
|
1773
1784
|
}
|
|
1774
1785
|
|
|
1775
|
-
const IS_MAC = process.platform === 'darwin';
|
|
1776
|
-
const IS_WIN = process.platform === 'win32';
|
|
1777
|
-
const IS_LINUX = process.platform === 'linux';
|
|
1778
|
-
|
|
1779
1786
|
function shellExec(command) {
|
|
1780
1787
|
return new Promise((resolve, reject) => {
|
|
1781
1788
|
shelljs.exec(command, { async: true, silent: false }, (code) => {
|
|
@@ -1942,7 +1949,8 @@ var tauri = {
|
|
|
1942
1949
|
],
|
|
1943
1950
|
shortDescription: "",
|
|
1944
1951
|
targets: [
|
|
1945
|
-
"deb"
|
|
1952
|
+
"deb",
|
|
1953
|
+
"appimage"
|
|
1946
1954
|
]
|
|
1947
1955
|
}
|
|
1948
1956
|
};
|
|
@@ -1995,7 +2003,7 @@ class MacBuilder {
|
|
|
1995
2003
|
log.debug('PakeAppOptions', options);
|
|
1996
2004
|
const { name } = options;
|
|
1997
2005
|
yield mergeTauriConfig(url, options, tauriConf);
|
|
1998
|
-
yield shellExec(`cd ${npmDirectory} && npm install && npm run build
|
|
2006
|
+
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
|
|
1999
2007
|
let arch = "x64";
|
|
2000
2008
|
if (process.arch === "arm64") {
|
|
2001
2009
|
arch = "aarch64";
|
|
@@ -2045,7 +2053,7 @@ class WinBuilder {
|
|
|
2045
2053
|
logger.debug('PakeAppOptions', options);
|
|
2046
2054
|
const { name } = options;
|
|
2047
2055
|
yield mergeTauriConfig(url, options, tauriConf);
|
|
2048
|
-
yield shellExec(`cd ${npmDirectory} && npm install && npm run build
|
|
2056
|
+
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
|
|
2049
2057
|
const language = tauriConf.tauri.bundle.windows.wix.language[0];
|
|
2050
2058
|
const arch = process.arch;
|
|
2051
2059
|
const msiName = `${name}_${tauriConf.package.version}_${arch}_${language}.msi`;
|
|
@@ -2105,7 +2113,7 @@ Terminal=false
|
|
|
2105
2113
|
Type=Application
|
|
2106
2114
|
`;
|
|
2107
2115
|
yield fs.writeFile(assertPath, desktopStr);
|
|
2108
|
-
yield shellExec(`cd ${npmDirectory} && npm install && npm run build
|
|
2116
|
+
yield shellExec(`cd ${npmDirectory} && npm install && npm run build`);
|
|
2109
2117
|
let arch = "";
|
|
2110
2118
|
if (process.arch === "x64") {
|
|
2111
2119
|
arch = "amd64";
|
|
@@ -2114,22 +2122,27 @@ Type=Application
|
|
|
2114
2122
|
arch = process.arch;
|
|
2115
2123
|
}
|
|
2116
2124
|
const debName = `${name}_${tauriConf.package.version}_${arch}.deb`;
|
|
2117
|
-
const appPath = this.getBuildedAppPath(npmDirectory, debName);
|
|
2125
|
+
const appPath = this.getBuildedAppPath(npmDirectory, "deb", debName);
|
|
2118
2126
|
const distPath = path.resolve(`${name}.deb`);
|
|
2119
2127
|
yield fs.copyFile(appPath, distPath);
|
|
2120
2128
|
yield fs.unlink(appPath);
|
|
2129
|
+
const appImageName = `${name}_${tauriConf.package.version}_${arch}.AppImage`;
|
|
2130
|
+
const appImagePath = this.getBuildedAppPath(npmDirectory, "appimage", appImageName);
|
|
2131
|
+
const distAppPath = path.resolve(`${name}.AppImage`);
|
|
2132
|
+
yield fs.copyFile(appImagePath, distAppPath);
|
|
2133
|
+
yield fs.unlink(appImagePath);
|
|
2121
2134
|
logger.success('Build success!');
|
|
2122
|
-
logger.success('You can find the app installer in', distPath);
|
|
2135
|
+
logger.success('You can find the deb app installer in', distPath);
|
|
2136
|
+
logger.success('You can find the Appimage app installer in', distAppPath);
|
|
2123
2137
|
});
|
|
2124
2138
|
}
|
|
2125
|
-
getBuildedAppPath(npmDirectory,
|
|
2126
|
-
return path.join(npmDirectory, 'src-tauri/target/release/bundle/
|
|
2139
|
+
getBuildedAppPath(npmDirectory, packageType, packageName) {
|
|
2140
|
+
return path.join(npmDirectory, 'src-tauri/target/release/bundle/', packageType, packageName);
|
|
2127
2141
|
}
|
|
2128
2142
|
}
|
|
2129
2143
|
|
|
2130
2144
|
class BuilderFactory {
|
|
2131
2145
|
static create() {
|
|
2132
|
-
console.log("now platform is ", process.platform);
|
|
2133
2146
|
if (IS_MAC) {
|
|
2134
2147
|
return new MacBuilder();
|
|
2135
2148
|
}
|
|
@@ -2144,7 +2157,7 @@ class BuilderFactory {
|
|
|
2144
2157
|
}
|
|
2145
2158
|
|
|
2146
2159
|
var name = "pake-cli";
|
|
2147
|
-
var version = "
|
|
2160
|
+
var version = "0.1.2";
|
|
2148
2161
|
var description = "🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App 🤱🏻 A simple way to make any web page a desktop application using Rust.";
|
|
2149
2162
|
var bin = {
|
|
2150
2163
|
pake: "./cli.js"
|
|
@@ -2160,14 +2173,13 @@ var author = {
|
|
|
2160
2173
|
var files = [
|
|
2161
2174
|
"dist",
|
|
2162
2175
|
"src-tauri",
|
|
2163
|
-
"cli.js"
|
|
2164
|
-
"pake-default.icns"
|
|
2176
|
+
"cli.js"
|
|
2165
2177
|
];
|
|
2166
2178
|
var scripts = {
|
|
2167
2179
|
start: "npm run dev",
|
|
2168
2180
|
dev: "npm run tauri dev",
|
|
2169
2181
|
"dev:debug": "npm run tauri dev -- --features devtools",
|
|
2170
|
-
|
|
2182
|
+
build: "npm run tauri build --release",
|
|
2171
2183
|
"build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
|
|
2172
2184
|
"build:all-windows": ".\\script\\build.bat",
|
|
2173
2185
|
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.2",
|
|
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"
|
|
@@ -16,14 +16,13 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist",
|
|
18
18
|
"src-tauri",
|
|
19
|
-
"cli.js"
|
|
20
|
-
"pake-default.icns"
|
|
19
|
+
"cli.js"
|
|
21
20
|
],
|
|
22
21
|
"scripts": {
|
|
23
22
|
"start": "npm run dev",
|
|
24
23
|
"dev": "npm run tauri dev",
|
|
25
24
|
"dev:debug": "npm run tauri dev -- --features devtools",
|
|
26
|
-
"build
|
|
25
|
+
"build": "npm run tauri build --release",
|
|
27
26
|
"build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh",
|
|
28
27
|
"build:all-windows": ".\\script\\build.bat",
|
|
29
28
|
"tauri": "tauri",
|
package/src-tauri/Cargo.lock
CHANGED
|
@@ -49,7 +49,7 @@ dependencies = [
|
|
|
49
49
|
"tauri-build",
|
|
50
50
|
"tauri-utils",
|
|
51
51
|
"webbrowser",
|
|
52
|
-
"wry 0.
|
|
52
|
+
"wry 0.23.1",
|
|
53
53
|
]
|
|
54
54
|
|
|
55
55
|
[[package]]
|
|
@@ -1262,20 +1262,6 @@ dependencies = [
|
|
|
1262
1262
|
"system-deps 5.0.0",
|
|
1263
1263
|
]
|
|
1264
1264
|
|
|
1265
|
-
[[package]]
|
|
1266
|
-
name = "jni"
|
|
1267
|
-
version = "0.19.0"
|
|
1268
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
1269
|
-
checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec"
|
|
1270
|
-
dependencies = [
|
|
1271
|
-
"cesu8",
|
|
1272
|
-
"combine",
|
|
1273
|
-
"jni-sys",
|
|
1274
|
-
"log",
|
|
1275
|
-
"thiserror",
|
|
1276
|
-
"walkdir",
|
|
1277
|
-
]
|
|
1278
|
-
|
|
1279
1265
|
[[package]]
|
|
1280
1266
|
name = "jni"
|
|
1281
1267
|
version = "0.20.0"
|
|
@@ -2474,52 +2460,6 @@ dependencies = [
|
|
|
2474
2460
|
"version-compare 0.1.1",
|
|
2475
2461
|
]
|
|
2476
2462
|
|
|
2477
|
-
[[package]]
|
|
2478
|
-
name = "tao"
|
|
2479
|
-
version = "0.14.0"
|
|
2480
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
2481
|
-
checksum = "43336f5d1793543ba96e2a1e75f3a5c7dcd592743be06a0ab3a190f4fcb4b934"
|
|
2482
|
-
dependencies = [
|
|
2483
|
-
"bitflags",
|
|
2484
|
-
"cairo-rs",
|
|
2485
|
-
"cc",
|
|
2486
|
-
"cocoa",
|
|
2487
|
-
"core-foundation",
|
|
2488
|
-
"core-graphics",
|
|
2489
|
-
"crossbeam-channel",
|
|
2490
|
-
"dispatch",
|
|
2491
|
-
"gdk",
|
|
2492
|
-
"gdk-pixbuf",
|
|
2493
|
-
"gdk-sys",
|
|
2494
|
-
"gdkx11-sys",
|
|
2495
|
-
"gio",
|
|
2496
|
-
"glib",
|
|
2497
|
-
"glib-sys",
|
|
2498
|
-
"gtk",
|
|
2499
|
-
"image",
|
|
2500
|
-
"instant",
|
|
2501
|
-
"jni 0.19.0",
|
|
2502
|
-
"lazy_static",
|
|
2503
|
-
"libc",
|
|
2504
|
-
"log",
|
|
2505
|
-
"ndk",
|
|
2506
|
-
"ndk-context",
|
|
2507
|
-
"ndk-sys",
|
|
2508
|
-
"objc",
|
|
2509
|
-
"once_cell",
|
|
2510
|
-
"parking_lot",
|
|
2511
|
-
"paste",
|
|
2512
|
-
"png",
|
|
2513
|
-
"raw-window-handle",
|
|
2514
|
-
"scopeguard",
|
|
2515
|
-
"serde",
|
|
2516
|
-
"unicode-segmentation",
|
|
2517
|
-
"uuid 1.2.2",
|
|
2518
|
-
"windows 0.39.0",
|
|
2519
|
-
"windows-implement",
|
|
2520
|
-
"x11-dl",
|
|
2521
|
-
]
|
|
2522
|
-
|
|
2523
2463
|
[[package]]
|
|
2524
2464
|
name = "tao"
|
|
2525
2465
|
version = "0.15.6"
|
|
@@ -2544,7 +2484,7 @@ dependencies = [
|
|
|
2544
2484
|
"gtk",
|
|
2545
2485
|
"image",
|
|
2546
2486
|
"instant",
|
|
2547
|
-
"jni
|
|
2487
|
+
"jni",
|
|
2548
2488
|
"lazy_static",
|
|
2549
2489
|
"libc",
|
|
2550
2490
|
"log",
|
|
@@ -3149,7 +3089,7 @@ version = "0.8.2"
|
|
|
3149
3089
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
3150
3090
|
checksum = "2a0cc7962b5aaa0dfcebaeef0161eec6edf5f4606c12e6777fd7d392f52033a5"
|
|
3151
3091
|
dependencies = [
|
|
3152
|
-
"jni
|
|
3092
|
+
"jni",
|
|
3153
3093
|
"ndk-context",
|
|
3154
3094
|
"objc",
|
|
3155
3095
|
"raw-window-handle",
|
|
@@ -3474,15 +3414,16 @@ dependencies = [
|
|
|
3474
3414
|
|
|
3475
3415
|
[[package]]
|
|
3476
3416
|
name = "wry"
|
|
3477
|
-
version = "0.
|
|
3417
|
+
version = "0.22.5"
|
|
3478
3418
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
3479
|
-
checksum = "
|
|
3419
|
+
checksum = "e3b4906cc7b3c5959893f3984bb60882ec94539eb14622077e6529f5b3d008ee"
|
|
3480
3420
|
dependencies = [
|
|
3481
3421
|
"base64",
|
|
3482
3422
|
"block",
|
|
3483
3423
|
"cocoa",
|
|
3484
3424
|
"core-graphics",
|
|
3485
3425
|
"crossbeam-channel",
|
|
3426
|
+
"dunce",
|
|
3486
3427
|
"gdk",
|
|
3487
3428
|
"gio",
|
|
3488
3429
|
"glib",
|
|
@@ -3498,7 +3439,8 @@ dependencies = [
|
|
|
3498
3439
|
"serde",
|
|
3499
3440
|
"serde_json",
|
|
3500
3441
|
"sha2",
|
|
3501
|
-
"
|
|
3442
|
+
"soup2",
|
|
3443
|
+
"tao",
|
|
3502
3444
|
"thiserror",
|
|
3503
3445
|
"url",
|
|
3504
3446
|
"webkit2gtk",
|
|
@@ -3510,9 +3452,9 @@ dependencies = [
|
|
|
3510
3452
|
|
|
3511
3453
|
[[package]]
|
|
3512
3454
|
name = "wry"
|
|
3513
|
-
version = "0.
|
|
3455
|
+
version = "0.23.1"
|
|
3514
3456
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
3515
|
-
checksum = "
|
|
3457
|
+
checksum = "a76c9236a810d4af02213f89f5bc55bf3262d40c4407b13a9fc847156ef8b856"
|
|
3516
3458
|
dependencies = [
|
|
3517
3459
|
"base64",
|
|
3518
3460
|
"block",
|
|
@@ -3536,7 +3478,7 @@ dependencies = [
|
|
|
3536
3478
|
"serde_json",
|
|
3537
3479
|
"sha2",
|
|
3538
3480
|
"soup2",
|
|
3539
|
-
"tao
|
|
3481
|
+
"tao",
|
|
3540
3482
|
"thiserror",
|
|
3541
3483
|
"url",
|
|
3542
3484
|
"webkit2gtk",
|
package/src-tauri/Cargo.toml
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src-tauri/src/main.rs
CHANGED
|
@@ -2,101 +2,76 @@
|
|
|
2
2
|
#![windows_subsystem = "windows"]
|
|
3
3
|
extern crate image;
|
|
4
4
|
use tauri_utils::config::{Config, WindowConfig};
|
|
5
|
-
#[cfg(target_os = "macos")]
|
|
6
|
-
use wry::application::platform::macos::WindowBuilderExtMacOS;
|
|
7
|
-
|
|
8
|
-
#[cfg(target_os = "macos")]
|
|
9
5
|
use wry::{
|
|
10
6
|
application::{
|
|
11
|
-
accelerator::{Accelerator, SysMods},
|
|
12
7
|
event::{Event, StartCause, WindowEvent},
|
|
13
8
|
event_loop::{ControlFlow, EventLoop},
|
|
14
|
-
|
|
15
|
-
menu::{MenuBar as Menu, MenuItem, MenuItemAttributes, MenuType},
|
|
9
|
+
menu::MenuType,
|
|
16
10
|
window::{Fullscreen, Window, WindowBuilder},
|
|
17
11
|
},
|
|
18
12
|
webview::WebViewBuilder,
|
|
19
13
|
};
|
|
20
14
|
|
|
21
|
-
#[cfg(target_os = "
|
|
22
|
-
use wry::{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
window::{Fullscreen, Icon, Window, WindowBuilder},
|
|
28
|
-
},
|
|
29
|
-
webview::WebViewBuilder,
|
|
15
|
+
#[cfg(target_os = "macos")]
|
|
16
|
+
use wry::application::{
|
|
17
|
+
accelerator::{Accelerator, SysMods},
|
|
18
|
+
keyboard::KeyCode,
|
|
19
|
+
menu::{MenuBar as Menu, MenuItem, MenuItemAttributes},
|
|
20
|
+
platform::macos::WindowBuilderExtMacOS,
|
|
30
21
|
};
|
|
31
22
|
|
|
23
|
+
#[cfg(target_os = "windows")]
|
|
24
|
+
use wry::application::window::Icon;
|
|
25
|
+
|
|
32
26
|
#[cfg(target_os = "linux")]
|
|
33
|
-
use wry::
|
|
34
|
-
application::{
|
|
35
|
-
event::{Event, StartCause, WindowEvent},
|
|
36
|
-
event_loop::{ControlFlow, EventLoop},
|
|
37
|
-
menu::MenuType,
|
|
38
|
-
window::{Fullscreen, Window, WindowBuilder},
|
|
39
|
-
},
|
|
40
|
-
webview::{WebContext, WebViewBuilder},
|
|
41
|
-
};
|
|
27
|
+
use wry::webview::WebContext;
|
|
42
28
|
|
|
43
29
|
fn main() -> wry::Result<()> {
|
|
44
30
|
#[cfg(target_os = "macos")]
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
first_menu.add_native_item(MenuItem::SelectAll);
|
|
68
|
-
#[cfg(target_os = "macos")]
|
|
69
|
-
first_menu.add_native_item(MenuItem::Separator);
|
|
70
|
-
|
|
71
|
-
#[cfg(target_os = "macos")]
|
|
72
|
-
let close_item = first_menu.add_item(
|
|
73
|
-
MenuItemAttributes::new("CloseWindow")
|
|
74
|
-
.with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
|
|
75
|
-
);
|
|
31
|
+
let (menu_bar_menu, close_item) = {
|
|
32
|
+
let mut menu_bar_menu = Menu::new();
|
|
33
|
+
let mut first_menu = Menu::new();
|
|
34
|
+
first_menu.add_native_item(MenuItem::Hide);
|
|
35
|
+
first_menu.add_native_item(MenuItem::EnterFullScreen);
|
|
36
|
+
first_menu.add_native_item(MenuItem::Minimize);
|
|
37
|
+
first_menu.add_native_item(MenuItem::Separator);
|
|
38
|
+
first_menu.add_native_item(MenuItem::Copy);
|
|
39
|
+
first_menu.add_native_item(MenuItem::Cut);
|
|
40
|
+
first_menu.add_native_item(MenuItem::Paste);
|
|
41
|
+
first_menu.add_native_item(MenuItem::Undo);
|
|
42
|
+
first_menu.add_native_item(MenuItem::Redo);
|
|
43
|
+
first_menu.add_native_item(MenuItem::SelectAll);
|
|
44
|
+
first_menu.add_native_item(MenuItem::Separator);
|
|
45
|
+
let close_item = first_menu.add_item(
|
|
46
|
+
MenuItemAttributes::new("CloseWindow")
|
|
47
|
+
.with_accelerators(&Accelerator::new(SysMods::Cmd, KeyCode::KeyW)),
|
|
48
|
+
);
|
|
49
|
+
first_menu.add_native_item(MenuItem::Quit);
|
|
50
|
+
menu_bar_menu.add_submenu("App", true, first_menu);
|
|
51
|
+
(menu_bar_menu, close_item)
|
|
52
|
+
};
|
|
76
53
|
|
|
77
|
-
#[cfg(target_os = "
|
|
78
|
-
|
|
54
|
+
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
|
55
|
+
let (
|
|
56
|
+
package_name,
|
|
57
|
+
WindowConfig {
|
|
58
|
+
url,
|
|
59
|
+
width,
|
|
60
|
+
height,
|
|
61
|
+
resizable,
|
|
62
|
+
fullscreen,
|
|
63
|
+
..
|
|
64
|
+
},
|
|
65
|
+
) = {
|
|
66
|
+
let (package_name, windows_config) = get_windows_config();
|
|
67
|
+
(
|
|
68
|
+
package_name
|
|
69
|
+
.expect("can't get package name in config file")
|
|
70
|
+
.to_lowercase(),
|
|
71
|
+
windows_config.unwrap_or_default(),
|
|
72
|
+
)
|
|
73
|
+
};
|
|
79
74
|
|
|
80
|
-
#[cfg(target_os = "macos")]
|
|
81
|
-
menu_bar_menu.add_submenu("App", true, first_menu);
|
|
82
|
-
#[cfg(target_os = "linux")]
|
|
83
|
-
let WindowConfig {
|
|
84
|
-
url,
|
|
85
|
-
width,
|
|
86
|
-
height,
|
|
87
|
-
resizable,
|
|
88
|
-
fullscreen,
|
|
89
|
-
..
|
|
90
|
-
} = get_windows_config().unwrap_or_default();
|
|
91
|
-
#[cfg(target_os = "windows")]
|
|
92
|
-
let WindowConfig {
|
|
93
|
-
url,
|
|
94
|
-
width,
|
|
95
|
-
height,
|
|
96
|
-
resizable,
|
|
97
|
-
fullscreen,
|
|
98
|
-
..
|
|
99
|
-
} = get_windows_config().unwrap_or_default();
|
|
100
75
|
#[cfg(target_os = "macos")]
|
|
101
76
|
let WindowConfig {
|
|
102
77
|
url,
|
|
@@ -106,7 +81,7 @@ fn main() -> wry::Result<()> {
|
|
|
106
81
|
transparent,
|
|
107
82
|
fullscreen,
|
|
108
83
|
..
|
|
109
|
-
} = get_windows_config().unwrap_or_default();
|
|
84
|
+
} = get_windows_config().1.unwrap_or_default();
|
|
110
85
|
let event_loop = EventLoop::new();
|
|
111
86
|
|
|
112
87
|
let common_window = WindowBuilder::new()
|
|
@@ -119,14 +94,15 @@ fn main() -> wry::Result<()> {
|
|
|
119
94
|
})
|
|
120
95
|
.with_inner_size(wry::application::dpi::LogicalSize::new(width, height));
|
|
121
96
|
#[cfg(target_os = "windows")]
|
|
122
|
-
let
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
97
|
+
let window = {
|
|
98
|
+
let icon_path = format!("png/{}_32.ico", package_name);
|
|
99
|
+
let icon = load_icon(std::path::Path::new(&icon_path));
|
|
100
|
+
common_window
|
|
101
|
+
.with_decorations(true)
|
|
102
|
+
.with_window_icon(Some(icon))
|
|
103
|
+
.build(&event_loop)
|
|
104
|
+
.unwrap()
|
|
105
|
+
};
|
|
130
106
|
|
|
131
107
|
#[cfg(target_os = "linux")]
|
|
132
108
|
let window = common_window.build(&event_loop).unwrap();
|
|
@@ -164,12 +140,11 @@ fn main() -> wry::Result<()> {
|
|
|
164
140
|
#[cfg(target_os = "macos")]
|
|
165
141
|
let webview = WebViewBuilder::new(window)?
|
|
166
142
|
// .with_user_agent(user_agent_string)
|
|
167
|
-
// .with_accept_first_mouse(true)
|
|
168
143
|
.with_url(&url.to_string())?
|
|
169
144
|
.with_devtools(cfg!(feature = "devtools"))
|
|
170
145
|
.with_initialization_script(include_str!("pake.js"))
|
|
171
146
|
.with_ipc_handler(handler)
|
|
172
|
-
|
|
147
|
+
.with_back_forward_navigation_gestures(true)
|
|
173
148
|
.build()?;
|
|
174
149
|
|
|
175
150
|
#[cfg(target_os = "windows")]
|
|
@@ -180,31 +155,36 @@ fn main() -> wry::Result<()> {
|
|
|
180
155
|
.with_devtools(cfg!(feature = "devtools"))
|
|
181
156
|
.with_initialization_script(include_str!("pake.js"))
|
|
182
157
|
.with_ipc_handler(handler)
|
|
183
|
-
// .with_back_forward_navigation_gestures(true)
|
|
184
158
|
.build()?;
|
|
159
|
+
|
|
185
160
|
// 自定义cookie文件夹,仅用于Linux
|
|
186
161
|
// Custom Cookie folder, only for Linux
|
|
187
162
|
#[cfg(target_os = "linux")]
|
|
188
|
-
let
|
|
189
|
-
std::
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
163
|
+
let webview = {
|
|
164
|
+
let user = std::env::var_os("USER");
|
|
165
|
+
let config_path = match user {
|
|
166
|
+
Some(v) => format!(
|
|
167
|
+
"/home/{}/.config/{}",
|
|
168
|
+
v.into_string().unwrap(),
|
|
169
|
+
package_name,
|
|
170
|
+
),
|
|
171
|
+
None => panic!("can't found any user"),
|
|
172
|
+
};
|
|
173
|
+
let data_path = std::path::PathBuf::from(&config_path);
|
|
174
|
+
if !std::path::Path::new(&data_path).exists() {
|
|
175
|
+
std::fs::create_dir(&data_path)
|
|
176
|
+
.unwrap_or_else(|_| panic!("can't create dir {}", &config_path));
|
|
177
|
+
}
|
|
178
|
+
let mut web_content = WebContext::new(Some(data_path));
|
|
179
|
+
WebViewBuilder::new(window)?
|
|
180
|
+
// .with_user_agent(user_agent_string)
|
|
181
|
+
.with_url(&url.to_string())?
|
|
182
|
+
.with_devtools(cfg!(feature = "devtools"))
|
|
183
|
+
.with_initialization_script(include_str!("pake.js"))
|
|
184
|
+
.with_ipc_handler(handler)
|
|
185
|
+
.with_web_context(&mut web_content)
|
|
186
|
+
.build()?
|
|
187
|
+
};
|
|
208
188
|
#[cfg(feature = "devtools")]
|
|
209
189
|
{
|
|
210
190
|
webview.open_devtools();
|
|
@@ -236,11 +216,13 @@ fn main() -> wry::Result<()> {
|
|
|
236
216
|
});
|
|
237
217
|
}
|
|
238
218
|
|
|
239
|
-
fn get_windows_config() -> Option<WindowConfig> {
|
|
219
|
+
fn get_windows_config() -> (Option<String>, Option<WindowConfig>) {
|
|
240
220
|
let config_file = include_str!("../tauri.conf.json");
|
|
241
221
|
let config: Config = serde_json::from_str(config_file).expect("failed to parse windows config");
|
|
242
|
-
|
|
243
|
-
|
|
222
|
+
(
|
|
223
|
+
config.package.product_name.clone(),
|
|
224
|
+
config.tauri.windows.first().cloned(),
|
|
225
|
+
)
|
|
244
226
|
}
|
|
245
227
|
|
|
246
228
|
#[cfg(target_os = "windows")]
|
package/src-tauri/src/pake.js
CHANGED
|
@@ -55,6 +55,18 @@ window.addEventListener("DOMContentLoaded", (_event) => {
|
|
|
55
55
|
padding-top: 20px;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
#__next .overflow-hidden .flex.flex-1.flex-col {
|
|
59
|
+
padding-left: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#__next .overflow-hidden>.hidden.bg-gray-900 {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#__next .overflow-hidden main .absolute .text-xs{
|
|
67
|
+
visibility: hidden;
|
|
68
|
+
}
|
|
69
|
+
|
|
58
70
|
.lark > .dashboard-sidebar, .lark > .dashboard-sidebar > .sidebar-user-info , .lark > .dashboard-sidebar .index-module_wrapper_F-Wbq{
|
|
59
71
|
padding-top:15px;
|
|
60
72
|
}
|
|
@@ -306,16 +318,16 @@ window.addEventListener("DOMContentLoaded", (_event) => {
|
|
|
306
318
|
document.addEventListener("click", (e) => {
|
|
307
319
|
const origin = e.target.closest("a");
|
|
308
320
|
if (origin && origin.href) {
|
|
321
|
+
const target = origin.target
|
|
309
322
|
origin.target = "_self";
|
|
323
|
+
const hrefUrl = new URL(origin.href)
|
|
310
324
|
|
|
311
|
-
//额外处理下 twitter 的外跳,对于其他需要外跳的可以改这里成对应域名
|
|
312
|
-
const href = origin.href;
|
|
313
325
|
if (
|
|
314
|
-
location.host
|
|
315
|
-
|
|
326
|
+
window.location.host !== hrefUrl.host && // 如果 a 标签内链接的域名和当前页面的域名不一致 且
|
|
327
|
+
target === '_blank' // a 标签内链接的 target 属性为 _blank 时
|
|
316
328
|
) {
|
|
317
329
|
e.preventDefault();
|
|
318
|
-
window.ipc.postMessage(`open_browser:${href}`);
|
|
330
|
+
window.ipc.postMessage(`open_browser:${origin.href}`);
|
|
319
331
|
}
|
|
320
332
|
}
|
|
321
333
|
});
|
package/pake-default.icns
DELETED
|
Binary file
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"package": {
|
|
3
|
-
"productName": "WeRead",
|
|
4
|
-
"version": "1.0.0"
|
|
5
|
-
},
|
|
6
|
-
"tauri": {
|
|
7
|
-
"windows": [
|
|
8
|
-
{
|
|
9
|
-
"url": "https://weread.qq.com/",
|
|
10
|
-
"transparent": true,
|
|
11
|
-
"fullscreen": false,
|
|
12
|
-
"width": 1200,
|
|
13
|
-
"height": 728,
|
|
14
|
-
"resizable": true
|
|
15
|
-
}
|
|
16
|
-
],
|
|
17
|
-
"security": {
|
|
18
|
-
"csp": null
|
|
19
|
-
},
|
|
20
|
-
"updater": {
|
|
21
|
-
"active": false
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"build": {
|
|
25
|
-
"devPath": "../dist",
|
|
26
|
-
"distDir": "../dist",
|
|
27
|
-
"beforeBuildCommand": "",
|
|
28
|
-
"beforeDevCommand": ""
|
|
29
|
-
}
|
|
30
|
-
}
|