From 201bd349f207a56a77f44480a17a8b2bab0034ab Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Tue, 18 Jul 2023 14:01:38 +0800 Subject: [PATCH] feat: platform util --- src/routes/chat/Layout/index.tsx | 4 +++- src/routes/setting/DataManagement/index.tsx | 13 ++++++++----- src/utils.tsx | 11 +++++++++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/routes/chat/Layout/index.tsx b/src/routes/chat/Layout/index.tsx index 41475c6e..b997c28a 100644 --- a/src/routes/chat/Layout/index.tsx +++ b/src/routes/chat/Layout/index.tsx @@ -18,6 +18,7 @@ import LicenseUpgradeTip from "./LicenseOutdatedTip"; import LoginTip from "./LoginTip"; import Operations from "./Operations"; import VirtualMessageFeed from "./VirtualMessageFeed"; +import { platform } from "@/utils"; interface Props { readonly?: boolean; @@ -125,7 +126,8 @@ const Layout: FC = ({ {aside && (
{aside} diff --git a/src/routes/setting/DataManagement/index.tsx b/src/routes/setting/DataManagement/index.tsx index f22e85d5..390faa30 100644 --- a/src/routes/setting/DataManagement/index.tsx +++ b/src/routes/setting/DataManagement/index.tsx @@ -7,6 +7,7 @@ import SettingBlock from "@/components/SettingBlock"; import StyledButton from "@/components/styled/Button"; import AutoDeleteFiles from "./AutoDeleteFiles"; import ClearConfirmModal from "./ClearConfirmModal"; +import ServerVersionChecker from "@/components/ServerVersionChecker"; export type VisibleModalType = "chat" | "files"; export default function DataManagement() { @@ -22,11 +23,13 @@ export default function DataManagement() { return (
{/* 清除服务器聊天消息 */} - - - {t("data.clear_msgs.btn")} - - + + + + {t("data.clear_msgs.btn")} + + + {/* 清除服务器文件 */} diff --git a/src/utils.tsx b/src/utils.tsx index d0b61729..c0e1043f 100644 --- a/src/utils.tsx +++ b/src/utils.tsx @@ -384,6 +384,17 @@ export const isDarkMode = () => { const isLightMode = localStorage.theme === "light"; return isDarkMode || (!isLightMode && window.matchMedia("(prefers-color-scheme: dark)").matches); }; +export const platform = () => { + const ua = navigator.userAgent.toLowerCase(); + const isMac = ua.indexOf("darwin") != -1; + const isWindows = ua.indexOf("win32") != -1; + const isLinux = ua.indexOf("linux") != -1; + return { + isMac, + isWindows, + isLinux + }; +}; export const fromNowTime = (ts?: number) => { if (!ts) return null;