fix: 修正投屏授权状态与窗口生命周期,避免串流状态错乱

This commit is contained in:
tongtong committed 2026-11-28 02:59:49 +08:00
1 parent a0b77a3e7a
commit 4c9d006d11
6 files changed
+134 -90

No files matched your search

@@ -10,6 +10,7 @@ class MirrorBar extends StatelessWidget {
required this.connected,
required this.streaming,
required this.windowOpen,
required this.granted,
required this.busy,
required this.resolution,
required this.frames,
@@ -20,6 +21,7 @@ class MirrorBar extends StatelessWidget {
final bool connected;
final bool streaming;
final bool windowOpen;
final bool granted;
final bool busy;
final String resolution;
final int frames;
@@ -72,7 +74,7 @@ class MirrorBar extends StatelessWidget {
SizedBox(
width: double.infinity,
child: FilledButton.icon(
onPressed: connected && !busy && !streaming ? onRequest : null,
onPressed: connected && !busy && !windowOpen ? onRequest : null,
icon: Icon(
streaming ? Icons.cast_connected : Icons.play_circle_outline,
),
@@ -86,28 +88,30 @@ class MirrorBar extends StatelessWidget {
}
String _statusText() {
if (error.isNotEmpty) return '异常';
if (streaming) return '接收画面中';
if (error.isNotEmpty) return '异常';
if (windowOpen && granted) return '已允许,等待画面';
if (windowOpen) return '等待被控端确认';
if (connected) return '已连接,未投屏';
return '未连接';
}
Color _statusColor(ThemeData theme) {
if (error.isNotEmpty) return theme.colorScheme.error;
if (streaming) return Colors.green;
if (error.isNotEmpty) return theme.colorScheme.error;
if (windowOpen) return Colors.orange;
if (connected) return theme.colorScheme.primary;
return theme.colorScheme.outline;
}
String _detailText() {
if (error.isNotEmpty) return error;
if (!connected) return '先在上方连接被控端,再请求投屏';
if (streaming) {
final size = resolution.isEmpty ? '未知分辨率' : resolution;
return '$size · 已接收 $frames 帧 · 关闭独立窗口会立即停止投屏';
}
if (error.isNotEmpty) return error;
if (windowOpen && granted) return '被控端已允许投屏,正在等待首帧';
if (windowOpen) return '已向被控端发送投屏请求,请在其弹窗中点击「允许」';
return '点击「请求投屏」会按视频比例弹出独立窗口播放画面';
}