mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
refactor: optimize
This commit is contained in:
@@ -58,22 +58,20 @@ pub fn open_file(path: PathBuf) -> Result<()> {
|
||||
.arg(path)
|
||||
.spawn()
|
||||
{
|
||||
bail!(format!("failed to open file by VScode for `{err}`"));
|
||||
bail!("failed to open file by VScode for `{err}`");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
if let Err(err) = Command::new(code).arg(path).spawn() {
|
||||
bail!(format!("failed to open file by VScode for `{err}`"));
|
||||
bail!("failed to open file by VScode for `{err}`");
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
match open::that(path) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => bail!(format!("failed to open file for `{err}`")),
|
||||
}
|
||||
open::that(path)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
||||
@@ -4,6 +4,5 @@ pub mod help;
|
||||
pub mod init;
|
||||
pub mod resolve;
|
||||
pub mod server;
|
||||
pub mod sysopt;
|
||||
pub mod tmpl;
|
||||
mod winhelp;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{core::Core, utils::init, utils::server};
|
||||
use crate::{core::Core, data::Data, utils::init, utils::server};
|
||||
use tauri::{App, AppHandle, Manager};
|
||||
|
||||
/// handle something when start app
|
||||
@@ -6,32 +6,27 @@ pub fn resolve_setup(app: &App) {
|
||||
// init app config
|
||||
init::init_app(app.package_info());
|
||||
|
||||
// init core
|
||||
// should be initialized after init_app fix #122
|
||||
let core = Core::new();
|
||||
|
||||
{
|
||||
let verge = core.verge.lock();
|
||||
let global = Data::global();
|
||||
let verge = global.verge.lock();
|
||||
let singleton = verge.app_singleton_port.clone();
|
||||
|
||||
// setup a simple http server for singleton
|
||||
server::embed_server(&app.handle(), singleton);
|
||||
}
|
||||
|
||||
core.set_win(app.get_window("main"));
|
||||
// core should be initialized after init_app fix #122
|
||||
let mut core = Core::global();
|
||||
core.init(app.app_handle());
|
||||
|
||||
// fix #122
|
||||
app.manage(core);
|
||||
|
||||
resolve_window(app);
|
||||
}
|
||||
|
||||
/// reset system proxy
|
||||
pub fn resolve_reset(app_handle: &AppHandle) {
|
||||
let core = app_handle.state::<Core>();
|
||||
pub fn resolve_reset() {
|
||||
let core = Core::global();
|
||||
let mut sysopt = core.sysopt.lock();
|
||||
sysopt.reset_sysproxy();
|
||||
crate::log_if_err!(sysopt.reset_sysproxy());
|
||||
drop(sysopt);
|
||||
|
||||
let mut service = core.service.lock();
|
||||
|
||||
@@ -29,7 +29,6 @@ enable_self_startup: false
|
||||
enable_system_proxy: false
|
||||
enable_proxy_guard: false
|
||||
proxy_guard_duration: 10
|
||||
system_proxy_bypass: localhost;127.*;10.*;192.168.*;<local>
|
||||
";
|
||||
|
||||
/// template for new a profile item
|
||||
@@ -60,7 +59,7 @@ append-proxy-groups:
|
||||
";
|
||||
|
||||
/// enhanced profile
|
||||
pub const ITEM_SCRIPT: &str = "// Should define the `main` function
|
||||
pub const ITEM_SCRIPT: &str = "// Define the `main` function
|
||||
// The argument to this function is the clash config
|
||||
// or the result of the previous handler
|
||||
// so you should return the config after processing
|
||||
|
||||
Reference in New Issue
Block a user