From 1f422afe3d3da7da43c91dc8c9367ca803f68d09 Mon Sep 17 00:00:00 2001 From: dongchengjie <37543964+dongchengjie@users.noreply.github.com> Date: Wed, 26 Jun 2024 05:33:06 +0800 Subject: [PATCH] chore: tooltips and locales --- src/components/base/base-empty.tsx | 4 ++- src/components/layout/layout-traffic.tsx | 26 ++++++++++++++----- src/components/profile/confirm-viewer.tsx | 2 +- src/components/profile/editor-viewer.tsx | 6 ++--- src/components/profile/log-viewer.tsx | 2 +- src/components/proxy/provider-button.tsx | 2 +- src/components/proxy/proxy-groups.tsx | 4 ++- src/components/rule/provider-button.tsx | 2 +- .../setting/mods/clash-core-viewer.tsx | 19 +++++++++----- src/components/setting/mods/layout-viewer.tsx | 2 +- .../setting/mods/sysproxy-viewer.tsx | 6 ++++- src/components/setting/mods/web-ui-viewer.tsx | 3 +-- src/components/setting/setting-clash.tsx | 20 ++++++++++++-- src/components/setting/setting-system.tsx | 16 +++++++++++- src/locales/en.json | 5 ++++ src/locales/fa.json | 5 ++++ src/locales/ru.json | 5 ++++ src/locales/zh.json | 5 ++++ src/pages/connections.tsx | 2 +- src/pages/logs.tsx | 2 +- src/pages/rules.tsx | 2 +- 21 files changed, 108 insertions(+), 32 deletions(-) diff --git a/src/components/base/base-empty.tsx b/src/components/base/base-empty.tsx index c364a50a..665c12c5 100644 --- a/src/components/base/base-empty.tsx +++ b/src/components/base/base-empty.tsx @@ -1,5 +1,6 @@ import { alpha, Box, Typography } from "@mui/material"; import { InboxRounded } from "@mui/icons-material"; +import { useTranslation } from "react-i18next"; interface Props { text?: React.ReactNode; @@ -8,6 +9,7 @@ interface Props { export const BaseEmpty = (props: Props) => { const { text = "Empty", extra } = props; + const { t } = useTranslation(); return ( { })} > - {text} + {t(`${text}`)} {extra} ); diff --git a/src/components/layout/layout-traffic.tsx b/src/components/layout/layout-traffic.tsx index 747a0392..5f2d9b8a 100644 --- a/src/components/layout/layout-traffic.tsx +++ b/src/components/layout/layout-traffic.tsx @@ -13,6 +13,7 @@ import { useVisibility } from "@/hooks/use-visibility"; import parseTraffic from "@/utils/parse-traffic"; import useSWRSubscription from "swr/subscription"; import { createSockette } from "@/utils/websocket"; +import { useTranslation } from "react-i18next"; interface MemoryUsage { inuse: number; @@ -21,6 +22,7 @@ interface MemoryUsage { // setup the traffic export const LayoutTraffic = () => { + const { t } = useTranslation(); const { clashInfo } = useClashInfo(); const { verge } = useVerge(); @@ -115,7 +117,6 @@ export const LayoutTraffic = () => { }; const valStyle: any = { component: "span", - // color: "primary", textAlign: "center", sx: { flex: "1 1 56px", userSelect: "none" }, }; @@ -128,15 +129,23 @@ export const LayoutTraffic = () => { }; return ( - + {trafficGraph && pageVisible && ( -
+
)} - + 0 ? "secondary" : "disabled"} @@ -147,7 +156,12 @@ export const LayoutTraffic = () => { {upUnit}/s - + 0 ? "primary" : "disabled"} @@ -163,7 +177,7 @@ export const LayoutTraffic = () => { display="flex" alignItems="center" whiteSpace="nowrap" - title="Memory Usage" + title={t("Memory Usage")} > {inuse} diff --git a/src/components/profile/confirm-viewer.tsx b/src/components/profile/confirm-viewer.tsx index 2ed293e6..382998b9 100644 --- a/src/components/profile/confirm-viewer.tsx +++ b/src/components/profile/confirm-viewer.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from "react"; +import { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { Button, diff --git a/src/components/profile/editor-viewer.tsx b/src/components/profile/editor-viewer.tsx index 1bfbb806..c64010f8 100644 --- a/src/components/profile/editor-viewer.tsx +++ b/src/components/profile/editor-viewer.tsx @@ -171,10 +171,10 @@ export const EditorViewer = (props: Props) => { - - {readOnly ? null : ( + {!readOnly && ( diff --git a/src/components/profile/log-viewer.tsx b/src/components/profile/log-viewer.tsx index 47924683..f36f2b4c 100644 --- a/src/components/profile/log-viewer.tsx +++ b/src/components/profile/log-viewer.tsx @@ -61,7 +61,7 @@ export const LogViewer = (props: Props) => { diff --git a/src/components/proxy/provider-button.tsx b/src/components/proxy/provider-button.tsx index 1d2e15d9..56dac715 100644 --- a/src/components/proxy/provider-button.tsx +++ b/src/components/proxy/provider-button.tsx @@ -94,7 +94,7 @@ export const ProviderButton = () => { } contentSx={{ width: 400 }} disableOk - cancelBtn={t("Cancel")} + cancelBtn={t("Close")} onClose={() => setOpen(false)} onCancel={() => setOpen(false)} > diff --git a/src/components/proxy/proxy-groups.tsx b/src/components/proxy/proxy-groups.tsx index 26e5ac00..bbe550a6 100644 --- a/src/components/proxy/proxy-groups.tsx +++ b/src/components/proxy/proxy-groups.tsx @@ -14,12 +14,14 @@ import { BaseEmpty } from "../base"; import { useRenderList } from "./use-render-list"; import { ProxyRender } from "./proxy-render"; import delayManager from "@/services/delay"; +import { useTranslation } from "react-i18next"; interface Props { mode: string; } export const ProxyGroups = (props: Props) => { + const { t } = useTranslation(); const { mode } = props; const { renderList, onProxies, onHeadState } = useRenderList(mode); @@ -116,7 +118,7 @@ export const ProxyGroups = (props: Props) => { }; if (mode === "direct") { - return ; + return ; } return ( diff --git a/src/components/rule/provider-button.tsx b/src/components/rule/provider-button.tsx index 733fef37..66812053 100644 --- a/src/components/rule/provider-button.tsx +++ b/src/components/rule/provider-button.tsx @@ -92,7 +92,7 @@ export const ProviderButton = () => { } contentSx={{ width: 400 }} disableOk - cancelBtn={t("Cancel")} + cancelBtn={t("Close")} onClose={() => setOpen(false)} onCancel={() => setOpen(false)} > diff --git a/src/components/setting/mods/clash-core-viewer.tsx b/src/components/setting/mods/clash-core-viewer.tsx index 3c7a9aae..ee52c7ed 100644 --- a/src/components/setting/mods/clash-core-viewer.tsx +++ b/src/components/setting/mods/clash-core-viewer.tsx @@ -6,18 +6,22 @@ import { useVerge } from "@/hooks/use-verge"; import { useLockFn } from "ahooks"; import { LoadingButton } from "@mui/lab"; import { SwitchAccessShortcut, RestartAlt } from "@mui/icons-material"; -import { Box, Button, List, ListItemButton, ListItemText } from "@mui/material"; +import { + Box, + Button, + Chip, + List, + ListItemButton, + ListItemText, +} from "@mui/material"; import { changeClashCore, restartSidecar } from "@/services/cmds"; import { closeAllConnections, upgradeCore } from "@/services/api"; -import getSystem from "@/utils/get-system"; const VALID_CORE = [ - { name: "Mihomo", core: "verge-mihomo" }, - { name: "Mihomo Alpha", core: "verge-mihomo-alpha" }, + { name: "Mihomo", core: "verge-mihomo", chip: "Release Version" }, + { name: "Mihomo Alpha", core: "verge-mihomo-alpha", chip: "Alpha Version" }, ]; -const OS = getSystem(); - export const ClashCoreViewer = forwardRef((props, ref) => { const { t } = useTranslation(); @@ -109,7 +113,7 @@ export const ClashCoreViewer = forwardRef((props, ref) => { marginTop: "-8px", }} disableOk - cancelBtn={t("Back")} + cancelBtn={t("Close")} onClose={() => setOpen(false)} onCancel={() => setOpen(false)} > @@ -121,6 +125,7 @@ export const ClashCoreViewer = forwardRef((props, ref) => { onClick={() => onCoreChange(each.core)} > + ))} diff --git a/src/components/setting/mods/layout-viewer.tsx b/src/components/setting/mods/layout-viewer.tsx index 3f68689e..a77e4546 100644 --- a/src/components/setting/mods/layout-viewer.tsx +++ b/src/components/setting/mods/layout-viewer.tsx @@ -79,7 +79,7 @@ export const LayoutViewer = forwardRef((props, ref) => { title={t("Layout Setting")} contentSx={{ width: 450 }} disableOk - cancelBtn={t("Cancel")} + cancelBtn={t("Close")} onClose={() => setOpen(false)} onCancel={() => setOpen(false)} > diff --git a/src/components/setting/mods/sysproxy-viewer.tsx b/src/components/setting/mods/sysproxy-viewer.tsx index c5ecea44..de3c7f0c 100644 --- a/src/components/setting/mods/sysproxy-viewer.tsx +++ b/src/components/setting/mods/sysproxy-viewer.tsx @@ -166,7 +166,10 @@ export const SysproxyViewer = forwardRef((props, ref) => { - + ((props, ref) => { disabled={!enabled} checked={value.guard} onChange={(_, e) => setValue((v) => ({ ...v, guard: e }))} + sx={{ marginLeft: "auto" }} /> diff --git a/src/components/setting/mods/web-ui-viewer.tsx b/src/components/setting/mods/web-ui-viewer.tsx index a885e515..afdb3879 100644 --- a/src/components/setting/mods/web-ui-viewer.tsx +++ b/src/components/setting/mods/web-ui-viewer.tsx @@ -98,14 +98,13 @@ export const WebUIViewer = forwardRef((props, ref) => { overflowY: "auto", userSelect: "text", }} - cancelBtn={t("Back")} + cancelBtn={t("Close")} disableOk onClose={() => setOpen(false)} onCancel={() => setOpen(false)} > {!editing && webUIList.length === 0 && ( {t("Replace host, port, secret with %host, %port, %secret")} diff --git a/src/components/setting/setting-clash.tsx b/src/components/setting/setting-clash.tsx index 41657cc5..3cc59588 100644 --- a/src/components/setting/setting-clash.tsx +++ b/src/components/setting/setting-clash.tsx @@ -9,7 +9,8 @@ import { IconButton, Tooltip, } from "@mui/material"; -import { Settings, Shuffle } from "@mui/icons-material"; + +import { InfoRounded, Settings, Shuffle } from "@mui/icons-material"; import { DialogRef, Notice, Switch } from "@/components/base"; import { useClash } from "@/hooks/use-clash"; import { GuardState } from "./mods/guard-state"; @@ -175,7 +176,22 @@ const SettingClash = ({ onError }: Props) => { {isWIN && ( - + + + + + + + + } + /> )} diff --git a/src/components/setting/setting-system.tsx b/src/components/setting/setting-system.tsx index 5cba3f68..433f3bb8 100644 --- a/src/components/setting/setting-system.tsx +++ b/src/components/setting/setting-system.tsx @@ -170,7 +170,21 @@ const SettingSystem = ({ onError }: Props) => { - + + + + + + + + } + > { }} > {filterConn.length === 0 ? ( - + ) : isTableLayout ? ( { followOutput={"smooth"} /> ) : ( - + )} diff --git a/src/pages/rules.tsx b/src/pages/rules.tsx index 662c626e..130901bc 100644 --- a/src/pages/rules.tsx +++ b/src/pages/rules.tsx @@ -62,7 +62,7 @@ const RulesPage = () => { followOutput={"smooth"} /> ) : ( - + )}