feat(ui): browser happy detecting

This commit is contained in:
Fu Diwei 2025-05-15 02:20:09 +08:00
parent e55e6cc512
commit 268ec4bd7f
5 changed files with 22 additions and 2 deletions

View File

@ -12,6 +12,7 @@
"common.text.copied": "Copied", "common.text.copied": "Copied",
"common.text.import_from_file": "Import from file ...", "common.text.import_from_file": "Import from file ...",
"common.text.happy_browser": "The browser version is too low, and Certimate WebUI is not working well. Recommend using modern browsers such as Google Chrome v119.0 or higher.",
"common.text.nodata": "No data available", "common.text.nodata": "No data available",
"common.text.operation_confirm": "Operation confirm", "common.text.operation_confirm": "Operation confirm",
"common.text.operation_succeeded": "Operation succeeded", "common.text.operation_succeeded": "Operation succeeded",

View File

@ -12,6 +12,7 @@
"common.text.copied": "已复制", "common.text.copied": "已复制",
"common.text.import_from_file": "从文件导入 ……", "common.text.import_from_file": "从文件导入 ……",
"common.text.happy_browser": "当前浏览器版本过低Certimate WebUI 无法正常工作。推荐使用 Google Chrome v119.0 或更高版本的现代浏览器。",
"common.text.nodata": "暂无数据", "common.text.nodata": "暂无数据",
"common.text.operation_confirm": "操作确认", "common.text.operation_confirm": "操作确认",
"common.text.operation_succeeded": "操作成功", "common.text.operation_succeeded": "操作成功",

View File

@ -1,10 +1,15 @@
import { useTranslation } from "react-i18next";
import { Navigate, Outlet } from "react-router-dom"; import { Navigate, Outlet } from "react-router-dom";
import { Layout } from "antd"; import { Alert, Layout } from "antd";
import Show from "@/components/Show";
import Version from "@/components/Version"; import Version from "@/components/Version";
import { getAuthStore } from "@/repository/admin"; import { getAuthStore } from "@/repository/admin";
import { isBrowserHappy } from "@/utils/browser";
const AuthLayout = () => { const AuthLayout = () => {
const { t } = useTranslation();
const auth = getAuthStore(); const auth = getAuthStore();
if (auth.isValid && auth.isSuperuser) { if (auth.isValid && auth.isSuperuser) {
return <Navigate to="/" />; return <Navigate to="/" />;
@ -12,6 +17,10 @@ const AuthLayout = () => {
return ( return (
<Layout className="h-screen"> <Layout className="h-screen">
<Show when={!isBrowserHappy()}>
<Alert message={t("common.text.happy_browser")} type="warning" showIcon closable />
</Show>
<div className="container"> <div className="container">
<Outlet /> <Outlet />

View File

@ -13,11 +13,13 @@ import {
SettingOutlined as SettingOutlinedIcon, SettingOutlined as SettingOutlinedIcon,
SunOutlined as SunOutlinedIcon, SunOutlined as SunOutlinedIcon,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { Button, type ButtonProps, Drawer, Dropdown, Layout, Menu, type MenuProps, Tooltip, theme } from "antd"; import { Alert, Button, type ButtonProps, Drawer, Dropdown, Layout, Menu, type MenuProps, Tooltip, theme } from "antd";
import Show from "@/components/Show";
import Version from "@/components/Version"; import Version from "@/components/Version";
import { useBrowserTheme, useTriggerElement } from "@/hooks"; import { useBrowserTheme, useTriggerElement } from "@/hooks";
import { getAuthStore } from "@/repository/admin"; import { getAuthStore } from "@/repository/admin";
import { isBrowserHappy } from "@/utils/browser";
const ConsoleLayout = () => { const ConsoleLayout = () => {
const navigate = useNavigate(); const navigate = useNavigate();
@ -50,6 +52,10 @@ const ConsoleLayout = () => {
</Layout.Sider> </Layout.Sider>
<Layout className="flex flex-col overflow-hidden pl-[256px] max-md:pl-0"> <Layout className="flex flex-col overflow-hidden pl-[256px] max-md:pl-0">
<Show when={!isBrowserHappy()}>
<Alert message={t("common.text.happy_browser")} type="warning" showIcon closable />
</Show>
<Layout.Header className="p-0 shadow-sm" style={{ background: themeToken.colorBgContainer }}> <Layout.Header className="p-0 shadow-sm" style={{ background: themeToken.colorBgContainer }}>
<div className="flex size-full items-center justify-between overflow-hidden px-4"> <div className="flex size-full items-center justify-between overflow-hidden px-4">
<div className="flex items-center gap-4"> <div className="flex items-center gap-4">

3
ui/src/utils/browser.ts Normal file
View File

@ -0,0 +1,3 @@
export const isBrowserHappy = () => {
return typeof Promise.withResolvers === "function";
};