From a3e7626dd9bddbc1c6348ecef3a8f7387e01d565 Mon Sep 17 00:00:00 2001
From: GyDi <segydi@foxmail.com>
Date: Fri, 18 Mar 2022 10:59:35 +0800
Subject: [PATCH] chore: add dev feature

---
 src-tauri/Cargo.toml          |  1 +
 src-tauri/src/utils/dirs.rs   | 17 +++++++++++------
 src-tauri/src/utils/server.rs |  3 +++
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 271ae80..b118f47 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -40,3 +40,4 @@ winreg = { version = "0.10", features = ["transactions"] }
 [features]
 default = [ "custom-protocol" ]
 custom-protocol = [ "tauri/custom-protocol" ]
+verge-dev = []
diff --git a/src-tauri/src/utils/dirs.rs b/src-tauri/src/utils/dirs.rs
index 985939c..e905f30 100644
--- a/src-tauri/src/utils/dirs.rs
+++ b/src-tauri/src/utils/dirs.rs
@@ -5,12 +5,22 @@ use tauri::{
   Env, PackageInfo,
 };
 
+#[cfg(not(feature = "verge-dev"))]
+static APP_DIR: &str = "clash-verge";
+#[cfg(feature = "verge-dev")]
+static APP_DIR: &str = "clash-verge-dev";
+
+static CLASH_CONFIG: &str = "config.yaml";
+static VERGE_CONFIG: &str = "verge.yaml";
+static PROFILE_YAML: &str = "profiles.yaml";
+static PROFILE_TEMP: &str = "clash-verge-runtime.yaml";
+
 /// get the verge app home dir
 pub fn app_home_dir() -> PathBuf {
   home_dir()
     .unwrap()
     .join(Path::new(".config"))
-    .join(Path::new("clash-verge"))
+    .join(Path::new(APP_DIR))
 }
 
 /// get the resources dir
@@ -30,11 +40,6 @@ pub fn app_logs_dir() -> PathBuf {
   app_home_dir().join("logs")
 }
 
-static CLASH_CONFIG: &str = "config.yaml";
-static VERGE_CONFIG: &str = "verge.yaml";
-static PROFILE_YAML: &str = "profiles.yaml";
-static PROFILE_TEMP: &str = "clash-verge-runtime.yaml";
-
 pub fn clash_path() -> PathBuf {
   app_home_dir().join(CLASH_CONFIG)
 }
diff --git a/src-tauri/src/utils/server.rs b/src-tauri/src/utils/server.rs
index e930964..11bd262 100644
--- a/src-tauri/src/utils/server.rs
+++ b/src-tauri/src/utils/server.rs
@@ -4,7 +4,10 @@ use port_scanner::local_port_available;
 use tauri::{AppHandle, Manager};
 use warp::Filter;
 
+#[cfg(not(feature = "verge-dev"))]
 const SERVER_PORT: u16 = 33333;
+#[cfg(feature = "verge-dev")]
+const SERVER_PORT: u16 = 11233;
 
 /// check whether there is already exists
 pub fn check_singleton() -> Result<(), ()> {
-- 
GitLab