diff --git a/.gitignore b/.gitignore index d3537d9..6a6f9cd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ dist-ssr update.json scripts/_env.sh .vscode -.tool-versions \ No newline at end of file +.tool-versions +.idea diff --git a/src-tauri/src/cmds.rs b/src-tauri/src/cmds.rs index 5576ca8..899f495 100644 --- a/src-tauri/src/cmds.rs +++ b/src-tauri/src/cmds.rs @@ -12,6 +12,12 @@ use sysproxy::{Autoproxy, Sysproxy}; use tauri::{api, Manager}; type CmdResult = Result; +#[tauri::command] +pub fn copy_clash_env(app_handle: tauri::AppHandle) -> CmdResult { + feat::copy_clash_env(&app_handle); + Ok(()) +} + #[tauri::command] pub fn get_profiles() -> CmdResult { Ok(Config::profiles().data().clone()) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index fb11e44..cbdffce 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -64,6 +64,7 @@ fn main() -> std::io::Result<()> { cmds::get_runtime_exists, cmds::get_runtime_logs, cmds::uwp::invoke_uwp_tool, + cmds::copy_clash_env, // verge cmds::get_verge_config, cmds::patch_verge_config, diff --git a/src/components/setting/setting-verge.tsx b/src/components/setting/setting-verge.tsx index 73db3cf..77c45e5 100644 --- a/src/components/setting/setting-verge.tsx +++ b/src/components/setting/setting-verge.tsx @@ -1,13 +1,21 @@ -import { useRef } from "react"; +import { useCallback, useRef } from "react"; import { useTranslation } from "react-i18next"; import { open } from "@tauri-apps/api/dialog"; -import { Button, MenuItem, Select, Input, Typography } from "@mui/material"; +import { + Button, + MenuItem, + Select, + Input, + Typography, + Box, +} from "@mui/material"; import { exitApp, openAppDir, openCoreDir, openLogsDir, openDevTools, + copyClashEnv, } from "@/services/cmds"; import { checkUpdate } from "@tauri-apps/api/updater"; import { useVerge } from "@/hooks/use-verge"; @@ -24,6 +32,8 @@ import { LayoutViewer } from "./mods/layout-viewer"; import { UpdateViewer } from "./mods/update-viewer"; import getSystem from "@/utils/get-system"; import { routers } from "@/pages/_routers"; +import { TooltipIcon } from "@/components/base/base-tooltip-icon"; +import { ContentCopyRounded } from "@mui/icons-material"; interface Props { onError?: (err: Error) => void; @@ -67,6 +77,11 @@ const SettingVerge = ({ onError }: Props) => { } }; + const onCopyClashEnv = useCallback(async () => { + await copyClashEnv(); + Notice.success(t("Copy Success"), 1000); + }, []); + return ( @@ -123,7 +138,12 @@ const SettingVerge = ({ onError }: Props) => { )} - + + } + > ("copy_clash_env"); +} + export async function getClashLogs() { const regex = /time="(.+?)"\s+level=(.+?)\s+msg="(.+?)"/; const newRegex = /(.+?)\s+(.+?)\s+(.+)/;