- LoginWindow:服务器地址 / 账号 / 密码 / 记住账号 → POST /api/web/auth/login 拿 user JWT; 本地已有令牌时先用 GET /api/web/me 验证,有效就跳过登录(窗口一闪而过),无效清掉令牌留下重登。 - TrayIconService(WinForms NotifyIcon,csproj 开 UseWindowsForms): 关窗口 = 隐藏到托盘(本机服务继续跑),双击托盘恢复,右键菜单「打开主界面 / 服务地址 / 版本 / 退出」; 第一次缩到托盘冒一次气泡提示。退出只走托盘「退出」(App 改 ShutdownMode=OnExplicitShutdown)。 - 防多开:SingleInstance(Local\ 命名互斥体 + 命名管道)。第二个实例不抢 17311 端口, 把 yuncang://open?code=… 转给已运行实例(在托盘里也会被弹出来并按 code 查询)后自己退出; 还在登录界面时先把 URL 存起来,登录完成后再查。 - 生命周期调整:本机 HTTP 服务与托盘在 App 里创建(登录前就可用),主窗口只管展示与操作; 日志改成全局 AppLog(窗口没开时的日志也会在窗口打开后补上)。 - 新增 AppSettings / SessionStore:%LOCALAPPDATA%\YuncangTrace\settings.json、session.json (服务器地址默认 http://127.0.0.1:7300;换服务器不会复用旧令牌)。 - 新增 ApiClient(登录 / 校验令牌)、MainWindow「退出登录」(清令牌回登录页)。 - 程序/托盘图标:Assets/app.ico + tools/make-icon.ps1(品牌蓝 + 白色播放三角)。 - csproj 关闭 ImplicitUsings:WPF 与 WinForms 同时开启时隐式命名空间会让 MessageBox / Application / Clipboard 等产生歧义。 ⚠️ 本机没有 .NET SDK,无法编译验证;已做 XAML/XML 良构与括号平衡检查。
94 lines
5.5 KiB
XML
94 lines
5.5 KiB
XML
<Window x:Class="YuncangTrace.LocalService.MainWindow"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
Title="云仓视频溯源软件(本机服务)"
|
|
Height="620" Width="780"
|
|
MinHeight="520" MinWidth="680"
|
|
WindowStartupLocation="CenterScreen"
|
|
Background="{StaticResource BgBrush}"
|
|
FontFamily="Microsoft YaHei UI, Segoe UI"
|
|
FontSize="13">
|
|
<Grid Margin="18">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="*" />
|
|
</Grid.RowDefinitions>
|
|
|
|
<!-- ① 标题 + 运行状态 + 当前登录用户 -->
|
|
<DockPanel Grid.Row="0" Margin="0,0,0,14">
|
|
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" VerticalAlignment="Center">
|
|
<TextBlock x:Name="UserText" Text="未登录" Foreground="{StaticResource MutedBrush}"
|
|
VerticalAlignment="Center" Margin="0,0,10,0" />
|
|
<Button Content="退出登录" Padding="10,4" Click="Logout_Click" />
|
|
</StackPanel>
|
|
<StackPanel Orientation="Horizontal">
|
|
<Ellipse x:Name="StatusDot" Width="10" Height="10" Margin="0,0,8,0"
|
|
VerticalAlignment="Center" Fill="{StaticResource BadBrush}" />
|
|
<TextBlock Text="本机服务" FontSize="18" FontWeight="SemiBold" VerticalAlignment="Center" />
|
|
<TextBlock x:Name="StatusText" Text="未启动" Margin="10,0,0,2"
|
|
Foreground="{StaticResource MutedBrush}" VerticalAlignment="Bottom" />
|
|
</StackPanel>
|
|
</DockPanel>
|
|
|
|
<!-- ② 服务地址 -->
|
|
<Border Grid.Row="1" Background="White" BorderBrush="{StaticResource LineBrush}"
|
|
BorderThickness="1" CornerRadius="8" Padding="12,10" Margin="0,0,0,10">
|
|
<DockPanel>
|
|
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
|
|
<Button Content="复制地址" Padding="10,4" Margin="0,0,8,0" Click="CopyAddress_Click" />
|
|
<Button Content="在浏览器打开" Padding="10,4" Click="OpenInBrowser_Click" />
|
|
</StackPanel>
|
|
<TextBlock Text="服务地址" Foreground="{StaticResource MutedBrush}" VerticalAlignment="Center" Margin="0,0,10,0" />
|
|
<TextBox x:Name="AddressBox" IsReadOnly="True" BorderThickness="0" Background="Transparent"
|
|
FontFamily="Consolas, Microsoft YaHei UI" VerticalContentAlignment="Center" />
|
|
</DockPanel>
|
|
</Border>
|
|
|
|
<!-- ③ 操作按钮 + 协议状态 -->
|
|
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,0,0,6">
|
|
<Button x:Name="StartStopButton" Content="停止服务" Padding="14,6" Click="StartStop_Click" />
|
|
<Button x:Name="ProtocolButton" Content="注册启动协议" Padding="14,6" Margin="10,0,0,0" Click="Protocol_Click" />
|
|
<Button Content="复制唤醒地址" Padding="14,6" Margin="10,0,0,0" Click="CopyLaunchUrl_Click" />
|
|
<TextBlock x:Name="ProtocolText" Margin="14,0,0,0" VerticalAlignment="Center"
|
|
Foreground="{StaticResource MutedBrush}" TextTrimming="CharacterEllipsis" />
|
|
</StackPanel>
|
|
|
|
<!-- ④ 查询测试 -->
|
|
<Border Grid.Row="3" Background="White" BorderBrush="{StaticResource LineBrush}"
|
|
BorderThickness="1" CornerRadius="8" Padding="12,10" Margin="0,6,0,10">
|
|
<StackPanel>
|
|
<DockPanel>
|
|
<Button DockPanel.Dock="Right" Content="查询" Padding="16,5" Margin="8,0,0,0" Click="Query_Click" />
|
|
<TextBlock Text="测试查询" Foreground="{StaticResource MutedBrush}" VerticalAlignment="Center" Margin="0,0,10,0" />
|
|
<TextBox x:Name="QueryBox" Padding="6,3" VerticalContentAlignment="Center"
|
|
ToolTip="输入运单号后回车" KeyDown="QueryBox_KeyDown" />
|
|
</DockPanel>
|
|
<TextBox x:Name="ResultBox" Margin="0,10,0,0" Height="130" IsReadOnly="True"
|
|
AcceptsReturn="True" AcceptsTab="True" TextWrapping="NoWrap"
|
|
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
|
|
FontFamily="Consolas, Microsoft YaHei UI" FontSize="12" Padding="8"
|
|
Background="#F9FAFB" BorderBrush="{StaticResource LineBrush}" />
|
|
</StackPanel>
|
|
</Border>
|
|
|
|
<!-- ⑤ 日志 -->
|
|
<Grid Grid.Row="4">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
<TextBlock Grid.Row="0" Text="运行日志" Foreground="{StaticResource MutedBrush}" Margin="2,0,0,4" />
|
|
<Border Grid.Row="1" Background="White" BorderBrush="{StaticResource LineBrush}"
|
|
BorderThickness="1" CornerRadius="8" Padding="4">
|
|
<ListBox x:Name="LogList" BorderThickness="0" Background="Transparent"
|
|
FontFamily="Consolas, Microsoft YaHei UI" FontSize="12"
|
|
ScrollViewer.HorizontalScrollBarVisibility="Auto" />
|
|
</Border>
|
|
</Grid>
|
|
</Grid>
|
|
</Window>
|