Adopt Semi desktop theme and fix UTF-8 process logs for 0.2.3

This commit is contained in:
tongtong committed 2026-11-13 14:56:19 +08:00
1 parent 5b3022e1f3
commit dc8edf0df6
16 files changed
+161 -55

No files matched your search

Generated
+6 -6
View File
@@ -4,7 +4,7 @@ version = 4
[[package]]
name = "ads-agent"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"ads-core",
"ads-management",
@@ -21,7 +21,7 @@ dependencies = [
[[package]]
name = "ads-client"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"ads-core",
"anyhow",
@@ -32,7 +32,7 @@ dependencies = [
[[package]]
name = "ads-core"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"anyhow",
"bytes",
@@ -51,7 +51,7 @@ dependencies = [
[[package]]
name = "ads-management"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"ads-core",
"anyhow",
@@ -67,7 +67,7 @@ dependencies = [
[[package]]
name = "ads-usb"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"anyhow",
"clap",
@@ -78,7 +78,7 @@ dependencies = [
[[package]]
name = "adsctl"
version = "0.2.2"
version = "0.2.3"
dependencies = [
"ads-core",
"ads-management",
+1 -1
View File
@@ -3,7 +3,7 @@ members = ["crates/ads-core", "agent", "client", "usb", "crates/ads-management",
resolver = "2"
[workspace.package]
version = "0.2.2"
version = "0.2.3"
edition = "2021"
license = "MIT"
+45 -1
View File
@@ -19,12 +19,24 @@ internal static class Program
Thread.Sleep(Timeout.Infinite);
return 0;
}
if (args.Contains("--encoding-child"))
{
var bytes=System.Text.Encoding.UTF8.GetBytes("连接已建立:中文日志 ✓ 📱\n");
Console.OpenStandardOutput().Write(bytes);Console.OpenStandardError().Write(bytes);
return 0;
}
if (args.Contains("--encoding-input"))
{
using var reader=new StreamReader(Console.OpenStandardInput(),System.Text.Encoding.UTF8);
var bytes=System.Text.Encoding.UTF8.GetBytes(reader.ReadToEnd());Console.OpenStandardOutput().Write(bytes);
return 0;
}
AppBuilder.Configure<App>().UseSkia().UseHeadless(new AvaloniaHeadlessPlatformOptions { UseHeadlessDrawing = false }).SetupWithoutStarting();
using var finished = new CancellationTokenSource();
Exception? failure = null;
Dispatcher.UIThread.Post(async () =>
{
try { if (args.Contains("--agents")) await RunAgentsAsync(args.Contains("--local-agent")); else if (args.Contains("--multi")) await RunMultiAsync(args.Contains("--usb")); else await RunAsync(args.Contains("--live"), args.Contains("--screen"), args.Contains("--usb")); }
try { if(args.Contains("--theme-preview")) await PreviewThemeAsync(); else if (args.Contains("--agents")) await RunAgentsAsync(args.Contains("--local-agent")); else if (args.Contains("--multi")) await RunMultiAsync(args.Contains("--usb")); else await RunAsync(args.Contains("--live"), args.Contains("--screen"), args.Contains("--usb")); }
catch (Exception error) { failure = error; }
finally { finished.Cancel(); }
});
@@ -33,6 +45,38 @@ internal static class Program
return 0;
}
private static async Task PreviewThemeAsync()
{
var root=DesktopPaths.ProjectRoot()!;
using var vm=new MainViewModel(Path.Combine(root,"work","semi-preview"),backgroundMonitoring:false,loadLocalCredentials:false);
vm.AutoRefresh=false;vm.AgentManager.AutoRefresh=false;
vm.Devices.Add(new DeviceItem("home-phone",false,false,ComputerName:"家里的 Windows",AgentId:"home-pc"));
vm.Devices.Add(new DeviceItem("pixel-test",false,false,ComputerName:"Ubuntu 实验室",AgentId:"ubuntu-224"));
vm.Devices.Add(new DeviceItem("android-phone",true,false,ComputerName:"办公电脑",AgentId:"office-pc"));
vm.Logs.Add("13:20:10 已连接设备 · 中文日志正常显示 ✓ 📱");
vm.Logs.Add("13:20:11 设备离线,等待自动重连。拒绝访问,请检查权限。");
vm.AgentManager.RemoteLogText="[INFO] 设备发现完成:3 台手机。\n[INFO] 连接已建立:中文日志正常。";
var window=new MainWindow {DataContext=vm};window.Show();
try {
var tabs=window.FindControl<TabControl>("MainTabs")!;
foreach(var dark in new[]{false,true}) {
var theme=dark?"dark":"light";
window.FindControl<ToggleSwitch>("ThemeSwitch")!.IsChecked=dark;
Require(Application.Current!.RequestedThemeVariant==(dark?Avalonia.Styling.ThemeVariant.Dark:Avalonia.Styling.ThemeVariant.Light),"Theme switch did not update the application");
for(var page=0;page<4;page++) {
tabs.SelectedIndex=page;window.Width=1240;window.Height=880;
await Task.Delay(220);
using var frame=window.CaptureRenderedFrame();
Require(frame!=null,"Semi frame was not rendered");
frame!.Save(Path.Combine(root,"work",$"semi-{theme}-{page}.png"));
}
tabs.SelectedIndex=0;window.Width=980;window.Height=700;await Task.Delay(220);
using var compact=window.CaptureRenderedFrame();compact!.Save(Path.Combine(root,"work",$"semi-{theme}-compact.png"));
}
Console.WriteLine("PASS: Semi light/dark pages and 980x700 compact layout rendered");
} finally { await vm.ShutdownAsync();window.Close(); }
}
private static void Require(bool condition, string message)
{
if (!condition) throw new InvalidOperationException(message);
@@ -0,0 +1,36 @@
using System.Text;
using System.Diagnostics;
using Ads.Desktop;
using Xunit;
namespace Ads.Desktop.Tests;
public class ProcessEncodingTests {
const string Text="连接已建立:中文日志 ✓ 📱";
static ProcessStartInfo Child(string argument) {
var configuration=new DirectoryInfo(AppContext.BaseDirectory).Parent!.Name;
var file=Path.Combine(DesktopPaths.ProjectRoot()!,"desktop","Ads.Desktop.Smoke","bin",configuration,"net8.0","Ads.Desktop.Smoke.dll");
return ProcessTools.CreateStartInfo("dotnet",[file,argument]);
}
[Fact] public async Task CapturedUnicodeOutputAndErrorsAreUtf8() {
var info=Child("--encoding-child");
Assert.Equal(65001,info.StandardOutputEncoding!.CodePage);Assert.Equal(65001,info.StandardErrorEncoding!.CodePage);
var result=await ProcessTools.RunAsync(info);
Assert.Equal(0,result.ExitCode);Assert.Equal(Text,result.Output.Trim());Assert.Equal(Text,result.Error.Trim());
}
[Fact] public async Task StreamingUnicodeLogsAreUtf8() {
using var process=new Process {StartInfo=Child("--encoding-child")};
var output=new TaskCompletionSource<string>();var error=new TaskCompletionSource<string>();
process.OutputDataReceived+=(_,e)=>{if(e.Data!=null)output.TrySetResult(e.Data);};
process.ErrorDataReceived+=(_,e)=>{if(e.Data!=null)error.TrySetResult(e.Data);};
process.Start();process.BeginOutputReadLine();process.BeginErrorReadLine();
await process.WaitForExitAsync().WaitAsync(TimeSpan.FromSeconds(10));
Assert.Equal(Text,await output.Task.WaitAsync(TimeSpan.FromSeconds(3)));Assert.Equal(Text,await error.Task.WaitAsync(TimeSpan.FromSeconds(3)));
}
[Fact] public async Task AgentJsonInputRetainsChinese() {
var info=Child("--encoding-input");info.RedirectStandardInput=true;info.StandardInputEncoding=new UTF8Encoding(false);
using var process=Process.Start(info)!;
await process.StandardInput.WriteAsync("{\"name\":\"家里的电脑\"}");process.StandardInput.Close();
var output=process.StandardOutput.ReadToEndAsync();
await process.WaitForExitAsync().WaitAsync(TimeSpan.FromSeconds(10));
Assert.Equal("{\"name\":\"家里的电脑\"}",await output);
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup><Version>0.2.2</Version><OutputType>WinExe</OutputType><TargetFramework>net8.0</TargetFramework><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings></PropertyGroup>
<ItemGroup><PackageReference Include="Avalonia.Desktop" Version="11.3.8"/><PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.8"/><PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/></ItemGroup>
<PropertyGroup><Version>0.2.3</Version><OutputType>WinExe</OutputType><TargetFramework>net8.0</TargetFramework><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings></PropertyGroup>
<ItemGroup><PackageReference Include="Avalonia.Desktop" Version="11.3.8"/><PackageReference Include="Semi.Avalonia" Version="11.3.7.3"/><PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/></ItemGroup>
<ItemGroup><AvaloniaResource Include="Assets/**"/></ItemGroup></Project>
+6 -11
View File
@@ -1,9 +1,4 @@
<UserControl xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Ads.Desktop.AgentManagementView">
<UserControl.Styles>
<Style Selector="Border.agentCard"><Setter Property="Background" Value="#192230"/><Setter Property="CornerRadius" Value="10"/><Setter Property="Padding" Value="16"/></Style>
<Style Selector="Button"><Setter Property="Padding" Value="12,8"/><Setter Property="Margin" Value="0,0,8,6"/></Style>
<Style Selector="TextBox"><Setter Property="Margin" Value="0,4,0,10"/></Style>
</UserControl.Styles>
<Grid RowDefinitions="Auto,*,Auto" Margin="0,14,0,0">
<StackPanel>
<WrapPanel><CheckBox x:Name="LocalAgentMode" Content="管理本机 Agent" IsChecked="{Binding LocalMode}" IsEnabled="{Binding !IsBusy}" Margin="0,0,20,8"/><CheckBox Content="自动刷新" IsChecked="{Binding AutoRefresh}"/><Button x:Name="RefreshAgentsButton" Content="刷新 Agent" Command="{Binding RefreshAgentsCommand}" IsEnabled="{Binding !IsBusy}" Margin="20,0,0,10"/></WrapPanel>
@@ -11,9 +6,9 @@
<StackPanel IsVisible="{Binding LocalMode}"><TextBlock Text="本机配置路径"/><Grid ColumnDefinitions="*,Auto"><TextBox Text="{Binding ConfigPath}"/><Button Grid.Column="1" Content="选择" Click="ChooseConfigClick"/></Grid><WrapPanel><Button Content="启动后台 Agent" Command="{Binding StartLocalCommand}"/><Button Content="安装开机服务" Command="{Binding InstallServiceCommand}"/></WrapPanel></StackPanel>
</StackPanel>
<Grid Grid.Row="1" ColumnDefinitions="300,*">
<Border Classes="agentCard" Margin="0,0,14,0"><Grid RowDefinitions="Auto,*"><TextBlock Text="Agent / 被控电脑" FontSize="18" FontWeight="SemiBold"/><ListBox x:Name="AgentList" Grid.Row="1" ItemsSource="{Binding Agents}" SelectedItem="{Binding SelectedAgent}" Margin="0,10,0,0"><ListBox.ItemTemplate><DataTemplate><StackPanel Spacing="5" Margin="4,8"><TextBlock Text="{Binding Id}" FontSize="16"/><TextBlock Text="{Binding Description}" TextWrapping="Wrap" Foreground="#A8B7CC"/></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></Grid></Border>
<Border Classes="agentCard" Margin="0,0,14,0"><Grid RowDefinitions="Auto,*"><TextBlock Text="Agent / 被控电脑" FontSize="18" FontWeight="SemiBold"/><ListBox x:Name="AgentList" Grid.Row="1" ItemsSource="{Binding Agents}" SelectedItem="{Binding SelectedAgent}" Margin="0,10,0,0"><ListBox.ItemTemplate><DataTemplate><StackPanel Spacing="5" Margin="4,8"><TextBlock Text="{Binding Id}" FontSize="16"/><TextBlock Text="{Binding Description}" TextWrapping="Wrap" Foreground="{DynamicResource SemiColorText2}"/></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></Grid></Border>
<ScrollViewer Grid.Column="1"><StackPanel Spacing="14">
<Border Classes="agentCard"><StackPanel Spacing="10"><TextBlock Text="{Binding SelectedAgentDetails}" TextWrapping="Wrap" Foreground="#66D9C0"/><WrapPanel><Button x:Name="LoadAgentConfigButton" Content="读取配置" Command="{Binding LoadConfigCommand}"/><Button Content="重启 Agent" Command="{Binding RestartAgentCommand}"/></WrapPanel><TextBlock Text="重启由监督进程执行,设备连接会短暂中断。" FontSize="12" Foreground="#A8B7CC"/></StackPanel></Border>
<Border Classes="agentCard"><StackPanel Spacing="10"><TextBlock Text="{Binding SelectedAgentDetails}" TextWrapping="Wrap" Foreground="{DynamicResource SemiColorPrimary}"/><WrapPanel><Button x:Name="LoadAgentConfigButton" Content="读取配置" Command="{Binding LoadConfigCommand}"/><Button Content="重启 Agent" Command="{Binding RestartAgentCommand}"/></WrapPanel><TextBlock Text="重启由监督进程执行,设备连接会短暂中断。" FontSize="12" Foreground="{DynamicResource SemiColorText2}"/></StackPanel></Border>
<Border Classes="agentCard"><StackPanel Spacing="8">
<Button Content="发现 ADB 设备" Command="{Binding DiscoverDevicesCommand}" HorizontalAlignment="Left"/>
<ListBox ItemsSource="{Binding DiscoveredDevices}" SelectedItem="{Binding SelectedDiscoveredDevice}" MaxHeight="160"><ListBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding Description}" TextWrapping="Wrap"/></DataTemplate></ListBox.ItemTemplate></ListBox>
@@ -21,15 +16,15 @@
<ListBox x:Name="ManagedDevicesList" ItemsSource="{Binding AgentDevices}" SelectedItem="{Binding SelectedManagedDevice}" MinHeight="70" MaxHeight="180"><ListBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding Description}" TextWrapping="Wrap" Margin="3,7"/></DataTemplate></ListBox.ItemTemplate></ListBox>
<WrapPanel><Button Content="启用" Command="{Binding EnableDeviceCommand}"/><Button Content="停用" Command="{Binding DisableDeviceCommand}"/><Button Content="移除配置" Command="{Binding RemoveDeviceCommand}"/></WrapPanel>
<Grid ColumnDefinitions="*,*"><StackPanel><TextBlock Text="设备 ID"/><TextBox Text="{Binding DeviceId}" Watermark="home-phone"/></StackPanel><StackPanel Grid.Column="1" Margin="12,0,0,0"><TextBlock Text="手机 adbd 地址"/><TextBox Text="{Binding Target}" Watermark="192.168.1.10:5555"/></StackPanel></Grid>
<Expander Header="通过已有 ADB server 接入"><StackPanel><TextBlock Text="ADB 序列号(与手机地址二选一)"/><TextBox Text="{Binding AdbSerial}"/><TextBlock Text="ADB server 地址(留空使用 Agent 默认值)"/><TextBox Text="{Binding AdbServer}" Watermark="127.0.0.1:5037"/><TextBlock Text="此模式仍要求手机启用 TCP adbd。" Foreground="#A8B7CC"/></StackPanel></Expander>
<Expander Header="通过已有 ADB server 接入"><StackPanel><TextBlock Text="ADB 序列号(与手机地址二选一)"/><TextBox Text="{Binding AdbSerial}"/><TextBlock Text="ADB server 地址(留空使用 Agent 默认值)"/><TextBox Text="{Binding AdbServer}" Watermark="127.0.0.1:5037"/><TextBlock Text="此模式仍要求手机启用 TCP adbd。" Foreground="{DynamicResource SemiColorText2}"/></StackPanel></Expander>
<Button x:Name="AddManagedDeviceButton" Content="添加手机" Command="{Binding AddDeviceCommand}" HorizontalAlignment="Left"/>
</StackPanel></Border>
<Border Classes="agentCard"><StackPanel Spacing="8"><TextBlock Text="Agent 配置" FontSize="18" FontWeight="SemiBold"/><TextBlock Text="修改设备或地址会重建受影响的连接;Agent ID 保持固定。" Foreground="#A8B7CC" TextWrapping="Wrap"/><TextBox x:Name="AgentConfigBox" Text="{Binding ConfigJson}" AcceptsReturn="True" FontFamily="Cascadia Mono,Consolas" FontSize="12" MinHeight="200" MaxHeight="380" ScrollViewer.VerticalScrollBarVisibility="Auto"/><Button Content="保存并应用配置" Command="{Binding SaveConfigCommand}" HorizontalAlignment="Left"/>
<Border Classes="agentCard"><StackPanel Spacing="8"><TextBlock Text="Agent 配置" FontSize="18" FontWeight="SemiBold"/><TextBlock Text="修改设备或地址会重建受影响的连接;Agent ID 保持固定。" Foreground="{DynamicResource SemiColorText2}" TextWrapping="Wrap"/><TextBox x:Name="AgentConfigBox" Text="{Binding ConfigJson}" AcceptsReturn="True" FontFamily="Cascadia Mono,Consolas,Microsoft YaHei UI,Noto Sans CJK SC" FontSize="12" MinHeight="200" MaxHeight="380" ScrollViewer.VerticalScrollBarVisibility="Auto"/><Button Content="保存并应用配置" Command="{Binding SaveConfigCommand}" HorizontalAlignment="Left"/>
<StackPanel IsVisible="{Binding LocalMode}"><TextBlock Text="首次设置:填写上方配置及设备端凭据后初始化,再启动后台 Agent。" TextWrapping="Wrap"/><TextBlock Text="{Binding EnrollmentPath}" TextWrapping="Wrap"/><TextBox Text="{Binding EnrollmentToken}" PasswordChar="●" Watermark="ADS_AGENT_TOKEN"/><WrapPanel><Button Content="导入 agent.env" Click="ImportEnrollmentClick"/><Button Content="初始化本机配置" Command="{Binding InitializeLocalCommand}"/></WrapPanel></StackPanel>
</StackPanel></Border>
<Border Classes="agentCard"><StackPanel Spacing="8"><WrapPanel><Button Content="读取日志" Command="{Binding ReadLogsCommand}"/><CheckBox Content="持续跟随日志" IsChecked="{Binding FollowLogs}"/></WrapPanel><TextBox x:Name="AgentLogsBox" Text="{Binding RemoteLogText}" IsReadOnly="True" AcceptsReturn="True" FontFamily="Cascadia Mono,Consolas" FontSize="12" Height="200" ScrollViewer.VerticalScrollBarVisibility="Auto"/></StackPanel></Border>
<Border Classes="agentCard"><StackPanel Spacing="8"><WrapPanel><Button Content="读取日志" Command="{Binding ReadLogsCommand}"/><CheckBox Content="持续跟随日志" IsChecked="{Binding FollowLogs}"/></WrapPanel><TextBox x:Name="AgentLogsBox" Text="{Binding RemoteLogText}" IsReadOnly="True" AcceptsReturn="True" FontFamily="Cascadia Mono,Consolas,Microsoft YaHei UI,Noto Sans CJK SC" FontSize="12" Height="200" ScrollViewer.VerticalScrollBarVisibility="Auto"/></StackPanel></Border>
</StackPanel></ScrollViewer>
</Grid>
<TextBlock Grid.Row="2" x:Name="AgentNotice" Text="{Binding Notice}" TextWrapping="Wrap" Foreground="#A8B7CC" Margin="0,12,0,0"/>
<TextBlock Grid.Row="2" x:Name="AgentNotice" Text="{Binding Notice}" TextWrapping="Wrap" Foreground="{DynamicResource SemiColorText2}" Margin="0,12,0,0"/>
</Grid>
</UserControl>
@@ -136,7 +136,7 @@ public partial class AgentManagementViewModel : ObservableObject, IDisposable
private async Task<JsonElement> LocalRequestAsync(object request)
{
var executable=DesktopPaths.ResolveTool(DesktopPaths.FindTool("adsctl"),"adsctl");
var info=ProcessTools.CreateStartInfo(executable,["--json","--config",ConfigPath,"request"]);info.RedirectStandardInput=true;
var info=ProcessTools.CreateStartInfo(executable,["--json","--config",ConfigPath,"request"]);info.RedirectStandardInput=true;info.StandardInputEncoding=new System.Text.UTF8Encoding(false);
using var process=Process.Start(info) ?? throw new InvalidOperationException("adsctl 无法启动。");
var output=process.StandardOutput.ReadToEndAsync();var error=process.StandardError.ReadToEndAsync();
await process.StandardInput.WriteAsync(JsonSerializer.Serialize(request));process.StandardInput.Close();
@@ -219,7 +219,7 @@ public partial class AgentManagementViewModel : ObservableObject, IDisposable
if(!File.Exists(ConfigPath))throw new InvalidOperationException("请先导入 agent.env 并初始化本机配置,再启动 Agent。");
try { await LocalRequestAsync(new{op="status"});Notice="本机 Agent 已在运行。";return; } catch(InvalidOperationException){}
var info=ProcessTools.CreateStartInfo(DesktopPaths.ResolveTool(DesktopPaths.FindTool("ads-agent"),"ads-agent"),["--quiet","--supervise","--config",ConfigPath]);
info.RedirectStandardOutput=false;info.RedirectStandardError=false;
info.RedirectStandardOutput=false;info.RedirectStandardError=false;info.StandardOutputEncoding=null;info.StandardErrorEncoding=null;
using var process=Process.Start(info) ?? throw new InvalidOperationException("Agent 启动失败。");
await Task.Delay(700,lifetime.Token);await RefreshCoreAsync();Notice="后台 Agent 已启动,退出托盘不会停止它。";
});
+5 -2
View File
@@ -1,3 +1,6 @@
<Application xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Ads.Desktop.App" RequestedThemeVariant="Dark">
<Application.Styles><FluentTheme/></Application.Styles>
<Application xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:semi="https://irihi.tech/semi" x:Class="Ads.Desktop.App" RequestedThemeVariant="Light">
<Application.Styles>
<semi:SemiTheme Locale="zh-CN"/>
<StyleInclude Source="avares://Ads.Desktop/WorkbenchStyles.axaml"/>
</Application.Styles>
</Application>
+1 -1
View File
@@ -18,7 +18,7 @@ public partial class App : Application
Window window;
if(localAgentMode) {
vm.AgentManager.LocalMode=true;vm.AgentManager.StartMonitoring();
window=new Window {Title="ADS · 被控端 Agent 管理",Width=1100,Height=850,MinWidth=900,MinHeight=650,Background=Avalonia.Media.Brush.Parse("#10151F"),Content=new AgentManagementView{DataContext=vm.AgentManager,Margin=new Avalonia.Thickness(22)}};
window=new Window {Title="ADS · 被控端 Agent 管理",Width=1100,Height=850,MinWidth=900,MinHeight=650,Content=new AgentManagementView{DataContext=vm.AgentManager,Margin=new Avalonia.Thickness(22)}};
} else window = new MainWindow { DataContext = vm };
desktop.MainWindow = window;
desktop.ShutdownMode = ShutdownMode.OnExplicitShutdown;
+20 -27
View File
@@ -1,36 +1,29 @@
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Ads.Desktop"
x:Class="Ads.Desktop.MainWindow" Title="ADS · 公网设备工作台"
Width="1240" Height="880" MinWidth="980" MinHeight="700" Background="#10151F">
<Window.Styles>
<Style Selector="TextBox"><Setter Property="Margin" Value="0,5,0,12"/></Style>
<Style Selector="Button"><Setter Property="Padding" Value="15,10"/><Setter Property="Margin" Value="0,0,8,8"/></Style>
<Style Selector="TextBlock.label"><Setter Property="Foreground" Value="#9CAFC7"/></Style>
<Style Selector="TextBlock.section"><Setter Property="FontSize" Value="18"/><Setter Property="FontWeight" Value="SemiBold"/></Style>
<Style Selector="Border.card"><Setter Property="Background" Value="#192230"/><Setter Property="CornerRadius" Value="12"/><Setter Property="Padding" Value="20"/></Style>
</Window.Styles>
<Grid RowDefinitions="Auto,*,Auto" Margin="26">
Width="1240" Height="880" MinWidth="980" MinHeight="700" Background="{DynamicResource SemiColorBackground0}">
<Grid RowDefinitions="Auto,*,Auto" Margin="24">
<Grid ColumnDefinitions="*,Auto" Margin="0,0,0,20">
<StackPanel Spacing="5">
<TextBlock Text="ANDROID DEVICE STREAMING" Foreground="#66D9C0" FontSize="11" LetterSpacing="3"/>
<TextBlock Text="ANDROID DEVICE STREAMING" Foreground="{DynamicResource SemiColorPrimary}" FontSize="11" LetterSpacing="3"/>
<TextBlock Text="公网设备工作台" FontSize="29" FontWeight="Bold"/>
<TextBlock Text="连接远程手机,在本机调试与控制" Classes="label"/>
</StackPanel>
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Spacing="8">
<Border Height="3" HorizontalAlignment="Stretch"><ProgressBar IsIndeterminate="True" IsVisible="{Binding IsRefreshing}" Height="3"/></Border>
<TextBlock x:Name="RelayStatusText" Text="{Binding RelayStatus}" HorizontalAlignment="Right" Foreground="#66D9C0"/>
<StackPanel Orientation="Horizontal"><Button x:Name="RefreshButton" Content="刷新设备" Command="{Binding RefreshCommand}"/><Button Content="保存配置" Command="{Binding SaveCommand}"/></StackPanel>
<TextBlock x:Name="RelayStatusText" Text="{Binding RelayStatus}" HorizontalAlignment="Right" Foreground="{DynamicResource SemiColorPrimary}"/>
<StackPanel Orientation="Horizontal"><ToggleSwitch x:Name="ThemeSwitch" OnContent="深色" OffContent="浅色" IsChecked="False" IsCheckedChanged="ThemeChanged" Margin="0,0,16,8"/><Button x:Name="RefreshButton" Content="刷新设备" Command="{Binding RefreshCommand}"/><Button Content="保存配置" Command="{Binding SaveCommand}"/></StackPanel>
</StackPanel>
</Grid>
<TabControl x:Name="MainTabs" Grid.Row="1">
<TabControl x:Name="MainTabs" Classes="workbench" TabStripPlacement="Left" Grid.Row="1">
<TabItem Header="设备与连接">
<Grid ColumnDefinitions="320,*" Margin="0,16,0,0">
<Grid ColumnDefinitions="270,*" Margin="0,16,0,0">
<Border Classes="card" Margin="0,0,16,0">
<Grid RowDefinitions="Auto,*,Auto,Auto,Auto">
<TextBlock Text="在线设备" Classes="section"/>
<ListBox x:Name="DeviceList" Grid.Row="1" ItemsSource="{Binding Devices}" SelectedItem="{Binding SelectedDevice}" Margin="0,14,0,12" Background="Transparent">
<ListBox.ItemTemplate><DataTemplate><StackPanel Margin="5,10" Spacing="6"><TextBlock Text="{Binding Id}" FontSize="17" TextWrapping="Wrap"/><TextBlock Text="{Binding ComputerLabel}" Classes="label" TextWrapping="Wrap"/><TextBlock Text="{Binding Description}" Classes="label" TextWrapping="Wrap"/></StackPanel></DataTemplate></ListBox.ItemTemplate>
</ListBox>
<TextBlock Grid.Row="2" Text="{Binding ConnectionSummary}" Foreground="#66D9C0" Margin="0,0,0,8" TextWrapping="Wrap"/>
<TextBlock Grid.Row="2" Text="{Binding ConnectionSummary}" Foreground="{DynamicResource SemiColorPrimary}" Margin="0,0,0,8" TextWrapping="Wrap"/>
<TextBlock Grid.Row="3" Text="{Binding DeviceSummary}" Classes="label" TextWrapping="Wrap"/>
<CheckBox Grid.Row="4" Content="自动刷新设备列表" IsChecked="{Binding AutoRefresh}" Margin="0,12,0,0"/>
</Grid>
@@ -39,15 +32,15 @@
<StackPanel Spacing="14">
<Border Classes="card">
<StackPanel Spacing="12">
<Grid ColumnDefinitions="*,Auto"><TextBlock Text="多设备连接总览" Classes="section"/><TextBlock Grid.Column="1" Text="{Binding ConnectionSummary}" Foreground="#66D9C0" VerticalAlignment="Center"/></Grid>
<WrapPanel><Button x:Name="ConnectAllButton" Content="连接全部空闲设备" Command="{Binding ConnectAllCommand}"/><Button Content="投屏全部就绪设备" Command="{Binding StartAllScreensCommand}"/><Button x:Name="DisconnectAllButton" Content="断开全部" Command="{Binding DisconnectAllCommand}"/></WrapPanel>
<Grid ColumnDefinitions="*,Auto"><TextBlock Text="多设备连接总览" Classes="section"/><TextBlock Grid.Column="1" Text="{Binding ConnectionSummary}" Foreground="{DynamicResource SemiColorPrimary}" VerticalAlignment="Center"/></Grid>
<WrapPanel><Button Classes="Primary" Theme="{DynamicResource SolidButton}" x:Name="ConnectAllButton" Content="连接全部空闲设备" Command="{Binding ConnectAllCommand}"/><Button Content="投屏全部就绪设备" Command="{Binding StartAllScreensCommand}"/><Button Classes="Danger" x:Name="DisconnectAllButton" Content="断开全部" Command="{Binding DisconnectAllCommand}"/></WrapPanel>
<ScrollViewer MaxHeight="380">
<ItemsControl x:Name="ConnectionsList" ItemsSource="{Binding Connections}">
<ItemsControl.ItemTemplate><DataTemplate>
<Border Background="#101923" CornerRadius="8" Padding="12" Margin="0,0,0,8">
<Border Classes="inset" Margin="0,0,0,8">
<StackPanel Spacing="6">
<Grid ColumnDefinitions="*,Auto"><TextBlock Text="{Binding DeviceId}" FontSize="17" FontWeight="SemiBold"/><TextBlock Grid.Column="1" Text="{Binding Mode}" Foreground="#66D9C0"/></Grid>
<TextBlock Text="{Binding Status}" Foreground="#66D9C0"/>
<Grid ColumnDefinitions="*,Auto"><TextBlock Text="{Binding DeviceId}" FontSize="17" FontWeight="SemiBold"/><TextBlock Grid.Column="1" Text="{Binding Mode}" Foreground="{DynamicResource SemiColorPrimary}"/></Grid>
<TextBlock Text="{Binding Status}" Foreground="{DynamicResource SemiColorPrimary}"/>
<TextBlock Text="{Binding Endpoint}" Classes="label"/><TextBlock Text="{Binding PortSummary}" Classes="label" FontSize="12" TextWrapping="Wrap"/><TextBlock Text="{Binding TransportStatus}" Classes="label" TextWrapping="Wrap"/>
<WrapPanel>
<Button Content="查看" Command="{Binding $parent[Window].DataContext.SelectConnectionCommand}" CommandParameter="{Binding}" Padding="10,6"/>
@@ -67,10 +60,10 @@
<Border Classes="card">
<StackPanel Spacing="12">
<TextBlock Text="所选设备 · 连接管理" Classes="section"/>
<TextBlock x:Name="ConnectionStatusText" Text="{Binding Status}" Foreground="#66D9C0" FontSize="19" TextWrapping="Wrap"/>
<TextBlock x:Name="TransportStatusText" Text="{Binding TransportStatus}" Foreground="#A8B7CC" TextWrapping="Wrap"/>
<TextBlock x:Name="ConnectionStatusText" Text="{Binding Status}" Foreground="{DynamicResource SemiColorPrimary}" FontSize="19" TextWrapping="Wrap"/>
<TextBlock x:Name="TransportStatusText" Text="{Binding TransportStatus}" Foreground="{DynamicResource SemiColorText2}" TextWrapping="Wrap"/>
<TextBlock x:Name="EndpointText" Text="{Binding ActiveEndpoint}" Classes="label" TextWrapping="Wrap"/>
<WrapPanel><Button x:Name="ConnectButton" Content="连接所选设备" Command="{Binding ConnectCommand}"/><Button x:Name="ReconnectButton" Content="重新连接" Command="{Binding ReconnectCommand}"/><Button x:Name="DisconnectButton" Content="断开连接" Command="{Binding DisconnectCommand}"/><Button Content="复制设备标识" IsEnabled="{Binding HasConnection}" Click="CopyEndpointClick"/><Button x:Name="ClearPortButton" Content="清理占用端口" Command="{Binding ClearPortCommand}"/></WrapPanel>
<WrapPanel><Button Classes="Primary" Theme="{DynamicResource SolidButton}" x:Name="ConnectButton" Content="连接所选设备" Command="{Binding ConnectCommand}"/><Button x:Name="ReconnectButton" Content="重新连接" Command="{Binding ReconnectCommand}"/><Button x:Name="DisconnectButton" Content="断开连接" Command="{Binding DisconnectCommand}"/><Button Content="复制设备标识" IsEnabled="{Binding HasConnection}" Click="CopyEndpointClick"/><Button x:Name="ClearPortButton" Content="清理占用端口" Command="{Binding ClearPortCommand}"/></WrapPanel>
<TextBlock Text="断开连接只释放本机通道,远程手机守护程序会继续在线。" TextWrapping="Wrap" Classes="label" FontSize="12"/>
</StackPanel>
</Border>
@@ -93,7 +86,7 @@
<StackPanel Grid.Column="1"><TextBlock Text="最大帧率" Classes="label"/><NumericUpDown Value="{Binding MaxFps}" Minimum="1" Maximum="240" Increment="10" Margin="8,6,0,4"/></StackPanel>
</Grid>
<WrapPanel><CheckBox Content="传输音频" IsChecked="{Binding Audio}" Margin="0,0,24,0"/><CheckBox Content="只看画面" IsChecked="{Binding ViewOnly}"/></WrapPanel>
<WrapPanel><Button x:Name="StartScreenButton" Content="打开手机控制" Command="{Binding StartScrcpyCommand}"/><Button Content="停止投屏" Command="{Binding StopScrcpyCommand}"/></WrapPanel>
<WrapPanel><Button Classes="Primary" Theme="{DynamicResource SolidButton}" x:Name="StartScreenButton" Content="打开手机控制" Command="{Binding StartScrcpyCommand}"/><Button Content="停止投屏" Command="{Binding StopScrcpyCommand}"/></WrapPanel>
</StackPanel>
</Border>
</StackPanel>
@@ -106,7 +99,7 @@
<StackPanel Margin="4,18" MaxWidth="880" Spacing="16">
<Border Classes="card"><StackPanel>
<TextBlock Text="控制中心" Classes="section" Margin="0,0,0,12"/>
<ItemsControl ItemsSource="{Binding RelayNodes}" Margin="0,0,0,12"><ItemsControl.ItemTemplate><DataTemplate><TextBlock Text="{Binding Description}" Foreground="#66D9C0" Margin="0,3"/></DataTemplate></ItemsControl.ItemTemplate></ItemsControl>
<ItemsControl ItemsSource="{Binding RelayNodes}" Margin="0,0,0,12"><ItemsControl.ItemTemplate><DataTemplate><TextBlock Text="{Binding Description}" Foreground="{DynamicResource SemiColorPrimary}" Margin="0,3"/></DataTemplate></ItemsControl.ItemTemplate></ItemsControl>
<TextBlock Text="控制中心地址(WSS,可包含路径)"/><TextBox x:Name="ServerBox" Text="{Binding Server}" Watermark="wss://ttstd.com/ads"/>
<TextBlock Text="直连服务器(可选)"/><TextBox x:Name="OriginBox" Text="{Binding Origin}" Watermark="175.178.213.60:443"/>
<TextBlock Text="留空则按域名解析;指定公网 IP 时仍验证域名证书。当前部署使用此设置避开 Cloudflare 连接超时。" Classes="label" TextWrapping="Wrap"/>
@@ -148,10 +141,10 @@
<TabItem Header="运行日志">
<Grid RowDefinitions="Auto,*" Margin="0,16,0,0">
<StackPanel Orientation="Horizontal"><Button Content="打开日志文件夹" Command="{Binding OpenLogFolderCommand}"/><Button Content="清空日志" Command="{Binding ClearLogsCommand}"/><Button Content="导出日志" Command="{Binding ExportLogsCommand}"/></StackPanel>
<ListBox Grid.Row="1" ItemsSource="{Binding Logs}" Margin="0,8,0,0" FontFamily="Cascadia Mono,Consolas" FontSize="12"><ListBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding}" TextWrapping="Wrap"/></DataTemplate></ListBox.ItemTemplate></ListBox>
<ListBox x:Name="RuntimeLogs" Grid.Row="1" ItemsSource="{Binding Logs}" Margin="0,8,0,0" FontFamily="Cascadia Mono,Consolas,Microsoft YaHei UI,Noto Sans CJK SC" FontSize="12"><ListBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding}" TextWrapping="Wrap"/></DataTemplate></ListBox.ItemTemplate></ListBox>
</Grid>
</TabItem>
</TabControl>
<TextBlock Grid.Row="2" x:Name="NoticeText" Text="{Binding Notice}" Foreground="#A8B7CC" Margin="0,18,0,0" TextWrapping="Wrap" MaxHeight="70"/>
<TextBlock Grid.Row="2" x:Name="NoticeText" Text="{Binding Notice}" Foreground="{DynamicResource SemiColorText2}" Margin="0,18,0,0" TextWrapping="Wrap" MaxHeight="70"/>
</Grid>
</Window>
+6
View File
@@ -10,6 +10,12 @@ public partial class MainWindow : Window
Opened += async (_, _) => { if (DataContext is MainViewModel vm) await vm.InitializeAsync(); };
}
private void ThemeChanged(object? sender, RoutedEventArgs e)
{
if (sender is ToggleSwitch control && Avalonia.Application.Current is {} app)
app.RequestedThemeVariant = control.IsChecked == true ? Avalonia.Styling.ThemeVariant.Dark : Avalonia.Styling.ThemeVariant.Light;
}
private async void ImportCredentialsClick(object? sender, RoutedEventArgs e)
{
if (DataContext is not MainViewModel vm) return;
+3 -1
View File
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Text;
namespace Ads.Desktop;
@@ -11,7 +12,8 @@ public static class ProcessTools
var info = new ProcessStartInfo(executable)
{
UseShellExecute = false, CreateNoWindow = true,
RedirectStandardOutput = true, RedirectStandardError = true
RedirectStandardOutput = true, RedirectStandardError = true,
StandardOutputEncoding = new UTF8Encoding(false), StandardErrorEncoding = new UTF8Encoding(false)
};
foreach (var argument in arguments) info.ArgumentList.Add(argument);
foreach (var key in new[] { "ADB_SERVER_SOCKET", "ANDROID_ADB_SERVER_ADDRESS", "ANDROID_ADB_SERVER_PORT", "ADS_CLIENT_TOKEN", "ADS_AGENT_TOKEN", "ADS_ADMIN_TOKEN", "ADS_CONNECT_ADDRESS" })
+16
View File
@@ -0,0 +1,16 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="Window">
<Setter Property="Background" Value="{DynamicResource SemiColorBackground0}"/>
<Setter Property="Foreground" Value="{DynamicResource SemiColorText0}"/>
<Setter Property="FontFamily" Value="Segoe UI,Microsoft YaHei UI,Noto Sans CJK SC"/>
<Setter Property="FontSize" Value="14"/>
</Style>
<Style Selector="Button"><Setter Property="Padding" Value="14,8"/><Setter Property="MinHeight" Value="36"/><Setter Property="Margin" Value="0,0,8,8"/><Setter Property="CornerRadius" Value="6"/></Style>
<Style Selector="TextBox"><Setter Property="Margin" Value="0,6,0,12"/><Setter Property="MinHeight" Value="36"/></Style>
<Style Selector="TextBlock.label"><Setter Property="Foreground" Value="{DynamicResource SemiColorText2}"/></Style>
<Style Selector="TextBlock.section"><Setter Property="FontSize" Value="18"/><Setter Property="FontWeight" Value="SemiBold"/></Style>
<Style Selector="Border.card, Border.agentCard"><Setter Property="Background" Value="{DynamicResource SemiColorBackground1}"/><Setter Property="BorderBrush" Value="{DynamicResource SemiColorBorder}"/><Setter Property="BorderThickness" Value="1"/><Setter Property="CornerRadius" Value="10"/><Setter Property="Padding" Value="18"/></Style>
<Style Selector="Border.inset"><Setter Property="Background" Value="{DynamicResource SemiColorFill0}"/><Setter Property="CornerRadius" Value="8"/><Setter Property="Padding" Value="14"/></Style>
<Style Selector="TabControl.workbench TabItem"><Setter Property="MinWidth" Value="144"/><Setter Property="Padding" Value="16,12"/><Setter Property="Margin" Value="0,0,14,6"/><Setter Property="HorizontalContentAlignment" Value="Left"/></Style>
<Style Selector="ListBox"><Setter Property="CornerRadius" Value="6"/></Style>
</Styles>
+4
View File
@@ -98,3 +98,7 @@ USB 会话后端已按操作系统选择:Windows 使用已签名 USBip 控制
Windows 自包含发布把托管程序集打包到主程序,保留原生图形 DLL 和独立 Rust/ADB/scrcpy 工具;不启用反射裁剪,不要求安装 .NET,也不将全部应用压为单文件。发布使用全新暂存目录。`Ads.Desktop.exe --package-check` 可在隔离配置、无设备连接和不占用正式客户端互斥锁的条件下创建窗口后退出,用于验证发布包。
升级安装目录后会修复保存的旧工具位置;有效自定义可执行文件保留。启动时将解析后的路径写回已有设置,避免仍使用已删除的 TTSTD 安装目录。
Avalonia 使用锁定的 Semi.Avalonia 11.3.7.3(兼容 Avalonia 11.3.8)。`Ads.Desktop/WorkbenchStyles.axaml`(AXAML)统一侧边导航、卡片、表单和文本样式,颜色引用 Semi 语义资源,支持浅色/深色切换;Agent 托盘窗口共享主题。`dotnet run --project Ads.Desktop.Smoke -- --theme-preview` 可离线渲染 4 个页面的明暗主题和最小窗口尺寸,结果写入根目录 work(PNG)。
子进程 stdout/stderr 显式按 UTF-8 解码,包含 Rust、ADB、scrcpy 及 USB 工具;Agent JSON stdin 也使用 UTF-8。已生成的历史乱码日志保留,不猜测或改写丢失的字符。测试覆盖中文和 emoji 的一次性输出、流式日志及中文配置输入。
+7
View File
@@ -77,3 +77,10 @@ Port cleanup follow-up:
- 现场 settings.json 中 client、adb、scrcpy 三项仍为 Programs/TTSTD/ADS-Flutter,且三文件已不存在;当前 TongTongStudio 安装目录中的工具存在,ads-client --version 与 adb version 可运行。已备份现场配置后修复三项路径,其他设置和凭据保持不变;已运行的旧 UI 需重启才能重新读取设置。
- Flutter 新增 ToolPaths:启动及连接前解析、持久化当前工具位置,优先当前安装包,保留有效自定义工具。缺失工具在分配端口和建立租约之前报出修复方法,避免底层 ProcessException。投屏也解析 scrcpy/ADB 及工作目录。
- Avalonia 同步旧路径回退、启动迁移及保存。Flutter 32 项测试、Dart 静态分析、Avalonia 24 项测试通过,实际发布包窗口启动检查 PACKAGE_CHECK_OK。并行编译压力下一次端口测试超时,完整复跑 24 项均通过。
### 0.2.3:Avalonia Semi 主题与 UTF-8 日志
- 现场日志出现“鍦ㄥ叾…”等 UTF-8 字节被按 Windows 本地编码解释后的乱码。ProcessTools 对 stdout/stderr 显式使用 UTF-8,覆盖同步命令与流式日志;本机 Agent 管理 JSON stdin 同步 UTF-8,非重定向后台启动清空输出编码选项。
- 锁定 Semi.Avalonia 11.3.7.3,与当前 Avalonia 11.3.8 兼容。设备、Agent 管理、设置、日志及 Agent 托盘统一使用 Semi 资源;新增 WorkbenchStyles.axaml,替换硬编码深色配色,使用左侧导航和明暗主题开关。
- 27 项 Avalonia 测试通过,包含中文及 emoji stdout/stderr、流式日志和中文 JSON 输入。离屏渲染四个页面的浅色/深色和 980×700 最小窗口共 10 张 PNG 并检查截图;实际 Windows 发布包 PACKAGE_CHECK_OK,PE 运行库检查通过。
- Windows 安装器为 0.2.3;Linux 发布同版本 Avalonia/Agent deb。历史乱码日志不改写;安装新版本并重启后,新日志按 UTF-8 正常显示。尚未在本轮执行干净虚拟机完整安装/卸载和 Linux GUI 实机回归。
+1 -1
View File
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.2.2+3
version: 0.2.3+4
environment:
sdk: ^3.14.0