pake-cli 0.1.0 → 0.1.1
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/dist/cli.js +3 -2
- package/package.json +1 -1
- package/src-tauri/src/main.rs +37 -11
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") {
|
|
@@ -2144,7 +2145,7 @@ class BuilderFactory {
|
|
|
2144
2145
|
}
|
|
2145
2146
|
|
|
2146
2147
|
var name = "pake-cli";
|
|
2147
|
-
var version = "
|
|
2148
|
+
var version = "0.1.1";
|
|
2148
2149
|
var description = "🤱🏻 很简单的用 Rust 打包网页生成很小的桌面 App 🤱🏻 A simple way to make any web page a desktop application using Rust.";
|
|
2149
2150
|
var bin = {
|
|
2150
2151
|
pake: "./cli.js"
|
package/package.json
CHANGED
package/src-tauri/src/main.rs
CHANGED
|
@@ -79,6 +79,12 @@ fn main() -> wry::Result<()> {
|
|
|
79
79
|
|
|
80
80
|
#[cfg(target_os = "macos")]
|
|
81
81
|
menu_bar_menu.add_submenu("App", true, first_menu);
|
|
82
|
+
#[cfg(target_os = "linux")]
|
|
83
|
+
let (package_name, windows_config) = get_windows_config();
|
|
84
|
+
|
|
85
|
+
#[cfg(target_os = "linux")]
|
|
86
|
+
let package_name = package_name.expect("can't get package name in config file");
|
|
87
|
+
|
|
82
88
|
#[cfg(target_os = "linux")]
|
|
83
89
|
let WindowConfig {
|
|
84
90
|
url,
|
|
@@ -87,7 +93,9 @@ fn main() -> wry::Result<()> {
|
|
|
87
93
|
resizable,
|
|
88
94
|
fullscreen,
|
|
89
95
|
..
|
|
90
|
-
} =
|
|
96
|
+
} = windows_config.unwrap_or_default();
|
|
97
|
+
#[cfg(target_os = "windows")]
|
|
98
|
+
let (package_name, windows_config) = get_windows_config();
|
|
91
99
|
#[cfg(target_os = "windows")]
|
|
92
100
|
let WindowConfig {
|
|
93
101
|
url,
|
|
@@ -96,7 +104,7 @@ fn main() -> wry::Result<()> {
|
|
|
96
104
|
resizable,
|
|
97
105
|
fullscreen,
|
|
98
106
|
..
|
|
99
|
-
} =
|
|
107
|
+
} = windows_config.unwrap_or_default();
|
|
100
108
|
#[cfg(target_os = "macos")]
|
|
101
109
|
let WindowConfig {
|
|
102
110
|
url,
|
|
@@ -106,7 +114,7 @@ fn main() -> wry::Result<()> {
|
|
|
106
114
|
transparent,
|
|
107
115
|
fullscreen,
|
|
108
116
|
..
|
|
109
|
-
} = get_windows_config().unwrap_or_default();
|
|
117
|
+
} = get_windows_config().1.unwrap_or_default();
|
|
110
118
|
let event_loop = EventLoop::new();
|
|
111
119
|
|
|
112
120
|
let common_window = WindowBuilder::new()
|
|
@@ -119,8 +127,13 @@ fn main() -> wry::Result<()> {
|
|
|
119
127
|
})
|
|
120
128
|
.with_inner_size(wry::application::dpi::LogicalSize::new(width, height));
|
|
121
129
|
#[cfg(target_os = "windows")]
|
|
122
|
-
let
|
|
123
|
-
|
|
130
|
+
let package_name = package_name
|
|
131
|
+
.expect("can't get package name in config file")
|
|
132
|
+
.to_lowercase();
|
|
133
|
+
#[cfg(target_os = "windows")]
|
|
134
|
+
let icon_path = format!("png/{}_32.ico", package_name);
|
|
135
|
+
#[cfg(target_os = "windows")]
|
|
136
|
+
let icon = load_icon(std::path::Path::new(&icon_path));
|
|
124
137
|
#[cfg(target_os = "windows")]
|
|
125
138
|
let window = common_window
|
|
126
139
|
.with_decorations(true)
|
|
@@ -184,12 +197,23 @@ fn main() -> wry::Result<()> {
|
|
|
184
197
|
.build()?;
|
|
185
198
|
// 自定义cookie文件夹,仅用于Linux
|
|
186
199
|
// Custom Cookie folder, only for Linux
|
|
200
|
+
// #[cfg(target_os = "linux")]
|
|
201
|
+
// let config_path = format!("/home/{}/.config/{}", env!("USER"), package_name);
|
|
202
|
+
#[cfg(target_os = "linux")]
|
|
203
|
+
let user = std::env::var_os("USER");
|
|
187
204
|
#[cfg(target_os = "linux")]
|
|
188
|
-
let
|
|
189
|
-
|
|
205
|
+
let config_path = match user {
|
|
206
|
+
Some(v) => format!(
|
|
207
|
+
"/home/{}/.config/{}", v.into_string().unwrap(), package_name
|
|
208
|
+
),
|
|
209
|
+
None => panic!("can't found any user")
|
|
210
|
+
};
|
|
211
|
+
#[cfg(target_os = "linux")]
|
|
212
|
+
let data_path = std::path::PathBuf::from(&config_path);
|
|
190
213
|
#[cfg(target_os = "linux")]
|
|
191
214
|
if !std::path::Path::new(&data_path).exists() {
|
|
192
|
-
std::fs::create_dir(&data_path)
|
|
215
|
+
std::fs::create_dir(&data_path)
|
|
216
|
+
.unwrap_or_else(|_| panic!("can't create dir {}", &config_path));
|
|
193
217
|
}
|
|
194
218
|
#[cfg(target_os = "linux")]
|
|
195
219
|
let mut web_content = WebContext::new(Some(data_path));
|
|
@@ -236,11 +260,13 @@ fn main() -> wry::Result<()> {
|
|
|
236
260
|
});
|
|
237
261
|
}
|
|
238
262
|
|
|
239
|
-
fn get_windows_config() -> Option<WindowConfig> {
|
|
263
|
+
fn get_windows_config() -> (Option<String>, Option<WindowConfig>) {
|
|
240
264
|
let config_file = include_str!("../tauri.conf.json");
|
|
241
265
|
let config: Config = serde_json::from_str(config_file).expect("failed to parse windows config");
|
|
242
|
-
|
|
243
|
-
|
|
266
|
+
(
|
|
267
|
+
config.package.product_name.clone(),
|
|
268
|
+
config.tauri.windows.first().cloned(),
|
|
269
|
+
)
|
|
244
270
|
}
|
|
245
271
|
|
|
246
272
|
#[cfg(target_os = "windows")]
|