docs: 补全全部缺失的 XML 文档注释(中文)
- 为全部 5 个项目(Avalonia-API、Avalonia-Common、Avalonia-EFCore、 Avalonia-PC、Avalonia-Services)中缺失注释的类、方法、属性、字段、 接口成员等补全中文 XML 文档注释 - 共修改约 37 个文件,补全约 220+ 处注释 - 修复 ServiceEndpointCollection.cs 中 MapDelete<TService> 语法错误 - 修复 PcAuthService.cs 中 const prefix 位置错乱导致编译失败的问题 - 扫描结果:缺失项 0 - 构建结果:4/4 项目编译通过
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
namespace Avalonia_PC.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow 的分部类,定义注入 WebView2 的 JavaScript Bridge 脚本。
|
||||
/// </summary>
|
||||
public partial class MainWindow
|
||||
{
|
||||
private const string BridgeScript = """
|
||||
@@ -106,6 +109,9 @@ if (!window.__appBridgeInstalled) {
|
||||
});
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// WebView2 Bridge 中的 XMLHttpRequest 替代实现,将 app:// 请求拦截并转为 C# 调用。
|
||||
/// </summary>
|
||||
class BridgeXMLHttpRequest {
|
||||
constructor() {
|
||||
this._native = new NativeXMLHttpRequest();
|
||||
|
||||
@@ -9,6 +9,9 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Avalonia_PC.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// MainWindow 的分部类,负责路由注册和统一端点适配。
|
||||
/// </summary>
|
||||
public partial class MainWindow
|
||||
{
|
||||
/// <summary>
|
||||
@@ -22,6 +25,9 @@ namespace Avalonia_PC.Views
|
||||
/// </summary>
|
||||
private IServiceProvider _services = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 从 DI 获取统一端点集合并构建桌面适配器。
|
||||
/// </summary>
|
||||
private void RegisterRoutes()
|
||||
{
|
||||
// 从 DI 获取已构建的端点集合
|
||||
|
||||
@@ -12,23 +12,56 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Avalonia_PC.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// 主窗口,承载 WebView2 控件并管理前后端 Bridge 通信。
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义协议方案名称。
|
||||
/// </summary>
|
||||
private const string AppScheme = "app";
|
||||
/// <summary>
|
||||
/// 在线模式下的前端启动 URL。
|
||||
/// </summary>
|
||||
private const string? OnlineStartupUrl = "http://localhost:51240";
|
||||
//private const string? OnlineStartupUrl = null;
|
||||
/// <summary>
|
||||
/// 离线模式下的前端本地文件路径,为空则使用在线模式。
|
||||
/// </summary>
|
||||
private const string? LocalStartupPath = null;
|
||||
private static readonly JsonSerializerOptions BridgeJsonSerializerOptions = new()
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// WebView2 原生控件实例。
|
||||
/// </summary>
|
||||
private NativeWebView? _webView;
|
||||
/// <summary>
|
||||
/// 标记 WebView 事件是否已绑定。
|
||||
/// </summary>
|
||||
private bool _eventsAttached;
|
||||
/// <summary>
|
||||
/// WebView 适配器对象。
|
||||
/// </summary>
|
||||
private object? _webViewAdapter;
|
||||
/// <summary>
|
||||
/// 本地 HTTP 服务器实例(离线模式)。
|
||||
/// </summary>
|
||||
private HttpListener? _localHttpServer;
|
||||
/// <summary>
|
||||
/// 本地 HTTP 服务器的取消令牌源。
|
||||
/// </summary>
|
||||
private CancellationTokenSource? _localHttpServerCts;
|
||||
/// <summary>
|
||||
/// 本地 HTTP 服务器的基础 URL。
|
||||
/// </summary>
|
||||
private string? _localHttpBaseUrl;
|
||||
/// <summary>
|
||||
/// 本地 HTTP 服务器的根目录路径。
|
||||
/// </summary>
|
||||
private string? _localHttpRoot;
|
||||
|
||||
#region 生命周期与 WebView 事件
|
||||
@@ -610,18 +643,39 @@ namespace Avalonia_PC.Views
|
||||
|
||||
#region DTO / 路由上下文模型
|
||||
|
||||
/// <summary>
|
||||
/// Bridge 通信响应 DTO,用于序列化返回给前端的数据。
|
||||
/// </summary>
|
||||
private sealed class AppResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置响应类型标识。
|
||||
/// </summary>
|
||||
public string Kind { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置请求 ID(对应前端请求)。
|
||||
/// </summary>
|
||||
public string? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 HTTP 状态码。
|
||||
/// </summary>
|
||||
public int StatusCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置状态描述文本。
|
||||
/// </summary>
|
||||
public string StatusMessage { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置响应体 JSON 字符串。
|
||||
/// </summary>
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置响应头字典。
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Headers { get; set; } = new();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user