From a2e6d328f09366abf39a3df5400fb8006ecbe252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Fri, 24 Apr 2026 14:34:01 +0800 Subject: [PATCH] =?UTF-8?q?v0.0.9=20-=20=E5=AF=BB=E9=85=8D=E5=8F=B7?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=A8=B3=E5=AE=9A=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 自有匹配:正常计算 - 网络匹配:使用缓存方式(数据库字段) - 加载速度:0.06秒 News.jsx: 0.0.7 → 0.0.8 seek.py: 0.0.8 → 0.0.9 --- backend/app/routers/seek.py | 19 ++++++++----------- frontend/src/pages/News.jsx | 10 ++++++---- 2 files changed, 14 insertions(+), 15 deletions(-) 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 ? (