fix(sender): 串流窗口锁定视频比例,关窗即停流,修正文件传输取 IP
- 独立窗口首帧到达后按视频宽高比自动调整并居中;WM_SIZING 锁定比例,最小 320x180 - 去掉 WS_MAXIMIZEBOX 与双击/F11 全屏,只保留关闭与最小化 - 移除停止投屏按钮;WM_DESTROY 通过 ttstd/video 通道回调 windowClosed,Dart 侧下发 stopMirror - 文件传输地址优先取设备局域网 IP,取不到时回退控制通道 peerIp,并在文件页提供可编辑 IP 输入
This commit is contained in:
1 parent
d3ff293877
commit
d8357a8491
8 files changed
+321
-127
No files matched your search
@@ -20,19 +20,22 @@ class FileBrowserPage extends StatefulWidget {
|
||||
final int initialPort;
|
||||
final String initialToken;
|
||||
|
||||
/// 用户改了端口/令牌并保存时通知主界面写回设置。
|
||||
final void Function(int port, String token)? onConfigChanged;
|
||||
/// 用户改了地址/端口/令牌并保存时通知主界面写回设置。
|
||||
final void Function(String host, int port, String token)? onConfigChanged;
|
||||
|
||||
@override
|
||||
State<FileBrowserPage> createState() => _FileBrowserPageState();
|
||||
}
|
||||
|
||||
class _FileBrowserPageState extends State<FileBrowserPage> {
|
||||
late final TextEditingController _hostController =
|
||||
TextEditingController(text: widget.host);
|
||||
late final TextEditingController _portController =
|
||||
TextEditingController(text: widget.initialPort.toString());
|
||||
late final TextEditingController _tokenController =
|
||||
TextEditingController(text: widget.initialToken);
|
||||
|
||||
late String _host = widget.host;
|
||||
late int _port = widget.initialPort;
|
||||
late String _token = widget.initialToken;
|
||||
|
||||
@@ -58,15 +61,15 @@ class _FileBrowserPageState extends State<FileBrowserPage> {
|
||||
}
|
||||
|
||||
Future<void> _connect() async {
|
||||
if (widget.host.isEmpty) {
|
||||
setState(() => _error = '还没有选中设备,请先连接被控端');
|
||||
if (_host.isEmpty || _host == '127.0.0.1') {
|
||||
setState(() => _error = '还没有拿到被控端的局域网 IP,请在上方「IP」里手动填写(例如 192.168.1.23)');
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
_loading = true;
|
||||
_error = null;
|
||||
});
|
||||
final client = AndroidFileClient(host: widget.host, port: _port, token: _token);
|
||||
final client = AndroidFileClient(host: _host, port: _port, token: _token);
|
||||
try {
|
||||
final info = await client.info();
|
||||
final directory = await client.browse('');
|
||||
@@ -224,13 +227,15 @@ class _FileBrowserPageState extends State<FileBrowserPage> {
|
||||
}
|
||||
|
||||
void _saveConfig() {
|
||||
final host = _hostController.text.trim();
|
||||
final port = int.tryParse(_portController.text.trim()) ?? _port;
|
||||
final token = _tokenController.text.trim();
|
||||
setState(() {
|
||||
_host = host;
|
||||
_port = port;
|
||||
_token = token;
|
||||
});
|
||||
widget.onConfigChanged?.call(port, token);
|
||||
widget.onConfigChanged?.call(host, port, token);
|
||||
_toast('参数已保存');
|
||||
_connect();
|
||||
}
|
||||
@@ -256,7 +261,7 @@ class _FileBrowserPageState extends State<FileBrowserPage> {
|
||||
title: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(widget.host.isEmpty ? '文件传输' : '${widget.host}:$_port'),
|
||||
Text(_host.isEmpty ? '文件传输' : '$_host:$_port'),
|
||||
if (_alias.isNotEmpty)
|
||||
Text(_alias, style: theme.textTheme.bodySmall),
|
||||
],
|
||||
@@ -306,6 +311,18 @@ class _FileBrowserPageState extends State<FileBrowserPage> {
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: TextField(
|
||||
controller: _hostController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'IP',
|
||||
hintText: '192.168.1.23',
|
||||
isDense: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: TextField(
|
||||
controller: _portController,
|
||||
@@ -316,9 +333,12 @@ class _FileBrowserPageState extends State<FileBrowserPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: TextField(
|
||||
controller: _tokenController,
|
||||
decoration: const InputDecoration(
|
||||
|
||||
Reference in new issue
Block a user