feat: migrate Flutter to Cupertino with daily logs and computer groups

This commit is contained in:
tongtong committed 2026-11-13 11:27:46 +08:00
1 parent c568749d23
commit 87e1fff59b
22 files changed
+808 -55

No files matched your search

+58 -13
View File
@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:material_ui/material_ui.dart';
import 'app_widgets.dart';
import 'package:flutter/services.dart';
import '../data/windows_usb.dart';
@@ -34,7 +35,7 @@ class _ManagerViewState extends State<ManagerView> {
SizedBox(
width: 204,
child: Material(
color: const Color(0xFF14233F),
color: const Color(0xFFF0F2F7),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -43,7 +44,7 @@ class _ManagerViewState extends State<ManagerView> {
child: Text(
'ADS',
style: TextStyle(
color: Colors.white,
color: Color(0xFF182235),
fontSize: 32,
fontWeight: FontWeight.w800,
),
@@ -53,7 +54,7 @@ class _ManagerViewState extends State<ManagerView> {
padding: EdgeInsets.fromLTRB(24, 0, 16, 36),
child: Text(
'设备管理中心 / Flutter',
style: TextStyle(color: Colors.white60, fontSize: 12),
style: TextStyle(color: Colors.blueGrey, fontSize: 12),
),
),
for (final (i, title, icon) in [
@@ -71,15 +72,15 @@ class _ManagerViewState extends State<ManagerView> {
),
child: ListTile(
selected: page == i,
selectedTileColor: const Color(0xFF29446C),
selectedTileColor: const Color(0xFFE4ECFF),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
leading: Icon(icon, color: Colors.white70, size: 21),
leading: Icon(icon, color: Colors.blueGrey, size: 21),
title: Text(
title,
style: const TextStyle(
color: Colors.white,
color: Color(0xFF182235),
fontSize: 14,
),
),
@@ -98,7 +99,7 @@ class _ManagerViewState extends State<ManagerView> {
child: Text(
'Windows · 网络 ADB\n关闭窗口后保留在托盘',
style: TextStyle(
color: Colors.white54,
color: Colors.blueGrey,
height: 1.8,
fontSize: 12,
),
@@ -167,7 +168,12 @@ class _ManagerViewState extends State<ManagerView> {
],
),
),
if (m.refreshing) const LinearProgressIndicator(minHeight: 2),
SizedBox(
height: 3,
child: m.refreshing
? const LinearProgressIndicator(minHeight: 3)
: null,
),
Expanded(
child: Padding(
padding: const EdgeInsets.all(24),
@@ -252,8 +258,18 @@ class _ManagerViewState extends State<ManagerView> {
all.putIfAbsent(id, () => Device(id, false));
}
final rows = all.values
.where((d) => d.id.toLowerCase().contains(search.toLowerCase()))
.where(
(d) => '${d.id} ${d.computerName} ${d.agentId}'
.toLowerCase()
.contains(search.toLowerCase()),
)
.toList();
rows.sort((a, b) {
final host = '${a.computerName} ${a.agentId}'.compareTo(
'${b.computerName} ${b.agentId}',
);
return host != 0 ? host : a.id.compareTo(b.id);
});
return Column(
children: [
Row(
@@ -276,7 +292,7 @@ class _ManagerViewState extends State<ManagerView> {
child: TextField(
onChanged: (v) => setState(() => search = v),
decoration: const InputDecoration(
hintText: '搜索设备 ID',
hintText: '搜索手机或电脑名',
prefixIcon: Icon(Icons.search),
filled: true,
fillColor: Colors.white,
@@ -320,7 +336,24 @@ class _ManagerViewState extends State<ManagerView> {
: ListView.separated(
itemCount: rows.length,
separatorBuilder: (_, index) => const SizedBox(height: 12),
itemBuilder: (context, i) => deviceCard(rows[i]),
itemBuilder: (context, i) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (i == 0 || rows[i].agentId != rows[i - 1].agentId)
Padding(
padding: const EdgeInsets.only(top: 6, bottom: 10),
child: Text(
'电脑 · ${rows[i].computerName.isEmpty ? "未上报电脑名" : rows[i].computerName}${rows[i].agentId.isEmpty ? "" : " / ${rows[i].agentId}"}',
style: const TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: Colors.blueGrey,
),
),
),
deviceCard(rows[i]),
],
),
),
),
],
@@ -361,6 +394,13 @@ class _ManagerViewState extends State<ManagerView> {
fontSize: 17,
),
),
Text(
'电脑:${d.computerName.isEmpty ? "旧 Agent(未上报电脑名)" : d.computerName}${d.agentId.isEmpty ? "" : " · ${d.agentId}"}',
style: const TextStyle(
fontSize: 12,
color: Colors.blueGrey,
),
),
const SizedBox(height: 5),
Text(
s?.state ?? (d.busy ? '其他客户端占用' : '空闲 · 可连接'),
@@ -515,7 +555,12 @@ class _ManagerViewState extends State<ManagerView> {
children: [
Row(
children: [
const Text('最近 500 条 · 仅保存在内存'),
Expanded(
child: Text(
'最近 500 条 · 按天保存,单文件 5 MiB,保留 14 天\n${m.logDirectory}${m.diskLog.error == null ? "" : "\n日志写入失败:${m.diskLog.error}"}',
style: const TextStyle(fontSize: 12),
),
),
const Spacer(),
TextButton(
onPressed: () =>