From 29d236f3fed97a8aa2b2d6c500d1c90cbec0a0d5 Mon Sep 17 00:00:00 2001 From: shenlei Date: Thu, 15 Oct 2026 13:47:56 +0900 Subject: [PATCH] Add copy-all-logs buttons and log status refresh failures Co-Authored-By: Claude Code --- .../lib/features/detail_pages.dart | 13 ++++++++ .../meshport_lab/lib/features/lab_screen.dart | 31 ++++++++++++++----- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/apps/meshport_lab/lib/features/detail_pages.dart b/apps/meshport_lab/lib/features/detail_pages.dart index a0423a9..f951a61 100644 --- a/apps/meshport_lab/lib/features/detail_pages.dart +++ b/apps/meshport_lab/lib/features/detail_pages.dart @@ -234,6 +234,19 @@ class _LogsPageBodyState extends State { Wrap( spacing: 12, children: [ + OutlinedButton( + onPressed: () async { + await Clipboard.setData( + ClipboardData(text: widget.logs.join('\n')), + ); + if (context.mounted) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar(content: Text('已复制全部 ${widget.logs.length} 条日志')), + ); + } + }, + child: const Text('复制全部日志'), + ), OutlinedButton( onPressed: () async { await Clipboard.setData( diff --git a/apps/meshport_lab/lib/features/lab_screen.dart b/apps/meshport_lab/lib/features/lab_screen.dart index f895c00..521cb19 100644 --- a/apps/meshport_lab/lib/features/lab_screen.dart +++ b/apps/meshport_lab/lib/features/lab_screen.dart @@ -348,6 +348,7 @@ class _LabScreenState extends State { setState(() => status = next); } } catch (e) { + log('状态刷新失败 · $e'); if (mounted && proxySession?.state == 'Failed') { setState(() { status = {'state': 'Failed', 'peer_count': 0}; @@ -1055,7 +1056,17 @@ class _LabScreenState extends State { ]), speedPanel(), if (logs.isNotEmpty) - panel('最近事件', logs.take(3).map((line) => Text(line)).toList()), + panel('最近事件', [ + ...logs.take(3).map((line) => Text(line)), + TextButton.icon( + onPressed: () async { + await Clipboard.setData(ClipboardData(text: logs.join('\n'))); + log('已复制全部运行日志(${logs.length} 条)'); + }, + icon: const Icon(Icons.copy), + label: Text('复制全部日志(${logs.length} 条)'), + ), + ]), ], ); } @@ -1155,18 +1166,24 @@ class _LabScreenState extends State { label: const Text('复制网络诊断'), ), ]), - panel( - '最近事件', - logs + panel('最近事件', [ + ...logs .take(4) .map( (v) => Padding( padding: const EdgeInsets.only(bottom: 8), child: Text(v), ), - ) - .toList(), - ), + ), + TextButton.icon( + onPressed: () async { + await Clipboard.setData(ClipboardData(text: logs.join('\n'))); + log('已复制全部运行日志(${logs.length} 条)'); + }, + icon: const Icon(Icons.copy), + label: Text('复制全部日志(${logs.length} 条)'), + ), + ]), ], ); Widget nodes() => Column(