From f9be0fad2d77017846fc689830ca020d9ffd50cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Tue, 19 Aug 2025 14:57:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(UpdateNotification):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=90=E7=A4=BA=E7=BB=84=E4=BB=B6=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=92=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 forceShow 和 onClose 属性支持强制显示和关闭回调 - 重新设计 UI 样式为顶部通知栏布局 - 新增"稍后"按钮支持延迟更新 - 优化动画效果和交互体验 --- .../components/UpdateNotification/index.tsx | 208 ++++++++++-------- 1 file changed, 122 insertions(+), 86 deletions(-) diff --git a/Cunkebao/src/components/UpdateNotification/index.tsx b/Cunkebao/src/components/UpdateNotification/index.tsx index 371b3d8a..d7169da7 100644 --- a/Cunkebao/src/components/UpdateNotification/index.tsx +++ b/Cunkebao/src/components/UpdateNotification/index.tsx @@ -1,22 +1,22 @@ import React, { useState, useEffect } from "react"; import { Button } from "antd-mobile"; import { updateChecker } from "@/utils/updateChecker"; -import { - ReloadOutlined, - CloudDownloadOutlined, - RocketOutlined, -} from "@ant-design/icons"; +import { ReloadOutlined } from "@ant-design/icons"; interface UpdateNotificationProps { position?: "top" | "bottom"; autoReload?: boolean; showToast?: boolean; + forceShow?: boolean; + onClose?: () => void; } const UpdateNotification: React.FC = ({ position = "top", autoReload = false, showToast = true, + forceShow = false, + onClose, }) => { const [hasUpdate, setHasUpdate] = useState(false); const [isVisible, setIsVisible] = useState(false); @@ -51,7 +51,19 @@ const UpdateNotification: React.FC = ({ updateChecker.forceReload(); }; - if (!isVisible || !hasUpdate) { + const handleLater = () => { + setIsVisible(false); + onClose?.(); + // 10分钟后再次检查 + setTimeout( + () => { + updateChecker.start(); + }, + 10 * 60 * 1000, + ); + }; + + if ((!isVisible || !hasUpdate) && !forceShow) { return null; } @@ -62,110 +74,134 @@ const UpdateNotification: React.FC = ({ top: 0, left: 0, right: 0, - bottom: 0, zIndex: 99999, - background: "linear-gradient(135deg, #1890ff 0%, #096dd9 100%)", + background: "linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%)", color: "white", - display: "flex", - flexDirection: "column", - alignItems: "center", - justifyContent: "center", - padding: "20px", - textAlign: "center", + padding: "16px 16px", + boxShadow: "0 4px 20px rgba(0, 0, 0, 0.5)", + borderBottom: "1px solid rgba(255, 255, 255, 0.1)", + animation: "slideDownBar 0.3s ease-out", }} > - {/* 背景装饰 */}
- -
- - {/* 主要内容 */} -
- {/* 图标 */} + {/* 左侧内容 */}
- + {/* 更新图标 */} +
+ +
+ {/* 文本信息 */} +
+
+ 发现新版本 +
+
+ 建议立即更新获得更好体验 +
+
- {/* 标题 */} + {/* 右侧按钮组 */}
- 发现新版本 -
- - {/* 描述 */} -
- 为了给您提供更好的体验,请更新到最新版本 -
- - {/* 更新按钮 */} - - - {/* 提示文字 */} -
- 更新将自动重启应用 + +
{/* 动画样式 */}