chore: resolve deprecation warnings and add missing translations

This commit is contained in:
wonfen
2025-10-06 23:39:56 +08:00
parent abb0df59df
commit c6afbf6ee8
7 changed files with 18 additions and 23 deletions

View File

@@ -20,8 +20,6 @@ import getSystem from "@/utils/get-system";
const OS = getSystem();
interface ClashPortViewerProps {}
interface ClashPortViewerRef {
open: () => void;
close: () => void;
@@ -30,10 +28,7 @@ interface ClashPortViewerRef {
const generateRandomPort = () =>
Math.floor(Math.random() * (65535 - 1025 + 1)) + 1025;
export const ClashPortViewer = forwardRef<
ClashPortViewerRef,
ClashPortViewerProps
>((props, ref) => {
export const ClashPortViewer = forwardRef<ClashPortViewerRef>((_, ref) => {
const { t } = useTranslation();
const { clashInfo, patchInfo } = useClashInfo();
const { verge, patchVerge } = useVerge();
@@ -74,10 +69,10 @@ export const ClashPortViewer = forwardRef<
manual: true,
onSuccess: () => {
setOpen(false);
showNotice("success", t("Port settings saved")); // 调用提示函数
showNotice("success", t("Port settings saved"));
},
onError: () => {
showNotice("error", t("Failed to save settings")); // 调用提示函数
showNotice("error", t("Failed to save port settings"));
},
},
);
@@ -154,7 +149,7 @@ export const ClashPortViewer = forwardRef<
return (
<BaseDialog
open={open}
title={t("Port Configuration")}
title={t("Port Config")}
contentSx={{
width: 400,
}}
@@ -177,7 +172,7 @@ export const ClashPortViewer = forwardRef<
<ListItem sx={{ padding: "4px 0", minHeight: 36 }}>
<ListItemText
primary={t("Mixed Port")}
primaryTypographyProps={{ fontSize: 12 }}
slotProps={{ primary: { sx: { fontSize: 12 } } }}
/>
<div style={{ display: "flex", alignItems: "center" }}>
<TextField
@@ -187,7 +182,7 @@ export const ClashPortViewer = forwardRef<
onChange={(e) =>
setMixedPort(+e.target.value?.replace(/\D+/, "").slice(0, 5))
}
inputProps={{ style: { fontSize: 12 } }}
slotProps={{ htmlInput: { style: { fontSize: 12 } } }}
/>
<IconButton
size="small"
@@ -209,7 +204,7 @@ export const ClashPortViewer = forwardRef<
<ListItem sx={{ padding: "4px 0", minHeight: 36 }}>
<ListItemText
primary={t("Socks Port")}
primaryTypographyProps={{ fontSize: 12 }}
slotProps={{ primary: { sx: { fontSize: 12 } } }}
/>
<div style={{ display: "flex", alignItems: "center" }}>
<TextField
@@ -220,7 +215,7 @@ export const ClashPortViewer = forwardRef<
setSocksPort(+e.target.value?.replace(/\D+/, "").slice(0, 5))
}
disabled={!socksEnabled}
inputProps={{ style: { fontSize: 12 } }}
slotProps={{ htmlInput: { style: { fontSize: 12 } } }}
/>
<IconButton
size="small"
@@ -243,7 +238,7 @@ export const ClashPortViewer = forwardRef<
<ListItem sx={{ padding: "4px 0", minHeight: 36 }}>
<ListItemText
primary={t("Http Port")}
primaryTypographyProps={{ fontSize: 12 }}
slotProps={{ primary: { sx: { fontSize: 12 } } }}
/>
<div style={{ display: "flex", alignItems: "center" }}>
<TextField
@@ -254,7 +249,7 @@ export const ClashPortViewer = forwardRef<
setHttpPort(+e.target.value?.replace(/\D+/, "").slice(0, 5))
}
disabled={!httpEnabled}
inputProps={{ style: { fontSize: 12 } }}
slotProps={{ htmlInput: { style: { fontSize: 12 } } }}
/>
<IconButton
size="small"
@@ -278,7 +273,7 @@ export const ClashPortViewer = forwardRef<
<ListItem sx={{ padding: "4px 0", minHeight: 36 }}>
<ListItemText
primary={t("Redir Port")}
primaryTypographyProps={{ fontSize: 12 }}
slotProps={{ primary: { sx: { fontSize: 12 } } }}
/>
<div style={{ display: "flex", alignItems: "center" }}>
<TextField
@@ -289,7 +284,7 @@ export const ClashPortViewer = forwardRef<
setRedirPort(+e.target.value?.replace(/\D+/, "").slice(0, 5))
}
disabled={!redirEnabled}
inputProps={{ style: { fontSize: 12 } }}
slotProps={{ htmlInput: { style: { fontSize: 12 } } }}
/>
<IconButton
size="small"
@@ -314,7 +309,7 @@ export const ClashPortViewer = forwardRef<
<ListItem sx={{ padding: "4px 0", minHeight: 36 }}>
<ListItemText
primary={t("Tproxy Port")}
primaryTypographyProps={{ fontSize: 12 }}
slotProps={{ primary: { sx: { fontSize: 12 } } }}
/>
<div style={{ display: "flex", alignItems: "center" }}>
<TextField
@@ -325,7 +320,7 @@ export const ClashPortViewer = forwardRef<
setTproxyPort(+e.target.value?.replace(/\D+/, "").slice(0, 5))
}
disabled={!tproxyEnabled}
inputProps={{ style: { fontSize: 12 } }}
slotProps={{ htmlInput: { style: { fontSize: 12 } } }}
/>
<IconButton
size="small"