Files
Hua.Todo/src/Hua.Todo.Maui/Platforms/Windows/MainPage.Windows.cs
T
ShaoHua d53828c150 feat: v1.2.0 开发进度更新
### 新增功能
- **Linux 官方支持**:新增 Hua.Todo.Avalonia 项目,正式适配 Linux 平台,同时支持 Windows 和 macOS
- **Avalonia 桌面交互**:增加托盘菜单(显示/退出)、关闭隐藏到托盘、Windows 全局热键唤起主窗口、热键配置本地持久化
- **SQLite DateTime 兼容修复**:新增 LenientUtcDateTimeStringConverter,解决历史遗留的 DateTime 脏数据解析问题
- **用户文档完善**:新增 docs/manual/新手指南.md 和 docs/manual/用户指南.md
- **部署文档**:新增 docs/manual/部署文档.md,详细说明多平台发布流程

### 优化与修复
- **发布脚本整理**:拆分/对齐各平台发布入口,新增 publish.ps1 作为统一入口
- **Windows WebView2 优化**:数据目录调整到 %LocalAppData%\Hua.Todo\WebView2,修复 Runtime 误判问题
- **MAUI 多平台构建**:在 Windows 开发机上默认仅构建 Android + Windows 目标
- **SPA 路由回落**:修复 Release 模式下 /swagger 路径的 404 问题
- **Swagger 输出**:补齐 Dynamic API 端点,避免接口缺失

### 文档更新
- **版本记录**:更新 v1.2.0 开发进度和功能列表
- **技术设计文档**:添加 Avalonia 项目架构和模块设计
- **项目结构**:更新 README.md 中的项目结构说明

### 其他变更
- 新增 Directory.Build.props 和更新 Directory.Build.targets
- 调整 src/Hua.Todo.Avalonia 项目配置和资源文件
- 更新 src/Hua.Todo.Web 前端资源文件
- 修复 src/Hua.Todo.Maui 相关配置和打包脚本
2026-04-09 21:39:07 +08:00

99 lines
3.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Microsoft.Maui.Controls;
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Handlers;
namespace Hua.Todo.Maui.Views
{
/// <summary>
/// Windows 平台特定的 MainPage 逻辑(分部类)。
/// 该文件仅在 Windows 目标框架下参与编译,用于接入 Windows 全局键盘事件等能力。
/// </summary>
public partial class MainPage
{
private Platforms.Windows.WindowsKeyboardHandler? _keyboardHandler;
/// <summary>
/// Windows 平台特定的键盘处理器设置。
/// 当前仅监听 Esc 键,用于快速最小化窗口(与桌面端交互习惯保持一致)。
/// </summary>
partial void PlatformSetupKeyboardHandler()
{
_keyboardHandler = new Platforms.Windows.WindowsKeyboardHandler();
_keyboardHandler.EscKeyPressed += OnEscKeyPressed;
_keyboardHandler.Start();
}
/// <summary>
/// Windows 平台特定的 Esc 键处理(最小化窗口)。
/// </summary>
/// <param name="window">当前窗口。</param>
partial void PlatformOnEscKeyPressed(Window window)
{
var windowService = new Platforms.Windows.WindowsWindowService();
windowService.MinimizeWindow(window);
}
/// <summary>
/// 配置 WebView 滚动条行为。
/// </summary>
partial void ConfigureWebViewScrollBars()
{
// 使用 JavaScript 注入的方式禁用滚动条
MainWebView.EvaluateJavaScriptAsync(@"
// 禁用页面垂直滚动条
document.body.style.overflowY = 'hidden';
// 禁用整个文档的滚动
document.documentElement.style.overflowY = 'hidden';
");
}
partial void PlatformPrepareWebViewContainer()
{
if (Platforms.Windows.WebView2RuntimeDetector.IsRuntimeInstalled(out _))
{
return;
}
_isWebViewContainerReady = false;
var downloadUrl = "https://developer.microsoft.com/microsoft-edge/webview2/";
var content = new VerticalStackLayout
{
Padding = new Thickness(20),
Spacing = 12,
Children =
{
new Label
{
Text = "检测到系统未安装 WebView2 Runtime,无法加载主界面。",
FontSize = 16
},
new Label
{
Text = "请安装 Microsoft Edge WebView2 RuntimeEvergreen),安装完成后重新打开应用。",
Opacity = 0.85
},
new Button
{
Text = "打开下载页面",
Command = new Command(async () =>
{
await Launcher.Default.OpenAsync(downloadUrl);
})
},
new Button
{
Text = "退出应用",
Command = new Command(() =>
{
Microsoft.Maui.Controls.Application.Current?.Quit();
})
}
}
};
Content = new ScrollView { Content = content };
}
}
}