fix(honor): 优化光荣榜列表去重逻辑,防止重复显示
- 列表第一页渲染时根据 articleId 去重,避免重复条目显示 - 翻页追加数据时合并并去重列表,确保展示无重复内容 - 修复因后端数据重复导致的同一条目多次出现问题 feat(config): 新增环境变量配置及配置文件重构 - 新增 config/env.ts 支持开发、测试、生产环境变量配置 - 通过 getEnvConfig 函数动态获取当前环境配置 - config/app.ts 引入环境变量,实现接口地址等配置统一管理
This commit is contained in:
16
.workbuddy/memory/2026-04-06.md
Normal file
16
.workbuddy/memory/2026-04-06.md
Normal file
@@ -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` 去重,防止同一条目重复展示。
|
||||||
|
- 建议:根本解决方案是从后端数据库中删除重复的文章记录。
|
||||||
0
.workbuddy/memory/MEMORY.md
Normal file
0
.workbuddy/memory/MEMORY.md
Normal file
12
config/app.ts
Normal file
12
config/app.ts
Normal file
@@ -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 ./
|
||||||
42
config/env.ts
Normal file
42
config/env.ts
Normal file
@@ -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()
|
||||||
@@ -41,12 +41,18 @@ const List = () => {
|
|||||||
if (articles) {
|
if (articles) {
|
||||||
if (articles?.list && articles?.list.length > 0) {
|
if (articles?.list && articles?.list.length > 0) {
|
||||||
if (currentPage === 1) {
|
if (currentPage === 1) {
|
||||||
// 第一页,直接设置
|
// 第一页,直接设置(按 articleId 去重)
|
||||||
setList(articles.list);
|
const unique = articles.list.filter(
|
||||||
|
(item, idx, arr) => arr.findIndex(t => t.articleId === item.articleId) === idx
|
||||||
|
);
|
||||||
|
setList(unique);
|
||||||
} else {
|
} else {
|
||||||
// 后续页面,追加到现有列表
|
// 后续页面,追加到现有列表(合并后去重)
|
||||||
setList(prevList => {
|
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);
|
console.log('honor/list 合并后的列表长度:', newList.length);
|
||||||
return newList;
|
return newList;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ const MyPage = () => {
|
|||||||
<video
|
<video
|
||||||
controls
|
controls
|
||||||
className='w-full max-w-2xl mx-auto'
|
className='w-full max-w-2xl mx-auto'
|
||||||
poster='https://oss.wsdns.cn/20250722/018be1bd1c8b4cc4a15076ad0578b88d.mp4?x-oss-process=video/snapshot,t_1000,f_jpg,w_396,h_222,m_fast'
|
poster='https://oss.wsdns.cn/20260406/2be0376cac054f2ba86dd35a2bc52e11.mp4?x-oss-process=video/snapshot,t_1000,f_jpg,w_396,h_222,m_fast'
|
||||||
>
|
>
|
||||||
<source src='https://oss.wsdns.cn/20250722/018be1bd1c8b4cc4a15076ad0578b88d.mp4' type='video/mp4' />
|
<source src='https://oss.wsdns.cn/20260406/2be0376cac054f2ba86dd35a2bc52e11.mp4' type='video/mp4' />
|
||||||
您的浏览器不支持视频播放
|
您的浏览器不支持视频播放
|
||||||
</video>
|
</video>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// 租户ID
|
// 租户ID
|
||||||
export const TenantId = 10556;
|
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';
|
export const Version = 'v3.0.8';
|
||||||
// 版权信息
|
// 版权信息
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ export const TEMPLATE_ID = 10556;
|
|||||||
export const SERVER_API_URL = 'https://server.websoft.top/api';
|
export const SERVER_API_URL = 'https://server.websoft.top/api';
|
||||||
// export const SERVER_API_URL = 'http://127.0.0.1:8000/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';
|
// export const APP_API_URL = 'http://127.0.0.1:9000/api';
|
||||||
// WSS
|
// 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
|
* @param token
|
||||||
|
|||||||
Reference in New Issue
Block a user