Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
f726e8a7
There was an error fetching the commit references. Please try again later.
Unverified
Commit
f726e8a7
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: supports change config dir
parent
2f284cfd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src-tauri/src/main.rs
+6
-1
6 additions, 1 deletion
src-tauri/src/main.rs
src-tauri/src/utils/dirs.rs
+34
-5
34 additions, 5 deletions
src-tauri/src/utils/dirs.rs
with
40 additions
and
6 deletions
src-tauri/src/main.rs
+
6
−
1
View file @
f726e8a7
...
...
@@ -10,7 +10,7 @@ mod utils;
use
crate
::{
core
::
VergeConfig
,
utils
::{
resolve
,
server
},
utils
::{
dirs
,
resolve
,
server
},
};
use
tauri
::{
api
,
CustomMenuItem
,
Manager
,
SystemTray
,
SystemTrayEvent
,
SystemTrayMenu
,
SystemTrayMenuItem
,
...
...
@@ -22,6 +22,11 @@ fn main() -> std::io::Result<()> {
return
Ok
(());
}
#[cfg(target_os
=
"windows"
)]
unsafe
{
dirs
::
init_portable_flag
();
}
let
tray_menu
=
SystemTrayMenu
::
new
()
.add_item
(
CustomMenuItem
::
new
(
"open_window"
,
"Show"
))
.add_item
(
CustomMenuItem
::
new
(
"system_proxy"
,
"System Proxy"
))
...
...
This diff is collapsed.
Click to expand it.
src-tauri/src/utils/dirs.rs
+
34
−
5
View file @
f726e8a7
use
std
::
env
::
temp_dir
;
use
std
::
path
::{
Path
,
PathBuf
};
use
std
::
path
::
PathBuf
;
use
tauri
::
utils
::
platform
::
current_exe
;
use
tauri
::{
api
::
path
::{
home_dir
,
resource_dir
},
Env
,
PackageInfo
,
...
...
@@ -15,12 +16,40 @@ static VERGE_CONFIG: &str = "verge.yaml";
static
PROFILE_YAML
:
&
str
=
"profiles.yaml"
;
static
PROFILE_TEMP
:
&
str
=
"clash-verge-runtime.yaml"
;
/// portable flag
#[allow(unused)]
static
mut
PORTABLE_FLAG
:
bool
=
false
;
/// initialize portable flag
pub
unsafe
fn
init_portable_flag
()
{
#[cfg(target_os
=
"windows"
)]
{
let
exe
=
current_exe
()
.unwrap
();
let
dir
=
exe
.parent
()
.unwrap
();
let
dir
=
PathBuf
::
from
(
dir
)
.join
(
".config/PORTABLE"
);
if
dir
.exists
()
{
PORTABLE_FLAG
=
true
;
}
}
}
/// get the verge app home dir
pub
fn
app_home_dir
()
->
PathBuf
{
home_dir
()
.unwrap
()
.join
(
Path
::
new
(
".config"
))
.join
(
Path
::
new
(
APP_DIR
))
#[cfg(target_os
=
"windows"
)]
unsafe
{
if
!
PORTABLE_FLAG
{
home_dir
()
.unwrap
()
.join
(
".config"
)
.join
(
APP_DIR
)
}
else
{
let
app_exe
=
current_exe
()
.unwrap
();
let
app_exe
=
dunce
::
canonicalize
(
app_exe
)
.unwrap
();
let
app_dir
=
app_exe
.parent
()
.unwrap
();
PathBuf
::
from
(
app_dir
)
.join
(
".config"
)
.join
(
APP_DIR
)
}
}
#[cfg(not(target_os
=
"windows"
))]
home_dir
()
.unwrap
()
.join
(
".config"
)
.join
(
APP_DIR
)
}
/// get the resources dir
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment