From bcfa5143e3795617ef96f8e5cc9d8c000c2d5bf3 Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 1 Feb 2026 02:23:21 -0800 Subject: [PATCH] =?UTF-8?q?fix(mining-app):=20C2C=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0?= =?UTF-8?q?=EF=BC=8C=E5=88=97=E8=A1=A8=E5=88=B7=E6=96=B0=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E7=BC=A9=E7=9F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 订单详情 Provider 活跃状态(PENDING/MATCHED/PAID)每10秒自动刷新 过期/完成/取消后停止刷新,节省资源 - 市场订单和我的订单列表刷新间隔从1分钟缩短到30秒 - 离开订单详情页时立即刷新市场和我的订单列表 确保过期恢复的新PENDING订单及时在列表中显示 Co-Authored-By: Claude Opus 4.5 --- .../pages/c2c/c2c_order_detail_page.dart | 10 ++++++++++ .../presentation/providers/c2c_providers.dart | 17 ++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/frontend/mining-app/lib/presentation/pages/c2c/c2c_order_detail_page.dart b/frontend/mining-app/lib/presentation/pages/c2c/c2c_order_detail_page.dart index 0b73e0b7..b8304e41 100644 --- a/frontend/mining-app/lib/presentation/pages/c2c/c2c_order_detail_page.dart +++ b/frontend/mining-app/lib/presentation/pages/c2c/c2c_order_detail_page.dart @@ -42,6 +42,16 @@ class _C2cOrderDetailPageState extends ConsumerState { }); } + @override + void dispose() { + // 离开详情页时刷新市场和我的订单列表(确保过期恢复的新订单及时显示) + ref.invalidate(c2cOrdersProvider(null)); + ref.invalidate(c2cOrdersProvider('BUY')); + ref.invalidate(c2cOrdersProvider('SELL')); + ref.invalidate(myC2cOrdersProvider); + super.dispose(); + } + @override Widget build(BuildContext context) { final orderAsync = ref.watch(c2cOrderDetailProvider(widget.orderNo)); diff --git a/frontend/mining-app/lib/presentation/providers/c2c_providers.dart b/frontend/mining-app/lib/presentation/providers/c2c_providers.dart index 018e157e..3bf2f949 100644 --- a/frontend/mining-app/lib/presentation/providers/c2c_providers.dart +++ b/frontend/mining-app/lib/presentation/providers/c2c_providers.dart @@ -11,7 +11,7 @@ final c2cOrdersProvider = FutureProvider.family( final result = await dataSource.getC2cOrders(type: type); ref.keepAlive(); - final timer = Timer(const Duration(minutes: 1), () { + final timer = Timer(const Duration(seconds: 30), () { ref.invalidateSelf(); }); ref.onDispose(() => timer.cancel()); @@ -27,7 +27,7 @@ final myC2cOrdersProvider = FutureProvider( final result = await dataSource.getMyC2cOrders(); ref.keepAlive(); - final timer = Timer(const Duration(minutes: 1), () { + final timer = Timer(const Duration(seconds: 30), () { ref.invalidateSelf(); }); ref.onDispose(() => timer.cancel()); @@ -37,10 +37,21 @@ final myC2cOrdersProvider = FutureProvider( ); /// C2C订单详情 Provider(autoDispose: 每次进入详情页都获取最新数据) +/// 活跃状态订单(PENDING/MATCHED/PAID)每10秒自动刷新,终态订单不刷新 final c2cOrderDetailProvider = FutureProvider.autoDispose.family( (ref, orderNo) async { final dataSource = getIt(); - return dataSource.getC2cOrderDetail(orderNo); + final result = await dataSource.getC2cOrderDetail(orderNo); + + // 活跃状态订单自动刷新(过期/完成/取消后停止刷新) + if (result.isPending || result.isMatched || result.isPaid) { + final timer = Timer(const Duration(seconds: 10), () { + ref.invalidateSelf(); + }); + ref.onDispose(() => timer.cancel()); + } + + return result; }, );