chore: compatible with macos
This commit is contained in:
@@ -9,8 +9,6 @@ default-run = "app"
|
||||
edition = "2021"
|
||||
build = "src/build.rs"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "1.0.0-beta.4" }
|
||||
|
||||
@@ -20,10 +18,12 @@ serde_json = "1.0"
|
||||
serde_yaml = "0.8"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
tauri = { version = "1.0.0-beta.8", features = ["api-all", "system-tray"] }
|
||||
winreg = { version = "0.10", features = ["transactions"] }
|
||||
reqwest = { version = "0.11", features = ["json"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winreg = { version = "0.10", features = ["transactions"] }
|
||||
|
||||
[features]
|
||||
default = [ "custom-protocol" ]
|
||||
custom-protocol = [ "tauri/custom-protocol" ]
|
||||
|
||||
@@ -19,13 +19,15 @@ async fn get_config_data(url: String) -> Result<String, String> {
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let config = sysopt::get_proxy_config()?;
|
||||
println!("{:?}", config);
|
||||
clash::run_clash_bin(&clash::get_config_dir().to_str().unwrap());
|
||||
|
||||
let app = tauri::Builder::default()
|
||||
.system_tray(
|
||||
SystemTray::new()
|
||||
.with_menu(SystemTrayMenu::new().add_item(CustomMenuItem::new("tray_event_quit", "Quit"))),
|
||||
SystemTray::new().with_menu(
|
||||
SystemTrayMenu::new()
|
||||
.add_item(CustomMenuItem::new("event_show", "Show"))
|
||||
.add_item(CustomMenuItem::new("event_quit", "Quit")),
|
||||
),
|
||||
)
|
||||
.on_system_tray_event(move |app, event| match event {
|
||||
SystemTrayEvent::LeftClick { .. } => {
|
||||
@@ -35,7 +37,12 @@ fn main() -> std::io::Result<()> {
|
||||
}
|
||||
|
||||
SystemTrayEvent::MenuItemClick { id, .. } => match id.as_str() {
|
||||
"tray_event_quit" => {
|
||||
"event_show" => {
|
||||
let window = app.get_window("main").unwrap();
|
||||
window.show().unwrap();
|
||||
window.set_focus().unwrap();
|
||||
}
|
||||
"event_quit" => {
|
||||
app.exit(0);
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::io;
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
use winreg::enums::*;
|
||||
#[cfg(target_os = "windows")]
|
||||
use winreg::RegKey;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"resources": [],
|
||||
"externalBin": ["bin/clash"],
|
||||
"externalBin": ["sidebar/clash"],
|
||||
"copyright": "",
|
||||
"category": "DeveloperTool",
|
||||
"shortDescription": "",
|
||||
|
||||
Reference in New Issue
Block a user