From fa917639d2a2d12b29d616f90589f5e9452fbf4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Mon, 6 Apr 2026 12:21:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(honor):=20=E4=BC=98=E5=8C=96=E5=85=89?= =?UTF-8?q?=E8=8D=A3=E6=A6=9C=E5=88=97=E8=A1=A8=E5=8E=BB=E9=87=8D=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E9=98=B2=E6=AD=A2=E9=87=8D=E5=A4=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 列表第一页渲染时根据 articleId 去重,避免重复条目显示 - 翻页追加数据时合并并去重列表,确保展示无重复内容 - 修复因后端数据重复导致的同一条目多次出现问题 feat(config): 新增环境变量配置及配置文件重构 - 新增 config/env.ts 支持开发、测试、生产环境变量配置 - 通过 getEnvConfig 函数动态获取当前环境配置 - config/app.ts 引入环境变量,实现接口地址等配置统一管理 --- .workbuddy/memory/2026-04-06.md | 16 +++++++++++++ .workbuddy/memory/MEMORY.md | 0 config/app.ts | 12 ++++++++++ config/env.ts | 42 +++++++++++++++++++++++++++++++++ src/honor/list.tsx | 14 +++++++---- src/pages/index/Video.tsx | 4 ++-- src/utils/config.ts | 2 +- src/utils/server.ts | 4 ++-- 8 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 .workbuddy/memory/2026-04-06.md create mode 100644 .workbuddy/memory/MEMORY.md create mode 100644 config/app.ts create mode 100644 config/env.ts diff --git a/.workbuddy/memory/2026-04-06.md b/.workbuddy/memory/2026-04-06.md new file mode 100644 index 0000000..4f25210 --- /dev/null +++ b/.workbuddy/memory/2026-04-06.md @@ -0,0 +1,16 @@ +# 2026-04-06 工作记录 + +## 首页视频替换 + +- 文件:`src/pages/index/Video.tsx` +- 旧视频:`https://oss.wsdns.cn/20250722/018be1bd1c8b4cc4a15076ad0578b88d.mp4` +- 新视频(微信传入 7.mp4,约 11MB):`https://oss.wsdns.cn/20260406/2be0376cac054f2ba86dd35a2bc52e11.mp4` +- 上传方式:通过 `https://server.websoft.top/api/oss/upload` + Header `TenantId: 10556` + +--- + +## 光荣榜列表去重处理 + +- 问题:`src/honor/list.tsx` 渲染的"2024年立功受奖光荣榜"列表中,"黄富钜"出现了两次(后端数据库重复条目导致)。 +- 修复:在 `list.tsx` 的数据赋值逻辑中,第一页和翻页追加时均按 `articleId` 去重,防止同一条目重复展示。 +- 建议:根本解决方案是从后端数据库中删除重复的文章记录。 diff --git a/.workbuddy/memory/MEMORY.md b/.workbuddy/memory/MEMORY.md new file mode 100644 index 0000000..e69de29 diff --git a/config/app.ts b/config/app.ts new file mode 100644 index 0000000..3c80a5a --- /dev/null +++ b/config/app.ts @@ -0,0 +1,12 @@ +import { API_BASE_URL } from './env' + +// 租户ID - 请根据实际情况修改 +export const TenantId = '10556'; +// 接口地址 - 请根据实际情况修改 +export const BaseUrl = API_BASE_URL; +// 当前版本 +export const Version = 'v3.0.8'; +// 版权信息 +export const Copyright = 'WebSoft Inc.'; + +// java -jar CertificateDownloader.jar -k 0kF5OlPr482EZwtn9zGufUcqa7ovgxRL -m 1723321338 -f ./apiclient_key.pem -s 2B933F7C35014A1C363642623E4A62364B34C4EB -o ./ diff --git a/config/env.ts b/config/env.ts new file mode 100644 index 0000000..de8e281 --- /dev/null +++ b/config/env.ts @@ -0,0 +1,42 @@ +// 环境变量配置 +export const ENV_CONFIG = { + // 开发环境 + development: { + API_BASE_URL: 'https://cms-api.websoft.top/api', + APP_NAME: '开发环境', + DEBUG: 'true', + }, + // 生产环境 + production: { + API_BASE_URL: 'https://cms-api.websoft.top/api', + APP_NAME: '九运售电云', + DEBUG: 'false', + }, + // 测试环境 + test: { + API_BASE_URL: 'https://cms-api.s209.websoft.top/api', + APP_NAME: '测试环境', + DEBUG: 'true', + } +} + +// 获取当前环境配置 +export function getEnvConfig() { + const env = process.env.NODE_ENV || 'development' + if (env === 'production') { + return ENV_CONFIG.production + } else { // @ts-ignore + if (env === 'test') { + return ENV_CONFIG.test + } else { + return ENV_CONFIG.development + } + } +} + +// 导出环境变量 +export const { + API_BASE_URL, + APP_NAME, + DEBUG +} = getEnvConfig() diff --git a/src/honor/list.tsx b/src/honor/list.tsx index 35f3a78..85a20a4 100644 --- a/src/honor/list.tsx +++ b/src/honor/list.tsx @@ -41,12 +41,18 @@ const List = () => { if (articles) { if (articles?.list && articles?.list.length > 0) { if (currentPage === 1) { - // 第一页,直接设置 - setList(articles.list); + // 第一页,直接设置(按 articleId 去重) + const unique = articles.list.filter( + (item, idx, arr) => arr.findIndex(t => t.articleId === item.articleId) === idx + ); + setList(unique); } else { - // 后续页面,追加到现有列表 + // 后续页面,追加到现有列表(合并后去重) setList(prevList => { - const newList = [...prevList, ...articles.list]; + const merged = [...prevList, ...articles.list]; + const newList = merged.filter( + (item, idx, arr) => arr.findIndex(t => t.articleId === item.articleId) === idx + ); console.log('honor/list 合并后的列表长度:', newList.length); return newList; }); diff --git a/src/pages/index/Video.tsx b/src/pages/index/Video.tsx index 421f6cf..e70e838 100644 --- a/src/pages/index/Video.tsx +++ b/src/pages/index/Video.tsx @@ -10,9 +10,9 @@ const MyPage = () => { diff --git a/src/utils/config.ts b/src/utils/config.ts index beda84c..e370483 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -1,7 +1,7 @@ // 租户ID export const TenantId = 10556; // 接口地址 -export const BaseUrl = 'http://182.90.229.54:10048/api'; +export const BaseUrl = 'https://cms-api.websoft.top/api'; // 当前版本 export const Version = 'v3.0.8'; // 版权信息 diff --git a/src/utils/server.ts b/src/utils/server.ts index b37d43b..c8be7ab 100644 --- a/src/utils/server.ts +++ b/src/utils/server.ts @@ -7,10 +7,10 @@ export const TEMPLATE_ID = 10556; export const SERVER_API_URL = 'https://server.websoft.top/api'; // export const SERVER_API_URL = 'http://127.0.0.1:8000/api'; // 服务接口 -export const APP_API_URL = 'http://182.90.229.54:10048/api'; +export const APP_API_URL = 'https://cms-api.websoft.top/api'; // export const APP_API_URL = 'http://127.0.0.1:9000/api'; // WSS -export const WSS_API_URL = 'ws://182.90.229.54:10048/api'; +export const WSS_API_URL = 'ws://server.websoft.top/api'; /** * 保存用户信息到本地存储 * @param token