diff --git a/backend/app/routers/seek.py b/backend/app/routers/seek.py index 3a277d5..95db0c5 100644 --- a/backend/app/routers/seek.py +++ b/backend/app/routers/seek.py @@ -1,6 +1,6 @@ # seek - 寻配号路由 -# Version: 0.0.8 (2026-04-24) -# 更新:network_matched_count缓存到数据库,创建时初始化,点击时更新 +# Version: 0.0.9 (2026-04-24) +# 稳定版:自有匹配+网络匹配缓存 from fastapi import APIRouter, Depends, Query, HTTPException from sqlalchemy.orm import Session @@ -104,16 +104,13 @@ def get_seek_list( user_name = user.f01_01_name if user else '匿名用户' # 构建响应(不实时计算网络匹配,网络匹配在点击时再查) - # 计算自有匹配数量,网络匹配数量从数据库读取(如为0则计算一次) - matched_count = 0 - network_matched_count = getattr(item, 'network_matched_count', 0) or 0 - if network_matched_count == 0 and item.expect_number and len(item.expect_number) == 10: - # 如果数据库中没有值,计算一次并保存 - network_matched_count = match_collections_count_from_coolbot(item.expect_number) - # 更新数据库 - item.network_matched_count = network_matched_count - db.commit() + # 网络匹配数量从数据库读取(不再实时计算,初始为0) + network_matched_count = 0 + if hasattr(item, 'network_matched_count') and item.network_matched_count: + network_matched_count = item.network_matched_count + # 自有匹配数量(使用缓存方式,如为0则计算一次) + matched_count = 0 if item.expect_number and len(item.expect_number) == 10: if current_user and current_user.f99_90_id: matched_count = match_collections_count(db, current_user.f99_90_id, item.expect_number) diff --git a/frontend/src/pages/News.jsx b/frontend/src/pages/News.jsx index b72d681..8a52141 100644 --- a/frontend/src/pages/News.jsx +++ b/frontend/src/pages/News.jsx @@ -1,7 +1,7 @@ /** * News - 资讯列表页面 - * Version: 0.0.7 (2026-04-24) - * 更新:network_matched_count缓存机制 + * Version: 0.0.8 (2026-04-24) + * 稳定版:自有匹配+网络匹配缓存 */ import React, { useState, useEffect } from 'react' @@ -44,6 +44,8 @@ export default function News() { const [matchCollections, setMatchCollections] = useState([]) const [networkMatchCollections, setNetworkMatchCollections] = useState([]) const [showNetworkMatchList, setShowNetworkMatchList] = useState(false) + const [networkMatchInfoId, setNetworkMatchInfoId] = useState(null) + const [networkMatchTotalCount, setNetworkMatchTotalCount] = useState(0) const [customModal, setCustomModal] = useState({show: false, title: '', content: ''}) const [seekForm, setSeekForm] = useState({ edition: '龙钞', type: '', category: '寻号', price: '', matchType: '模糊', features: '', content: '', title: '', contact: getUserPhone() || '' @@ -817,7 +819,7 @@ export default function News() { > 自有{item.matched_count || 0}条藏品匹配成功 - {item.network_matched_count !== undefined && ( + {item.network_matched_count !== undefined && item.network_matched_count > 0 && ( fetchNetworkMatchCollections(item.id)} @@ -1058,7 +1060,7 @@ export default function News() {
-

匹配藏品清单(网络数据)

+

匹配藏品清单(网络数据{networkMatchTotalCount > 0 ? `共${networkMatchTotalCount}条` : ''})

{networkMatchCollections.length === 0 ? (