Skip to content

Commit

Permalink
feat: support to open core dir
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzgydi committed Dec 12, 2022
1 parent d93b00c commit 5c5177e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src-tauri/src/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ pub fn open_app_dir() -> CmdResult<()> {
wrap_err!(open::that(app_dir))
}

#[tauri::command]
pub fn open_core_dir() -> CmdResult<()> {
let core_dir = wrap_err!(tauri::utils::platform::current_exe())?;
let core_dir = core_dir.parent().ok_or(format!("failed to get core dir"))?;
wrap_err!(open::that(core_dir))
}

#[tauri::command]
pub fn open_logs_dir() -> CmdResult<()> {
let log_dir = wrap_err!(dirs::app_logs_dir())?;
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn main() -> std::io::Result<()> {
cmds::open_app_dir,
cmds::open_logs_dir,
cmds::open_web_url,
cmds::open_core_dir,
// cmds::kill_sidecar,
cmds::restart_sidecar,
// clash
Expand Down
15 changes: 13 additions & 2 deletions src/components/setting/setting-verge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Switch,
Typography,
} from "@mui/material";
import { openAppDir, openLogsDir, patchVergeConfig } from "@/services/cmds";
import { openAppDir, openCoreDir, openLogsDir } from "@/services/cmds";
import { ArrowForward } from "@mui/icons-material";
import { useVerge } from "@/hooks/use-verge";
import { version } from "@root/package.json";
Expand Down Expand Up @@ -94,7 +94,7 @@ const SettingVerge = ({ onError }: Props) => {
onCatch={onError}
onFormat={onSwitchFormat}
onChange={(e) => onChangeData({ traffic_graph: e })}
onGuard={(e) => patchVergeConfig({ traffic_graph: e })}
onGuard={(e) => patchVerge({ traffic_graph: e })}
>
<Switch edge="end" />
</GuardState>
Expand Down Expand Up @@ -155,6 +155,17 @@ const SettingVerge = ({ onError }: Props) => {
</IconButton>
</SettingItem>

<SettingItem label={t("Open Core Dir")}>
<IconButton
color="inherit"
size="small"
sx={{ my: "2px" }}
onClick={openCoreDir}
>
<ArrowForward />
</IconButton>
</SettingItem>

<SettingItem label={t("Open Logs Dir")}>
<IconButton
color="inherit"
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"Traffic Graph": "Traffic Graph",
"Language": "Language",
"Open App Dir": "Open App Dir",
"Open Core Dir": "Open Core Dir",
"Open Logs Dir": "Open Logs Dir",
"Verge Version": "Verge Version",
"theme.light": "Light",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"Traffic Graph": "流量图显",
"Language": "语言设置",
"Open App Dir": "应用目录",
"Open Core Dir": "内核目录",
"Open Logs Dir": "日志目录",
"Verge Version": "应用版本",
"theme.light": "浅色",
Expand Down
6 changes: 6 additions & 0 deletions src/services/cmds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ export async function openAppDir() {
);
}

export async function openCoreDir() {
return invoke<void>("open_core_dir").catch((err) =>
Notice.error(err?.message || err.toString(), 1500)
);
}

export async function openLogsDir() {
return invoke<void>("open_logs_dir").catch((err) =>
Notice.error(err?.message || err.toString(), 1500)
Expand Down

0 comments on commit 5c5177e

Please sign in to comment.