From 1e34ecffc242720b1897c50ca493d05bc7857e98 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: Thu, 11 Sep 2025 17:23:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81=E5=8F=8A=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(websocket): 禁用所有Toast提示以优化用户体验 删除开发环境下的测试路由、页面及组件,清理不再使用的代码。同时修改websocket模块,移除所有Toast提示以避免干扰用户操作。 --- Touchkebao/src/pages/mobile/test/README.md | 111 ----- Touchkebao/src/pages/mobile/test/index.tsx | 72 --- Touchkebao/src/pages/mobile/test/select.tsx | 221 --------- .../pages/mobile/test/update-notification.tsx | 179 -------- .../src/pages/mobile/test/upload.module.scss | 354 --------------- Touchkebao/src/pages/mobile/test/upload.tsx | 423 ------------------ Touchkebao/src/router/module/test.tsx | 39 -- .../src/store/module/websocket/websocket.ts | 38 +- 8 files changed, 19 insertions(+), 1418 deletions(-) delete mode 100644 Touchkebao/src/pages/mobile/test/README.md delete mode 100644 Touchkebao/src/pages/mobile/test/index.tsx delete mode 100644 Touchkebao/src/pages/mobile/test/select.tsx delete mode 100644 Touchkebao/src/pages/mobile/test/update-notification.tsx delete mode 100644 Touchkebao/src/pages/mobile/test/upload.module.scss delete mode 100644 Touchkebao/src/pages/mobile/test/upload.tsx delete mode 100644 Touchkebao/src/router/module/test.tsx diff --git a/Touchkebao/src/pages/mobile/test/README.md b/Touchkebao/src/pages/mobile/test/README.md deleted file mode 100644 index e8c69c49..00000000 --- a/Touchkebao/src/pages/mobile/test/README.md +++ /dev/null @@ -1,111 +0,0 @@ -# 上传组件测试页面 - -## 功能说明 - -这是一个完整的上传组件测试页面,用于演示和测试各种上传组件的功能。 - -## 包含的组件 - -### 1. 图片上传组件 (UploadComponent) - -- 支持多图片上传 -- 可设置最大上传数量 -- 文件类型验证 -- 文件大小限制 (5MB) -- 删除确认功能 - -### 2. 头像上传组件 (AvatarUpload) - -- 圆形头像显示 -- 支持尺寸调节 -- 单张图片上传 -- 悬停效果 - -### 3. 视频上传组件 (VideoUpload) - -- 支持视频文件上传 -- 文件大小限制 (50MB) -- 上传进度显示 - -## 测试功能 - -### 控制面板 - -- 图片上传数量限制调节 (1-20张) -- 头像尺寸调节 (60-200px) -- 各组件禁用状态切换 - -### 表单集成测试 - -- 模拟真实表单场景 -- 包含文本输入、文本域、图片、头像、视频上传 -- 展示组件在表单中的使用方式 - -### 操作功能 - -- 提交表单数据 (输出到控制台) -- 加载模拟数据 -- 重置所有数据 -- 页面刷新功能 - -### 数据展示 - -- 实时显示所有组件的当前状态 -- JSON格式展示,便于调试 - -## 使用Layout组件 - -页面使用了Layout组件进行布局,包含: - -1. **自定义头部** - - 返回按钮 - - 页面标题和图标 - - 搜索功能 - - 刷新功能 - -2. **主要内容区域** - - 响应式设计 - - 滚动支持 - - 加载状态显示 - -3. **样式特点** - - 响应式设计 - - 暗色主题支持 - - 现代化UI设计 - -## 访问方式 - -访问路径:`/mobile/test/upload` - -## 开发说明 - -### 文件结构 - -``` -src/pages/mobile/test/ -├── upload.tsx # 主测试页面 -├── upload.module.scss # 样式文件 -└── README.md # 说明文档 -``` - -### 依赖组件 - -- Layout: 页面布局组件 -- PopupHeader: 头部搜索组件 -- UploadComponent: 图片上传组件 -- AvatarUpload: 头像上传组件 -- VideoUpload: 视频上传组件 - -### 技术栈 - -- React 18 -- TypeScript -- Antd Mobile -- SCSS Modules - -## 注意事项 - -1. 上传功能需要配置正确的API地址 -2. 文件上传需要有效的认证token -3. 测试数据使用外部图片服务,需要网络连接 -4. 建议在移动端环境下测试以获得最佳体验 diff --git a/Touchkebao/src/pages/mobile/test/index.tsx b/Touchkebao/src/pages/mobile/test/index.tsx deleted file mode 100644 index aa153a7e..00000000 --- a/Touchkebao/src/pages/mobile/test/index.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import React from "react"; -import { Card, Button, Space, Typography, Tag } from "antd"; -import { - MessageOutlined, - SelectOutlined, - UploadOutlined, -} from "@ant-design/icons"; -import { useNavigate } from "react-router-dom"; -import { isDevelopment } from "@/utils/env"; -import Layout from "@/components/Layout/Layout"; -import NavCommon from "@/components/NavCommon"; - -const { Title, Text } = Typography; - -const TestIndex: React.FC = () => { - const navigate = useNavigate(); - - return ( - }> -
- - 测试页面 - {isDevelopment && ( - <Tag color="orange" style={{ marginLeft: 8, fontSize: "12px" }}> - 开发环境 - </Tag> - )} - - - - - - - - - - - - - - - 这里提供各种功能的测试页面,方便开发和调试。 - - -
-
- ); -}; - -export default TestIndex; diff --git a/Touchkebao/src/pages/mobile/test/select.tsx b/Touchkebao/src/pages/mobile/test/select.tsx deleted file mode 100644 index 35e47ca9..00000000 --- a/Touchkebao/src/pages/mobile/test/select.tsx +++ /dev/null @@ -1,221 +0,0 @@ -import React, { useState } from "react"; -import { Tabs, Tag } from "antd-mobile"; -import Layout from "@/components/Layout/Layout"; -import NavCommon from "@/components/NavCommon"; -import DeviceSelection from "@/components/DeviceSelection"; -import FriendSelection from "@/components/FriendSelection"; -import GroupSelection from "@/components/GroupSelection"; -import ContentSelection from "@/components/ContentSelection"; -import AccountSelection from "@/components/AccountSelection"; -import PoolSelection from "@/components/PoolSelection"; -import { isDevelopment } from "@/utils/env"; -import { GroupSelectionItem } from "@/components/GroupSelection/data"; -import { ContentItem } from "@/components/ContentSelection/data"; -import { FriendSelectionItem } from "@/components/FriendSelection/data"; -import { DeviceSelectionItem } from "@/components/DeviceSelection/data"; -import { AccountItem } from "@/components/AccountSelection/data"; -import { PoolSelectionItem } from "@/components/PoolSelection/data"; -const ComponentTest: React.FC = () => { - const [activeTab, setActiveTab] = useState("pools"); - - // 设备选择状态 - const [selectedDevices, setSelectedDevices] = useState( - [], - ); - - // 群组选择状态 - const [selectedGroups, setSelectedGroups] = useState( - [], - ); - - // 内容库选择状态 - const [selectedContent, setSelectedContent] = useState([]); - - const [selectedAccounts, setSelectedAccounts] = useState([]); - // 好友选择状态 - const [selectedFriendsOptions, setSelectedFriendsOptions] = useState< - FriendSelectionItem[] - >([]); - - // 流量池选择状态 - const [selectedPools, setSelectedPools] = useState([]); - return ( - }> -
- {isDevelopment && ( -
- - 开发环境 - 组件测试 - -
- )} - - - -
-

FriendSelection 组件测试

- -
-
- -
-

ContentSelection 组件测试

- -
- 已选内容库: {selectedContent.length} 个 -
- 内容库ID:{" "} - {selectedContent.map(c => c.id).join(", ") || "无"} -
-
-
- - -
-

GroupSelection 组件测试

- -
- 已选群组: {selectedGroups.length} 个 -
- 群组ID:{" "} - {selectedGroups.map(g => g.id).join(", ") || "无"} -
-
-
- - -
-

DeviceSelection 组件测试

- -
- 已选设备: {selectedDevices.length} 个 -
- 设备ID: - {selectedDevices.map(d => d.id).join(", ") || "无"} -
-
-
- - -
-

AccountSelection 组件测试

- -
- 已选账号: - {selectedAccounts.length > 0 - ? selectedAccounts.join(", ") - : "无"} -
-
-
- - -
-

GroupSelection 组件测试

- -
- 已选群组: {selectedGroups.length} 个 -
- 群组ID:{" "} - {selectedGroups.map(g => g.id).join(", ") || "无"} -
-
-
- - -
-

PoolSelection 组件测试

- -
- 已选流量池: {selectedPools.length} 个 -
- 流量池ID:{" "} - {selectedPools.map(p => p.id).join(", ") || "无"} -
-
-
-
-
-
- ); -}; - -export default ComponentTest; diff --git a/Touchkebao/src/pages/mobile/test/update-notification.tsx b/Touchkebao/src/pages/mobile/test/update-notification.tsx deleted file mode 100644 index dae1b936..00000000 --- a/Touchkebao/src/pages/mobile/test/update-notification.tsx +++ /dev/null @@ -1,179 +0,0 @@ -import React from "react"; -import UpdateNotification from "@/components/UpdateNotification"; - -const UpdateNotificationTest: React.FC = () => { - return ( -
- {/* 更新通知组件 */} - - - {/* 页面内容 */} -
-
-

- UpdateNotification 组件预览 -

- -
-

- 设计特点: -

-
    -
  • 酷黑风格横向条设计
  • -
  • 顶部固定定位,支持安全区域
  • -
  • 渐变背景和半透明边框
  • -
  • 蓝色主题按钮
  • -
  • 从上方滑入动画效果
  • -
  • 红色更新图标脉冲动画
  • -
  • 移动端优化的字体和按钮尺寸
  • -
-
- -
-

- 功能说明: -

-
    -
  • 点击“立即更新”会刷新页面
  • -
  • 点击“稍后”会隐藏通知,10分钟后重新检查
  • -
  • 通知固定在顶部,不会影响页面布局
  • -
  • 支持安全区域适配,确保在刘海屏设备上正常显示
  • -
  • 响应式设计,适配不同屏幕尺寸
  • -
-
- -
-

- 注意: - 此页面强制显示更新通知组件用于预览效果。在实际使用中,组件会根据更新检测结果自动显示或隐藏。 -

-
-
- - {/* 模拟页面内容 */} -
-

- 页面内容区域 -

-

- 这里是页面的主要内容区域。更新通知栏固定在顶部,不会影响页面内容的正常显示和交互。 -

-

- 页面内容会自动为顶部通知栏预留空间,确保内容不被遮挡。在有安全区域的设备上, - 通知栏会自动适配安全区域高度。 -

-
- 模拟内容区域 -
-
-
-
- ); -}; - -export default UpdateNotificationTest; diff --git a/Touchkebao/src/pages/mobile/test/upload.module.scss b/Touchkebao/src/pages/mobile/test/upload.module.scss deleted file mode 100644 index aaed5bc9..00000000 --- a/Touchkebao/src/pages/mobile/test/upload.module.scss +++ /dev/null @@ -1,354 +0,0 @@ -.container { - padding: 16px; - background: #f5f5f5; - min-height: 100vh; - - .customHeader { - display: flex; - align-items: center; - justify-content: space-between; - padding: 12px 16px; - background: #fff; - border-bottom: 1px solid #f0f0f0; - - .headerLeft { - display: flex; - align-items: center; - gap: 12px; - - .backButton { - padding: 4px; - border: none; - background: transparent; - color: #666; - font-size: 18px; - - &:hover { - color: #1890ff; - } - } - - .headerTitle { - display: flex; - align-items: center; - gap: 8px; - font-size: 16px; - font-weight: bold; - color: #333; - - .headerIcon { - font-size: 20px; - color: #1890ff; - } - } - } - } - - .controlPanel { - margin-bottom: 16px; - - h3 { - font-size: 16px; - font-weight: bold; - color: #333; - margin-bottom: 16px; - } - - .controlItem { - display: flex; - justify-content: space-between; - align-items: center; - padding: 8px 0; - border-bottom: 1px solid #f0f0f0; - - &:last-child { - border-bottom: none; - } - - span { - font-size: 14px; - color: #333; - } - } - } - - .testSection { - margin-bottom: 16px; - - h3 { - font-size: 16px; - font-weight: bold; - color: #333; - margin-bottom: 8px; - } - - p { - font-size: 12px; - color: #666; - margin-bottom: 16px; - } - - .result { - margin-top: 16px; - padding: 12px; - background: #f8f9fa; - border-radius: 8px; - - h4 { - font-size: 14px; - font-weight: bold; - color: #333; - margin-bottom: 8px; - } - - .urlList { - .urlItem { - display: flex; - align-items: flex-start; - margin-bottom: 4px; - font-size: 12px; - - span:first-child { - color: #666; - margin-right: 8px; - min-width: 20px; - flex-shrink: 0; - } - - .url { - color: #1890ff; - word-break: break-all; - line-height: 1.4; - white-space: pre-wrap; - word-wrap: break-word; - overflow-wrap: break-word; - flex: 1; - min-width: 0; // 确保flex项目可以收缩 - } - } - } - - .emptyText { - color: #999; - font-style: italic; - } - } - } - - .form { - .formItem { - margin-bottom: 16px; - - label { - display: block; - font-size: 14px; - font-weight: bold; - color: #333; - margin-bottom: 8px; - } - - input, - textarea { - width: 100%; - padding: 8px 12px; - border: 1px solid #d9d9d9; - border-radius: 6px; - font-size: 14px; - transition: border-color 0.3s; - - &:focus { - outline: none; - border-color: #1890ff; - box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2); - } - - &::placeholder { - color: #bfbfbf; - } - } - - textarea { - resize: vertical; - min-height: 80px; - } - } - } - - .actionPanel { - margin-bottom: 16px; - } - - .dataPanel { - h3 { - font-size: 16px; - font-weight: bold; - color: #333; - margin-bottom: 16px; - } - - .dataContent { - background: #f8f9fa; - border-radius: 8px; - padding: 12px; - max-height: 300px; - overflow-y: auto; - - pre { - margin: 0; - font-size: 12px; - line-height: 1.4; - color: #333; - white-space: pre-wrap; - word-break: break-all; - } - } - } -} - -// 响应式设计 -@media (max-width: 768px) { - .container { - padding: 12px; - - .customHeader { - padding: 8px 12px; - - .headerLeft { - .headerTitle { - font-size: 14px; - - .headerIcon { - font-size: 18px; - } - } - } - } - - .testSection { - .result { - .urlList { - .urlItem { - font-size: 11px; - } - } - } - } - - .dataPanel { - .dataContent { - pre { - font-size: 11px; - } - } - } - } -} - -// 暗色主题支持 -@media (prefers-color-scheme: dark) { - .container { - background: #1f1f1f; - - .customHeader { - background: #2a2a2a; - border-bottom-color: #434343; - - .headerLeft { - .backButton { - color: #ccc; - - &:hover { - color: #40a9ff; - } - } - - .headerTitle { - color: #fff; - - .headerIcon { - color: #40a9ff; - } - } - } - } - - .testSection { - h3 { - color: #fff; - } - - p { - color: #ccc; - } - - .result { - background: #2a2a2a; - - h4 { - color: #fff; - } - - .urlList { - .urlItem { - span:first-child { - color: #ccc; - } - - .url { - color: #40a9ff; - } - } - } - - // 单个URL项(头像、视频)的样式 - .urlItem { - .url { - color: #40a9ff; - } - } - - .emptyText { - color: #888; - } - } - } - - .form { - .formItem { - label { - color: #fff; - } - - input, - textarea { - background: #2a2a2a; - border-color: #434343; - color: #fff; - - &:focus { - border-color: #40a9ff; - box-shadow: 0 0 0 2px rgba(64, 169, 255, 0.2); - } - - &::placeholder { - color: #666; - } - } - } - } - - .dataPanel { - h3 { - color: #fff; - } - - .dataContent { - background: #2a2a2a; - - pre { - color: #fff; - } - } - } - } -} diff --git a/Touchkebao/src/pages/mobile/test/upload.tsx b/Touchkebao/src/pages/mobile/test/upload.tsx deleted file mode 100644 index 22bfb77e..00000000 --- a/Touchkebao/src/pages/mobile/test/upload.tsx +++ /dev/null @@ -1,423 +0,0 @@ -import React, { useState } from "react"; -import { Button, Card, Space, Divider, Toast, Switch } from "antd-mobile"; -import Layout from "@/components/Layout/Layout"; -import NavCommon from "@/components/NavCommon"; -import ImageUpload from "@/components/Upload/ImageUpload/ImageUpload"; -import AvatarUpload from "@/components/Upload/AvatarUpload"; -import VideoUpload from "@/components/Upload/VideoUpload"; -import FileUpload from "@/components/Upload/FileUpload"; -import MainImgUpload from "@/components/Upload/MainImgUpload"; -import styles from "./upload.module.scss"; - -// 错误边界组件 -class ErrorBoundary extends React.Component< - { children: React.ReactNode }, - { hasError: boolean; error: Error | null } -> { - constructor(props: { children: React.ReactNode }) { - super(props); - this.state = { hasError: false, error: null }; - } - - static getDerivedStateFromError(error: Error) { - return { hasError: true, error }; - } - - componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { - console.error("Error caught by boundary:", error, errorInfo); - } - - render() { - if (this.state.hasError) { - return ( -
-

组件出现错误

-

错误信息: {this.state.error?.message}

- -
- ); - } - - return this.props.children; - } -} - -const UploadTestPage: React.FC = () => { - // 搜索状态 - const [searchQuery, setSearchQuery] = useState(""); - const [loading, setLoading] = useState(false); - - // 图片上传状态 - const [imageUrls, setImageUrls] = useState([]); - const [imageCount, setImageCount] = useState(9); - const [imageDisabled, setImageDisabled] = useState(false); - - // 头像上传状态 - const [avatarUrl, setAvatarUrl] = useState(""); - const [avatarSize, setAvatarSize] = useState(100); - const [avatarDisabled, setAvatarDisabled] = useState(false); - - // 视频上传状态 - const [videoUrl, setVideoUrl] = useState(""); - const [videoUrls, setVideoUrls] = useState([]); - const [videoDisabled, setVideoDisabled] = useState(false); - const [videoCount, setVideoCount] = useState(1); - - // 文件上传状态 - const [fileUrl, setFileUrl] = useState(""); - const [fileUrls, setFileUrls] = useState([]); - const [fileDisabled, setFileDisabled] = useState(false); - const [fileCount, setFileCount] = useState(1); - const [fileTypes, setFileTypes] = useState([ - "excel", - "word", - "ppt", - ]); - - // 主图上传状态 - const [mainImgUrl, setMainImgUrl] = useState(""); - const [mainImgDisabled, setMainImgDisabled] = useState(false); - const [mainImgMaxSize, setMainImgMaxSize] = useState(5); - const [mainImgShowPreview, setMainImgShowPreview] = useState(true); - - return ( - } loading={loading}> -
- {/* 图片上传测试 */} - - -

图片上传组件测试

-

支持多图片上传,可设置数量限制

- - - -
-

当前图片URLs:

-
- {imageUrls.length > 0 ? ( - imageUrls.map((url, index) => ( -
- {index + 1}. - - {typeof url === "string" ? url : "无效URL"} - -
- )) - ) : ( - 暂无图片 - )} -
-
-
-
- - {/* 头像上传测试 */} - - -

头像上传组件测试

-

支持单张图片上传,圆形显示

- - - -
-

当前头像URL:

-
-
- {avatarUrl ? ( -
- {typeof avatarUrl === "string" ? avatarUrl : "无效URL"} -
- ) : ( - 暂无头像 - )} -
-
-
-
-
- - {/* 视频上传测试 */} - - -

视频上传组件测试

-

支持视频文件上传,最大50MB,支持预览功能,可设置上传数量

- - {/* 视频上传控制面板 */} -
-
- 视频上传数量: - - - {videoCount} - - -
-
- - { - if (videoCount === 1) { - setVideoUrl(url as string); - } else { - setVideoUrls(url as string[]); - } - }} - disabled={videoDisabled} - maxSize={50} - showPreview={true} - maxCount={videoCount} - /> - -
-

当前视频URL:

-
- {videoCount === 1 ? ( -
- {videoUrl ? ( -
- {typeof videoUrl === "string" ? videoUrl : "无效URL"} -
- ) : ( - 暂无视频 - )} -
- ) : videoUrls.length > 0 ? ( - videoUrls.map((url, index) => ( -
- {index + 1}. -
- {typeof url === "string" ? url : "无效URL"} -
-
- )) - ) : ( - 暂无视频 - )} -
-
-
-
- - {/* 文件上传测试 */} - - -

文件上传组件测试

-

支持Excel、Word、PPT格式文件上传,可设置上传数量和文件类型

- - {/* 文件上传控制面板 */} -
-
- 文件上传数量: - - - {fileCount} - - -
- -
- 文件类型: - - - - - -
-
- - { - if (fileCount === 1) { - setFileUrl(url as string); - } else { - setFileUrls(url as string[]); - } - }} - disabled={fileDisabled} - maxSize={10} - showPreview={true} - maxCount={fileCount} - acceptTypes={fileTypes} - /> - -
-

当前文件URL:

-
- {fileCount === 1 ? ( -
- {fileUrl ? ( -
- {typeof fileUrl === "string" ? fileUrl : "无效URL"} -
- ) : ( - 暂无文件 - )} -
- ) : fileUrls.length > 0 ? ( - fileUrls.map((url, index) => ( -
- {index + 1}. -
- {typeof url === "string" ? url : "无效URL"} -
-
- )) - ) : ( - 暂无文件 - )} -
-
-
-
- - {/* 主图上传测试 */} - - -

主图封面上传组件测试

-

支持单张图片上传作为主图封面,上传后右上角显示删除按钮

- - {/* 主图上传控制面板 */} -
-
- 最大文件大小: - - - {mainImgMaxSize}MB - - -
- -
- 显示预览按钮: - -
- -
- 禁用状态: - -
-
- - - -
-

当前主图URL:

-
-
- {mainImgUrl ? ( -
- {typeof mainImgUrl === "string" ? mainImgUrl : "无效URL"} -
- ) : ( - 暂无主图 - )} -
-
-
-
-
-
-
- ); -}; - -export default UploadTestPage; diff --git a/Touchkebao/src/router/module/test.tsx b/Touchkebao/src/router/module/test.tsx deleted file mode 100644 index ab416284..00000000 --- a/Touchkebao/src/router/module/test.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import SelectTest from "@/pages/mobile/test/select"; -import TestIndex from "@/pages/mobile/test/index"; -import UploadTest from "@/pages/mobile/test/upload"; -import UpdateNotificationTest from "@/pages/mobile/test/update-notification"; -import IframeDebugPage from "@/pages/iframe"; -import { DEV_FEATURES } from "@/utils/env"; - -// 只在开发环境启用测试路由 -const componentTestRoutes = DEV_FEATURES.SHOW_TEST_PAGES - ? [ - { - path: "/test", - element: , - auth: true, - }, - { - path: "/test/select", - element: , - auth: true, - }, - { - path: "/test/upload", - element: , - auth: true, - }, - { - path: "/test/update-notification", - element: , - auth: true, - }, - { - path: "/test/iframe", - element: , - auth: false, // 不需要认证,方便调试 - }, - ] - : []; - -export default componentTestRoutes; diff --git a/Touchkebao/src/store/module/websocket/websocket.ts b/Touchkebao/src/store/module/websocket/websocket.ts index 46f9ed18..1a4da01c 100644 --- a/Touchkebao/src/store/module/websocket/websocket.ts +++ b/Touchkebao/src/store/module/websocket/websocket.ts @@ -130,7 +130,7 @@ export const useWebSocketStore = createPersistStore( const { token2 } = useUserStore.getState(); if (!token2) { - Toast.show({ content: "未找到有效的访问令牌", position: "top" }); + // Toast.show({ content: "未找到有效的访问令牌", position: "top" }); return; } @@ -147,10 +147,10 @@ export const useWebSocketStore = createPersistStore( // 检查URL是否为localhost,如果是则不连接 if (wsUrl.includes("localhost") || wsUrl.includes("127.0.0.1")) { // console.error("WebSocket连接被拦截:不允许连接到本地地址", wsUrl); - Toast.show({ - content: "WebSocket连接被拦截:不允许连接到本地地址", - position: "top", - }); + // Toast.show({ + // content: "WebSocket连接被拦截:不允许连接到本地地址", + // position: "top", + // }); set({ status: WebSocketStatus.ERROR }); return; } @@ -175,7 +175,7 @@ export const useWebSocketStore = createPersistStore( } catch (error) { // console.error("WebSocket连接失败:", error); set({ status: WebSocketStatus.ERROR }); - Toast.show({ content: "WebSocket连接失败", position: "top" }); + // Toast.show({ content: "WebSocket连接失败", position: "top" }); } }, @@ -207,7 +207,7 @@ export const useWebSocketStore = createPersistStore( currentState.status !== WebSocketStatus.CONNECTED || !currentState.ws ) { - Toast.show({ content: "WebSocket未连接", position: "top" }); + // Toast.show({ content: "WebSocket未连接", position: "top" }); return; } @@ -220,7 +220,7 @@ export const useWebSocketStore = createPersistStore( // console.log("消息发送成功:", fullMessage); } catch (error) { // console.error("消息发送失败:", error); - Toast.show({ content: "消息发送失败", position: "top" }); + // Toast.show({ content: "消息发送失败", position: "top" }); } }, @@ -232,10 +232,10 @@ export const useWebSocketStore = createPersistStore( currentState.status !== WebSocketStatus.CONNECTED || !currentState.ws ) { - Toast.show({ - content: "WebSocket未连接,正在重新连接...", - position: "top", - }); + // Toast.show({ + // content: "WebSocket未连接,正在重新连接...", + // position: "top", + // }); // 重置连接状态并发起重新连接 set({ status: WebSocketStatus.DISCONNECTED }); @@ -256,7 +256,7 @@ export const useWebSocketStore = createPersistStore( // console.log("命令发送成功:", command); } catch (error) { // console.error("命令发送失败:", error); - Toast.show({ content: "命令发送失败", position: "top" }); + // Toast.show({ content: "命令发送失败", position: "top" }); // 发送失败时也尝试重新连接 set({ status: WebSocketStatus.DISCONNECTED }); @@ -339,7 +339,7 @@ export const useWebSocketStore = createPersistStore( }); } - Toast.show({ content: "WebSocket连接成功", position: "top" }); + // Toast.show({ content: "WebSocket连接成功", position: "top" }); // 启动客服状态查询定时器 currentState._startAliveStatusTimer(); @@ -356,10 +356,10 @@ export const useWebSocketStore = createPersistStore( // 处理Auth failed通知 if (data.notify === "Auth failed" || data.notify === "Kicked out") { // console.error(`WebSocket ${data.notify},断开连接`); - Toast.show({ - content: `WebSocket ${data.notify},断开连接`, - position: "top", - }); + // Toast.show({ + // content: `WebSocket ${data.notify},断开连接`, + // position: "top", + // }); // 禁用自动重连 if (get().config) { @@ -436,7 +436,7 @@ export const useWebSocketStore = createPersistStore( set({ status: WebSocketStatus.ERROR }); - Toast.show({ content: "WebSocket连接错误", position: "top" }); + // Toast.show({ content: "WebSocket连接错误", position: "top" }); }, // 内部方法:启动重连定时器