Files
LanMountainDesktop/.trae/documents/avalonia12-migration-plan.md
lincube 9fb41378eb Migrate codebase to Avalonia 12 APIs
Apply Avalonia 12 migration changes: replace SystemDecorations with WindowDecorations and remove ExtendClientAreaChromeHints/ExtendClientAreaTitleBarHeightHint usages; update BindingPlugins removal logic (no-op); switch clipboard usage to ClipboardExtensions.SetTextAsync; update Bitmap.CopyPixels calls to the new signature. Replace TextBox.Watermark with PlaceholderText, convert NumberBox styles to FANumberBox and adjust templates, change Checked/Unchecked handlers to IsCheckedChanged, and adapt FluentIcons usages (SymbolIconSource -> FASymbol/FAFont/FluentIcon equivalents). Fix MainWindow partial classes to inherit Window and correct missing variables/fields/usings. Add migration docs/specs/tasks under .trae and include a small TestFluentIcons project for icon testing.
2026-04-29 08:50:28 +08:00

3.3 KiB
Raw Blame History

Avalonia 12 迁移计划

当前状态

项目已完成以下迁移准备:

  • Directory.Packages.props 中 Avalonia 包已升级到 12.0.1

  • FluentAvaloniaUI 已升级到 3.0.0-preview1

  • Avalonia.Diagnostics 已替换为 AvaloniaUI.DiagnosticsSupport

  • Avalonia.Controls.WebView 已升级到 12.0.0

  • ClassIsland.Markdown.Avalonia 已升级到 12.0.0

构建错误清单26 errors

1. 窗口装饰 API 移除8 errors

文件LanMountainDesktop/Views/SettingsWindow.axaml.cs4 errors

  • ExtendClientAreaChromeHints 不存在line 166, 179

  • SystemDecorations 已过时,需改用 WindowDecorationsline 168, 177

文件LanMountainDesktop/Views/ComponentEditorWindow.axaml.cs4 errors

  • ExtendClientAreaChromeHints 不存在line 63, 72

  • SystemDecorations 已过时,需改用 WindowDecorationsline 65, 70

AXAML 文件13 个文件使用 SystemDecorations 属性(编译警告)

2. 变量/字段未找到8 errors

文件LanMountainDesktop/Views/MainWindow.ComponentSystem.cs

  • centerLeft 不存在line 759, 766, 778

  • positions 不存在line 1266

文件LanMountainDesktop/Views/MainWindow.DesktopPaging.cs

  • child 不存在line 312

  • _isThreeFingerOrRightDragSwipeActive 不存在line 517, 828, 847, 850

3. API 变更3 errors

文件LanMountainDesktop/App.axaml.cs

  • BindingPlugins 不可访问line 532, 537

文件LanMountainDesktop/Views/Components/DesktopComponentFailureView.cs

  • IClipboard.SetTextAsync 不存在line 187

文件LanMountainDesktop/Services/MonetColorService.cs

  • Bitmap.CopyPixels 参数不匹配line 91

4. 第三方库变更1 error

文件LanMountainDesktop/Views/SettingsWindow.axaml.cs

  • FluentIcons.Avalonia.SymbolIconSource 不存在line 215

5. 过时属性警告(需同步修复)

  • TextBox.WatermarkPlaceholderText7 处 .cs + 7 处 .axaml

迁移步骤

Phase 1: 修复窗口装饰 API高优先级

  1. 重写 SettingsWindow.ApplyChromeMode() 使用 Avalonia 12 新 API
  2. 重写 ComponentEditorWindow.ApplyChromeMode() 使用 Avalonia 12 新 API
  3. 批量替换所有 .axaml 中的 SystemDecorationsWindowDecorations

Phase 2: 修复 MainWindow 编译错误(高优先级)

  1. 检查 MainWindow.ComponentSystem.cscenterLeftpositions 的作用域问题
  2. 检查 MainWindow.DesktopPaging.cschild_isThreeFingerOrRightDragSwipeActive 的作用域问题
  3. 确认这些变量是否被意外删除或重命名

Phase 3: 修复 Avalonia 12 API 变更(中优先级)

  1. App.axaml.cs: 替换 BindingPlugins.DataValidators 的访问方式
  2. DesktopComponentFailureView.cs: 使用新的剪贴板 API
  3. MonetColorService.cs: 更新 Bitmap.CopyPixels 调用签名

Phase 4: 修复第三方库变更(中优先级)

  1. SettingsWindow.axaml.cs: 替换 FluentIcons.Avalonia.SymbolIconSource 为 v3 等效 API

Phase 5: 清理过时属性(低优先级)

  1. 批量替换 WatermarkPlaceholderText(所有 .cs 和 .axaml

验证步骤

  • 每阶段修复后运行 dotnet build LanMountainDesktop.slnx -c Debug

  • 最终运行 dotnet test LanMountainDesktop.slnx -c Debug