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

+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>