import { ContentCopyRounded } from "@mui/icons-material"; import { Typography } from "@mui/material"; import { check as checkUpdate } from "@tauri-apps/plugin-updater"; import { useCallback, useRef } from "react"; import { useTranslation } from "react-i18next"; import { DialogRef } from "@/components/base"; import { TooltipIcon } from "@/components/base/base-tooltip-icon"; import { exitApp, exportDiagnosticInfo, openAppDir, openCoreDir, openDevTools, openLogsDir, } from "@/services/cmds"; import { showNotice } from "@/services/noticeService"; import { version } from "@root/package.json"; import { BackupViewer } from "./mods/backup-viewer"; import { ConfigViewer } from "./mods/config-viewer"; import { HotkeyViewer } from "./mods/hotkey-viewer"; import { LayoutViewer } from "./mods/layout-viewer"; import { LiteModeViewer } from "./mods/lite-mode-viewer"; import { MiscViewer } from "./mods/misc-viewer"; import { SettingItem, SettingList } from "./mods/setting-comp"; import { ThemeViewer } from "./mods/theme-viewer"; import { UpdateViewer } from "./mods/update-viewer"; interface Props { onError?: (err: Error) => void; } const SettingVergeAdvanced = ({ onError: _ }: Props) => { const { t } = useTranslation(); const configRef = useRef(null); const hotkeyRef = useRef(null); const miscRef = useRef(null); const themeRef = useRef(null); const layoutRef = useRef(null); const updateRef = useRef(null); const backupRef = useRef(null); const liteModeRef = useRef(null); const onCheckUpdate = async () => { try { const info = await checkUpdate(); if (!info?.available) { showNotice("success", t("Currently on the Latest Version")); } else { updateRef.current?.open(); } } catch (err: any) { showNotice("error", err.message || err.toString()); } }; const onExportDiagnosticInfo = useCallback(async () => { await exportDiagnosticInfo(); showNotice("success", t("Copy Success"), 1000); }, [t]); const copyVersion = useCallback(() => { navigator.clipboard.writeText(`v${version}`).then(() => { showNotice("success", t("Version copied to clipboard"), 1000); }); }, [t]); return ( backupRef.current?.open()} label={t("Backup Setting")} extra={ } /> configRef.current?.open()} label={t("Runtime Config")} /> } /> } onClick={() => liteModeRef.current?.open()} /> { exitApp(); }} label={t("Exit")} /> } > } > v{version} ); }; export default SettingVergeAdvanced;