feat: support to open core dir

This commit is contained in:
GyDi 2022-12-13 00:44:24 +08:00
parent d93b00cd15
commit 5c5177ec57
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A
6 changed files with 29 additions and 2 deletions

View File

@ -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())?;

View File

@ -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

View File

@ -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";
@ -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>
@ -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"

View File

@ -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",

View File

@ -82,6 +82,7 @@
"Traffic Graph": "流量图显",
"Language": "语言设置",
"Open App Dir": "应用目录",
"Open Core Dir": "内核目录",
"Open Logs Dir": "日志目录",
"Verge Version": "应用版本",
"theme.light": "浅色",

View File

@ -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)