mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 08:45:41 +08:00
- Added WindowControls component for managing window actions (minimize, maximize, close) based on the operating system. - Integrated window decoration toggle functionality to allow users to prefer system titlebar. - Updated layout styles to accommodate new titlebar and window controls. - Refactored layout components to utilize new window management hooks. - Enhanced layout viewer to include a switch for enabling/disabling window decorations. - Improved overall window management by introducing useWindow and useWindowDecorations hooks for better state handling.
161 lines
4.5 KiB
TypeScript
161 lines
4.5 KiB
TypeScript
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<DialogRef>(null);
|
|
const hotkeyRef = useRef<DialogRef>(null);
|
|
const miscRef = useRef<DialogRef>(null);
|
|
const themeRef = useRef<DialogRef>(null);
|
|
const layoutRef = useRef<DialogRef>(null);
|
|
const updateRef = useRef<DialogRef>(null);
|
|
const backupRef = useRef<DialogRef>(null);
|
|
const liteModeRef = useRef<DialogRef>(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 (
|
|
<SettingList title={t("Verge Advanced Setting")}>
|
|
<ThemeViewer ref={themeRef} />
|
|
<ConfigViewer ref={configRef} />
|
|
<HotkeyViewer ref={hotkeyRef} />
|
|
<MiscViewer ref={miscRef} />
|
|
<LayoutViewer ref={layoutRef} />
|
|
<UpdateViewer ref={updateRef} />
|
|
<BackupViewer ref={backupRef} />
|
|
<LiteModeViewer ref={liteModeRef} />
|
|
|
|
<SettingItem
|
|
onClick={() => backupRef.current?.open()}
|
|
label={t("Backup Setting")}
|
|
extra={
|
|
<TooltipIcon
|
|
title={t("Backup Setting Info")}
|
|
sx={{ opacity: "0.7" }}
|
|
/>
|
|
}
|
|
/>
|
|
|
|
<SettingItem
|
|
onClick={() => configRef.current?.open()}
|
|
label={t("Runtime Config")}
|
|
/>
|
|
|
|
<SettingItem
|
|
onClick={openAppDir}
|
|
label={t("Open Conf Dir")}
|
|
extra={
|
|
<TooltipIcon
|
|
title={t("Open Conf Dir Info")}
|
|
sx={{ opacity: "0.7" }}
|
|
/>
|
|
}
|
|
/>
|
|
|
|
<SettingItem onClick={openCoreDir} label={t("Open Core Dir")} />
|
|
|
|
<SettingItem onClick={openLogsDir} label={t("Open Logs Dir")} />
|
|
|
|
<SettingItem onClick={onCheckUpdate} label={t("Check for Updates")} />
|
|
|
|
<SettingItem onClick={openDevTools} label={t("Open Dev Tools")} />
|
|
|
|
<SettingItem
|
|
label={t("LightWeight Mode Settings")}
|
|
extra={
|
|
<TooltipIcon
|
|
title={t("LightWeight Mode Info")}
|
|
sx={{ opacity: "0.7" }}
|
|
/>
|
|
}
|
|
onClick={() => liteModeRef.current?.open()}
|
|
/>
|
|
|
|
<SettingItem
|
|
onClick={() => {
|
|
exitApp();
|
|
}}
|
|
label={t("Exit")}
|
|
/>
|
|
|
|
<SettingItem
|
|
label={t("Export Diagnostic Info")}
|
|
extra={
|
|
<TooltipIcon
|
|
icon={ContentCopyRounded}
|
|
onClick={onExportDiagnosticInfo}
|
|
/>
|
|
}
|
|
></SettingItem>
|
|
|
|
<SettingItem
|
|
label={t("Verge Version")}
|
|
extra={
|
|
<TooltipIcon
|
|
icon={ContentCopyRounded}
|
|
onClick={copyVersion}
|
|
title={t("Copy Version")}
|
|
/>
|
|
}
|
|
>
|
|
<Typography sx={{ py: "7px", pr: 1 }}>v{version}</Typography>
|
|
</SettingItem>
|
|
</SettingList>
|
|
);
|
|
};
|
|
|
|
export default SettingVergeAdvanced;
|