fix: wrong exe path
This commit is contained in:
parent
72127979c3
commit
c9c06f8a3d
7
src-tauri/Cargo.lock
generated
7
src-tauri/Cargo.lock
generated
@ -448,6 +448,7 @@ dependencies = [
|
|||||||
"auto-launch",
|
"auto-launch",
|
||||||
"chrono",
|
"chrono",
|
||||||
"dirs",
|
"dirs",
|
||||||
|
"dunce",
|
||||||
"log",
|
"log",
|
||||||
"log4rs",
|
"log4rs",
|
||||||
"port_scanner",
|
"port_scanner",
|
||||||
@ -868,6 +869,12 @@ dependencies = [
|
|||||||
"dtoa",
|
"dtoa",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dunce"
|
||||||
|
version = "1.0.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "453440c271cf5577fd2a40e4942540cb7d0d2f85e27c8d07dd0023c925a67541"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "easy-parallel"
|
name = "easy-parallel"
|
||||||
version = "3.2.0"
|
version = "3.2.0"
|
||||||
|
@ -14,6 +14,7 @@ tauri-build = { version = "1.0.0-rc.3", features = [] }
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dirs = "4.0.0"
|
dirs = "4.0.0"
|
||||||
|
dunce = "1.0.2"
|
||||||
chrono = "0.4.19"
|
chrono = "0.4.19"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde_yaml = "0.8"
|
serde_yaml = "0.8"
|
||||||
|
@ -5,7 +5,7 @@ use crate::{
|
|||||||
use auto_launch::{AutoLaunch, AutoLaunchBuilder};
|
use auto_launch::{AutoLaunch, AutoLaunchBuilder};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tauri::{api::path::resource_dir, async_runtime::Mutex};
|
use tauri::{async_runtime::Mutex, utils::platform::current_exe};
|
||||||
|
|
||||||
/// ### `verge.yaml` schema
|
/// ### `verge.yaml` schema
|
||||||
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
#[derive(Default, Debug, Clone, Deserialize, Serialize)]
|
||||||
@ -122,13 +122,11 @@ impl Verge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// init the auto launch
|
/// init the auto launch
|
||||||
pub fn init_launch(&mut self, package_info: &tauri::PackageInfo) {
|
pub fn init_launch(&mut self) {
|
||||||
let app_name = "clash-verge";
|
let app_exe = current_exe().unwrap();
|
||||||
let app_path = get_app_path(app_name);
|
let app_exe = dunce::canonicalize(app_exe).unwrap();
|
||||||
let app_path = resource_dir(package_info, &tauri::Env::default())
|
let app_name = app_exe.file_stem().unwrap().to_str().unwrap();
|
||||||
.unwrap()
|
let app_path = app_exe.as_os_str().to_str().unwrap();
|
||||||
.join(app_path);
|
|
||||||
let app_path = app_path.as_os_str().to_str().unwrap();
|
|
||||||
|
|
||||||
let auto = AutoLaunchBuilder::new()
|
let auto = AutoLaunchBuilder::new()
|
||||||
.set_app_name(app_name)
|
.set_app_name(app_name)
|
||||||
@ -324,14 +322,3 @@ impl Verge {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the target app_path
|
|
||||||
fn get_app_path(app_name: &str) -> String {
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
let ext = "";
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let ext = "";
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
let ext = ".exe";
|
|
||||||
String::from(app_name) + ext
|
|
||||||
}
|
|
||||||
|
@ -31,7 +31,7 @@ pub fn resolve_setup(app: &App) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
verge.init_sysproxy(clash.info.port.clone());
|
verge.init_sysproxy(clash.info.port.clone());
|
||||||
verge.init_launch(app.package_info());
|
verge.init_launch();
|
||||||
if let Err(err) = verge.sync_launch() {
|
if let Err(err) = verge.sync_launch() {
|
||||||
log::error!("{}", err);
|
log::error!("{}", err);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user