feat(desktop): 主界面/托盘不再显示服务地址与运行状态
- 主界面移除整行「● 本机服务 运行中 · http://…」,顶部只留「已登录:xxx / 退出登录」 - UpdateServerState 只刷新菜单「服务 → 服务状态」,不再碰界面控件 - 托盘菜单的状态项改成固定的「本机服务」(原来是「服务:<地址>」), UpdateStatus 只传「运行中 / 未启动」;TrayIconService 构造不再需要 serverUrl - 运行状态统一在菜单里看,界面不再重复展示内部实现细节
This commit is contained in:
parent
e7ff6ed784
commit
62ab25e6fe
@ -69,7 +69,7 @@ public partial class App : Application
|
||||
|
||||
// ③ 托盘
|
||||
var version = GetType().Assembly.GetName().Version?.ToString() ?? "1.0.0";
|
||||
_tray = new TrayIconService(_server.BaseUrl, version);
|
||||
_tray = new TrayIconService(version);
|
||||
_tray.ShowRequested += ShowAppWindow;
|
||||
_tray.RestartRequested += RestartApplication;
|
||||
_tray.ExitRequested += ExitApplication;
|
||||
@ -316,7 +316,7 @@ public partial class App : Application
|
||||
|
||||
_trayHintShown = true;
|
||||
_tray?.ShowBalloon("云仓视频溯源软件仍在运行",
|
||||
$"本机服务在 {_server?.BaseUrl} 继续提供,双击托盘图标可重新打开窗口。");
|
||||
"本机服务继续在后台运行,双击托盘图标可重新打开窗口。");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -382,7 +382,7 @@ public partial class App : Application
|
||||
|
||||
private void UpdateTrayStatus()
|
||||
{
|
||||
_tray?.UpdateStatus(_server?.IsRunning == true ? $"运行中 · {_server.BaseUrl}" : "本机服务未启动");
|
||||
_tray?.UpdateStatus(_server?.IsRunning == true ? "运行中" : "未启动");
|
||||
}
|
||||
|
||||
// ---------------- 单实例 / 退出 ----------------
|
||||
|
||||
@ -45,21 +45,12 @@
|
||||
<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>
|
||||
<!-- ① 当前登录用户(运行状态在菜单「服务 → 服务状态」里看) -->
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,0,12">
|
||||
<TextBlock x:Name="UserText" Text="未登录" Foreground="{StaticResource MutedBrush}"
|
||||
VerticalAlignment="Center" Margin="0,0,10,0" />
|
||||
<Button Content="退出登录" Padding="10,4" Click="Logout_Click" />
|
||||
</StackPanel>
|
||||
|
||||
<!-- ② 查询测试(占满剩余高度;日志只写文件,界面上不再展示) -->
|
||||
<Border Grid.Row="1" Background="White" BorderBrush="{StaticResource LineBrush}"
|
||||
|
||||
@ -4,14 +4,14 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using YuncangTrace.LocalService.Services;
|
||||
|
||||
namespace YuncangTrace.LocalService;
|
||||
|
||||
/// <summary>
|
||||
/// 主窗口:本机服务状态、测试查询、当前登录用户
|
||||
/// 主窗口:测试查询、当前登录用户
|
||||
///
|
||||
/// 运行状态不在界面上占位(在菜单「服务 → 服务状态」里看)。
|
||||
/// 日志不进界面:只写文件(<c>软件目录\logs\log_yyyy-MM-dd.txt</c>),
|
||||
/// 需要看的时候用菜单「工具 → 打开日志目录」。
|
||||
///
|
||||
@ -75,16 +75,12 @@ public partial class MainWindow : Window
|
||||
// ---------------- 服务状态 ----------------
|
||||
|
||||
/// <summary>
|
||||
/// 只展示运行状态:本机服务跟随程序生命周期(启动即开、退出即停),
|
||||
/// 不再提供「停止服务」按钮 —— 停了网页就叫不醒,属于误操作。
|
||||
/// 只刷菜单里的状态项:本机服务跟随程序生命周期(启动即开、退出即停),
|
||||
/// 连界面上的状态点/文字也不再占位(用户不需要知道这些东西)。
|
||||
/// </summary>
|
||||
private void UpdateServerState()
|
||||
{
|
||||
var running = _server.IsRunning;
|
||||
|
||||
StatusText.Text = running ? $"运行中 · {_server.BaseUrl}" : "未启动";
|
||||
StatusDot.Fill = (Brush)FindResource(running ? "OkBrush" : "BadBrush");
|
||||
MenuServiceStatus.Header = running ? "服务状态:运行中" : "服务状态:未启动";
|
||||
MenuServiceStatus.Header = _server.IsRunning ? "服务状态:运行中" : "服务状态:未启动";
|
||||
}
|
||||
|
||||
// ---------------- 菜单 ----------------
|
||||
|
||||
@ -25,9 +25,10 @@ public sealed class TrayIconService : IDisposable
|
||||
/// <summary>要退出程序</summary>
|
||||
public event Action? ExitRequested;
|
||||
|
||||
public TrayIconService(string serverUrl, string version)
|
||||
public TrayIconService(string version)
|
||||
{
|
||||
_statusItem = new WinForms.ToolStripMenuItem($"服务:{serverUrl}") { Enabled = false };
|
||||
// 服务地址属于内部实现,不在界面/托盘上展示
|
||||
_statusItem = new WinForms.ToolStripMenuItem("本机服务") { Enabled = false };
|
||||
|
||||
var menu = new WinForms.ContextMenuStrip();
|
||||
menu.Items.Add(new WinForms.ToolStripMenuItem("打开主界面", null, (_, _) => ShowRequested?.Invoke()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user