feat: add reset button

This commit is contained in:
MystiPanda 2024-02-22 00:19:45 +08:00
parent bd8f07c90a
commit ce8383b26f
No known key found for this signature in database
GPG Key ID: 47D0F0284DC57888
6 changed files with 50 additions and 11 deletions

View File

@ -32,7 +32,7 @@ impl IClashTemp {
pub fn template() -> Self { pub fn template() -> Self {
let mut map = Mapping::new(); let mut map = Mapping::new();
let mut tun = Mapping::new(); let mut tun = Mapping::new();
tun.insert("stack".into(), "gVisor".into()); tun.insert("stack".into(), "gvisor".into());
tun.insert("device".into(), "Meta".into()); tun.insert("device".into(), "Meta".into());
tun.insert("auto-route".into(), true.into()); tun.insert("auto-route".into(), true.into());
tun.insert("strict-route".into(), false.into()); tun.insert("strict-route".into(), false.into());

View File

@ -148,9 +148,6 @@ impl Sysopt {
/// init the auto launch /// init the auto launch
pub fn init_launch(&self) -> Result<()> { pub fn init_launch(&self) -> Result<()> {
let enable = { Config::verge().latest().enable_auto_launch };
let enable = enable.unwrap_or(false);
let app_exe = current_exe()?; let app_exe = current_exe()?;
let app_exe = dunce::canonicalize(app_exe)?; let app_exe = dunce::canonicalize(app_exe)?;
let app_name = app_exe let app_name = app_exe

View File

@ -55,6 +55,7 @@ export const ProviderButton = () => {
<Typography variant="h6">{t("Proxy Provider")}</Typography> <Typography variant="h6">{t("Proxy Provider")}</Typography>
<Button <Button
variant="contained" variant="contained"
size="small"
onClick={async () => { onClick={async () => {
Object.entries(data || {}).forEach(async ([key, item]) => { Object.entries(data || {}).forEach(async ([key, item]) => {
await proxyProviderUpdate(key); await proxyProviderUpdate(key);

View File

@ -53,6 +53,7 @@ export const ProviderButton = () => {
<Typography variant="h6">{t("Rule Provider")}</Typography> <Typography variant="h6">{t("Rule Provider")}</Typography>
<Button <Button
variant="contained" variant="contained"
size="small"
onClick={async () => { onClick={async () => {
Object.entries(data || {}).forEach(async ([key, item]) => { Object.entries(data || {}).forEach(async ([key, item]) => {
await ruleProviderUpdate(key); await ruleProviderUpdate(key);

View File

@ -5,8 +5,9 @@ import {
List, List,
ListItem, ListItem,
ListItemText, ListItemText,
MenuItem, Box,
Select, Typography,
Button,
Switch, Switch,
TextField, TextField,
} from "@mui/material"; } from "@mui/material";
@ -21,8 +22,8 @@ export const TunViewer = forwardRef<DialogRef>((props, ref) => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [values, setValues] = useState({ const [values, setValues] = useState({
stack: "gVisor", stack: "gvisor",
device: "Mihomo", device: "Meta",
autoRoute: true, autoRoute: true,
autoDetectInterface: true, autoDetectInterface: true,
dnsHijack: ["any:53"], dnsHijack: ["any:53"],
@ -34,8 +35,8 @@ export const TunViewer = forwardRef<DialogRef>((props, ref) => {
open: () => { open: () => {
setOpen(true); setOpen(true);
setValues({ setValues({
stack: clash?.tun.stack ?? "gVisor", stack: clash?.tun.stack ?? "gvisor",
device: clash?.tun.device ?? "Mihomo", device: clash?.tun.device ?? "Meta",
autoRoute: clash?.tun["auto-route"] ?? true, autoRoute: clash?.tun["auto-route"] ?? true,
autoDetectInterface: clash?.tun["auto-detect-interface"] ?? true, autoDetectInterface: clash?.tun["auto-detect-interface"] ?? true,
dnsHijack: clash?.tun["dns-hijack"] ?? ["any:53"], dnsHijack: clash?.tun["dns-hijack"] ?? ["any:53"],
@ -74,7 +75,45 @@ export const TunViewer = forwardRef<DialogRef>((props, ref) => {
return ( return (
<BaseDialog <BaseDialog
open={open} open={open}
title={t("Tun Mode")} title={
<Box display="flex" justifyContent="space-between" gap={1}>
<Typography variant="h6">{t("Tun Mode")}</Typography>
<Button
variant="outlined"
size="small"
onClick={async () => {
let tun = {
stack: "gvisor",
device: "Meta",
"auto-route": true,
"auto-detect-interface": true,
"dns-hijack": ["any:53"],
"strict-route": false,
mtu: 9000,
};
setValues({
stack: "gvisor",
device: "Meta",
autoRoute: true,
autoDetectInterface: true,
dnsHijack: ["any:53"],
strictRoute: false,
mtu: 9000,
});
await patchClash({ tun });
await mutateClash(
(old) => ({
...(old! || {}),
tun,
}),
false
);
}}
>
{t("Reset to Default")}
</Button>
</Box>
}
contentSx={{ width: 450 }} contentSx={{ width: 450 }}
okBtn={t("Save")} okBtn={t("Save")}
cancelBtn={t("Cancel")} cancelBtn={t("Cancel")}

View File

@ -167,6 +167,7 @@
"Auto Detect Interface": "自动选择流量出口接口", "Auto Detect Interface": "自动选择流量出口接口",
"DNS Hijack": "DNS 劫持", "DNS Hijack": "DNS 劫持",
"MTU": "最大传输单元", "MTU": "最大传输单元",
"Reset to Default": "重置为默认值",
"Portable Updater Error": "便携版不支持应用内更新,请手动下载替换", "Portable Updater Error": "便携版不支持应用内更新,请手动下载替换",
"Tun Mode Info Windows": "Tun模式需要授予内核相关权限使用前请先开启服务模式", "Tun Mode Info Windows": "Tun模式需要授予内核相关权限使用前请先开启服务模式",