Sync desktop daily logs and fix emulator ADB upstream connections
This commit is contained in:
1 parent
87e1fff59b
commit
0d269f3ded
15 files changed
+139
-12
No files matched your search
@@ -8,8 +8,9 @@ using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace Ads.Desktop;
|
||||
|
||||
public sealed record DeviceItem(string Id, bool Busy, bool IsLocal, bool Online = true, string LocalSummary = "")
|
||||
public sealed record DeviceItem(string Id, bool Busy, bool IsLocal, bool Online = true, string LocalSummary = "", string ComputerName="", string AgentId="")
|
||||
{
|
||||
public string ComputerLabel => "电脑:"+(ComputerName.Length==0?"未上报电脑名":ComputerName)+(AgentId.Length==0?"":" · "+AgentId);
|
||||
public string Description => IsLocal ? "本机 · " + LocalSummary : !Online ? "远程暂时离线" : Busy ? "在线 · 其他客户端使用中" : "在线 · 可连接";
|
||||
}
|
||||
|
||||
@@ -143,9 +144,13 @@ public partial class MainViewModel : ObservableObject, IDisposable
|
||||
return text;
|
||||
}
|
||||
|
||||
private DailyLog? dailyLog;
|
||||
public string LogFolder => Path.Combine(folder,"logs");
|
||||
[RelayCommand] private void OpenLogFolder(){try{Directory.CreateDirectory(LogFolder);Process.Start(new ProcessStartInfo(LogFolder){UseShellExecute=true});}catch(Exception error){Report(error);}}
|
||||
private void Log(string message)
|
||||
{
|
||||
var line = $"{DateTime.Now:HH:mm:ss} {Redact(message)}";
|
||||
var safe=Redact(message);(dailyLog ??= new DailyLog(LogFolder)).Write(safe);
|
||||
var line = $"{DateTime.Now:HH:mm:ss} {safe}";
|
||||
void Append() { if (disposed) return; Logs.Add(line); while (Logs.Count > 1000) Logs.RemoveAt(0); }
|
||||
if (Dispatcher.UIThread.CheckAccess()) Append(); else Dispatcher.UIThread.Post(Append);
|
||||
}
|
||||
@@ -202,7 +207,7 @@ public partial class MainViewModel : ObservableObject, IDisposable
|
||||
Devices.Clear();
|
||||
foreach (var row in rows) {
|
||||
var connection = sessions.GetValueOrDefault(row.Id);
|
||||
Devices.Add(new DeviceItem(row.Id, row.Busy || connection?.HasConnection == true, connection?.HasConnection == true, true, connection?.Status ?? ""));
|
||||
Devices.Add(new DeviceItem(row.Id, row.Busy || connection?.HasConnection == true, connection?.HasConnection == true, true, connection?.Status ?? "",row.ComputerName,row.AgentId));
|
||||
}
|
||||
foreach (var local in Connections.Where(c => rows.All(r => r.Id != c.DeviceId)))
|
||||
Devices.Add(new DeviceItem(local.DeviceId, true, true, false, local.Status));
|
||||
|
||||
Reference in new issue
Block a user