fix: adjust code

This commit is contained in:
GyDi 2022-04-14 01:29:02 +08:00
parent f4f1a0fbc6
commit 557abd4285
No known key found for this signature in database
GPG Key ID: 58B15242BA8277A6
2 changed files with 8 additions and 2 deletions
src-tauri/src

@ -10,7 +10,7 @@ mod utils;
use crate::{
core::VergeConfig,
utils::{dirs, resolve, server},
utils::{resolve, server},
};
use tauri::{
api, CustomMenuItem, Manager, SystemTray, SystemTrayEvent, SystemTrayMenu, SystemTrayMenuItem,
@ -24,6 +24,8 @@ fn main() -> std::io::Result<()> {
#[cfg(target_os = "windows")]
unsafe {
use crate::utils::dirs;
dirs::init_portable_flag();
}

@ -1,6 +1,5 @@
use std::env::temp_dir;
use std::path::PathBuf;
use tauri::utils::platform::current_exe;
use tauri::{
api::path::{home_dir, resource_dir},
Env, PackageInfo,
@ -21,9 +20,12 @@ static PROFILE_TEMP: &str = "clash-verge-runtime.yaml";
static mut PORTABLE_FLAG: bool = false;
/// initialize portable flag
#[allow(unused)]
pub unsafe fn init_portable_flag() {
#[cfg(target_os = "windows")]
{
use tauri::utils::platform::current_exe;
let exe = current_exe().unwrap();
let dir = exe.parent().unwrap();
let dir = PathBuf::from(dir).join(".config/PORTABLE");
@ -38,6 +40,8 @@ pub unsafe fn init_portable_flag() {
pub fn app_home_dir() -> PathBuf {
#[cfg(target_os = "windows")]
unsafe {
use tauri::utils::platform::current_exe;
if !PORTABLE_FLAG {
home_dir().unwrap().join(".config").join(APP_DIR)
} else {