From caa2358bbddd2b901b16af6bcfe036a62019ff66 Mon Sep 17 00:00:00 2001 From: zhaoxing <2558691827@qq.com> Date: Sun, 8 Nov 2026 11:22:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(consignment):=20=E5=8F=91=E5=B8=83=E5=90=8E?= =?UTF-8?q?=E5=8D=B3=E6=97=B6=E5=88=B7=E6=96=B0=E5=AF=84=E5=8D=96=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E4=B8=8A=E9=99=90=E5=8D=A0=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/worker/WorkerConsignmentPage.tsx | 21 ++++++--- .../tests/consignment-publish-limits.test.ts | 43 +++++++++++++++++++ 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/apps/frontend/src/pages/worker/WorkerConsignmentPage.tsx b/apps/frontend/src/pages/worker/WorkerConsignmentPage.tsx index b8c6b493..4dcc148a 100644 --- a/apps/frontend/src/pages/worker/WorkerConsignmentPage.tsx +++ b/apps/frontend/src/pages/worker/WorkerConsignmentPage.tsx @@ -198,11 +198,11 @@ export default function WorkerConsignmentPage() { }), }) - // 已发布的分类寄卖配置 → 打手端动态 tab + // 已发布的分类寄卖配置 → 打手端动态 tab。 + // activeQuantity(在售+待审核占用)是动态值:不设 staleTime,进入页面/窗口聚焦都拉最新。 const consignmentProfilesQuery = useQuery({ queryKey: ['worker-consignment-profiles'], queryFn: () => fetchWorkerConsignmentProfiles(), - staleTime: 60_000, }) const consignmentProfiles = consignmentProfilesQuery.data?.data.profiles || [] const selectedProfile: WorkerConsignmentProfile | null = @@ -247,10 +247,12 @@ export default function WorkerConsignmentPage() { const contactSupporters = consignmentContactsQuery.data?.data.items || [] const firstContactSupporterId = contactSupporters[0]?.id ?? null - // 切换标签页时自动刷新最新数据 + // 切换标签页时自动刷新最新数据;回到发布页时同步刷新各分类占用(activeQuantity) useEffect(() => { if (activeTab === 'records') { void queryClient.invalidateQueries({ queryKey: ['worker-my-consignments'] }) + } else { + void queryClient.invalidateQueries({ queryKey: ['worker-consignment-profiles'] }) } void queryClient.invalidateQueries({ queryKey: ['worker-profile'] }) }, [activeTab, queryClient]) @@ -586,7 +588,12 @@ export default function WorkerConsignmentPage() { setPriceState({ status: 'idle' }) lastPriceQueryKeyRef.current = '' setIntakeImages({}) - await Promise.all([myConsignmentsQuery.refetch(), profileQuery.refetch()]) + await Promise.all([ + myConsignmentsQuery.refetch(), + profileQuery.refetch(), + // 发布后立即刷新各分类占用,否则同一页面连续发布仍显示发布前的剩余额度 + consignmentProfilesQuery.refetch(), + ]) setRecordFilter('reviewing') setActiveTab('records') } catch (err: any) { @@ -1123,8 +1130,10 @@ export default function WorkerConsignmentPage() {