Avalonia12 (#7)

* ava12升级

* Enable centralized package versioning

Add <Project> and <PropertyGroup> with <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> to Directory.Packages.props to enable centralized package version management across the repository. This allows package versions to be controlled from this single file instead of individual project files.

* 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.

* Migrate to Avalonia 12 and Plugin SDK v5

Upgrade project to the Avalonia 12 baseline and Plugin SDK v5: centralize Avalonia packages, remove legacy WebView.Avalonia usage (use NativeWebView/WebView2 EnvironmentRequested), and update Fluent/Material icon/package usages. Bump multiple package/project versions to 5.0.0 and Avalonia 12.0.1, update plugin template and README/docs to SDK v5, and add PLUGIN_SDK_V5_MIGRATION.md.

Also fix runtime/behavior bugs: make DataLocationResolver use a fixed bootstrap launcher data path and avoid recursive ResolveDataRoot; add legacy-state handling and extraction in OobeStateService; and update component settings tests to reflect migrated storage (DB/backup) and reset cache for test reloads. Various csproj, tests, and docs updated to reflect the migration and ensure build/test compatibility.

* Update icon glyphs and symbol mappings

Replace and refine icon sources across settings pages and controls: many FAFontIconSource glyphs were updated to specific Seagull Fluent Icons codepoints, some FASymbolIconSource usages were replaced with FAFontIconSource, and a number of symbol-to-Symbol enum mappings were adjusted (e.g. "Bell" -> AlertOn, "Shield" -> ShieldLock). Also clarified a comment in SettingsWindow and fixed a trailing newline in StudySettingsPage. Changes standardize icon visuals and bridge FluentIcons glyphs into FluentAvalonia icon sources.

* fix.修复合并产生的问题。
This commit is contained in:
lincube
2026-04-29 12:14:29 +08:00
committed by GitHub
parent cbaf2a0c38
commit abfa64b3d7
100 changed files with 1530 additions and 1247 deletions

View File

@@ -0,0 +1,106 @@
# 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.cs`4 errors
* `ExtendClientAreaChromeHints` 不存在line 166, 179
* `SystemDecorations` 已过时,需改用 `WindowDecorations`line 168, 177
**文件**`LanMountainDesktop/Views/ComponentEditorWindow.axaml.cs`4 errors
* `ExtendClientAreaChromeHints` 不存在line 63, 72
* `SystemDecorations` 已过时,需改用 `WindowDecorations`line 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.Watermark``PlaceholderText`7 处 .cs + 7 处 .axaml
## 迁移步骤
### Phase 1: 修复窗口装饰 API高优先级
1. 重写 `SettingsWindow.ApplyChromeMode()` 使用 Avalonia 12 新 API
2. 重写 `ComponentEditorWindow.ApplyChromeMode()` 使用 Avalonia 12 新 API
3. 批量替换所有 `.axaml` 中的 `SystemDecorations``WindowDecorations`
### Phase 2: 修复 MainWindow 编译错误(高优先级)
1. 检查 `MainWindow.ComponentSystem.cs``centerLeft``positions` 的作用域问题
2. 检查 `MainWindow.DesktopPaging.cs``child``_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. 批量替换 `Watermark``PlaceholderText`(所有 .cs 和 .axaml
## 验证步骤
* 每阶段修复后运行 `dotnet build LanMountainDesktop.slnx -c Debug`
* 最终运行 `dotnet test LanMountainDesktop.slnx -c Debug`

View File

@@ -0,0 +1,21 @@
# Checklist
- [x] `Directory.Packages.props` contains the Avalonia 12 dependency baseline.
- [x] Main host references `Avalonia.Controls.WebView`.
- [x] Source no longer references `WebView.Avalonia`, `AvaloniaWebView`, or `.UseDesktopWebView()`.
- [x] `BrowserWidget` uses `NativeWebView.Source`, `Navigate`, `Refresh()`, `NavigationStarted`, and `EnvironmentRequested`.
- [x] WebView blanking navigates to `about:blank`.
- [x] Plugin SDK package version is `5.0.0`.
- [x] `PluginSdkInfo.ApiVersion` is `5.0.0`.
- [x] Plugin template package version default is `5.0.0`.
- [x] Plugin template manifest `apiVersion` is `5.0.0`.
- [x] Launcher data location config resolution cannot recurse through `ResolveDataRoot()`.
- [x] `OobeStateServiceTests` pass.
- [x] `dotnet build LanMountainDesktop.slnx -c Debug` has 0 errors.
- [x] `dotnet test LanMountainDesktop.slnx -c Debug` completes without a test host stack overflow.
- [ ] Windows host smoke test completed.
- [ ] Windows Launcher smoke test completed.
- [ ] Settings window FluentAvalonia 3 smoke test completed.
- [ ] Component editor Material smoke test completed.
- [ ] BrowserWidget navigation/refresh/page activation smoke test completed.
- [ ] WebView2 missing-runtime diagnostic smoke test completed.

View File

@@ -0,0 +1,49 @@
# Avalonia 12 Full Stack Migration
## Summary
LanMountainDesktop has moved its desktop stack to the Avalonia 12 baseline. The migration covers the main host, Launcher, Plugin SDK, plugin runtime loading policy, official WebView usage, ClassIsland Markdown, FluentAvalonia, FluentIcons, and Material-related dependencies.
## Requirements
### Requirement: Centralized Avalonia 12 dependency baseline
The solution SHALL use central package management for direct Avalonia-facing projects and keep the core UI dependency baseline on Avalonia `12.0.1`.
Required package baseline:
- `Avalonia*` `12.0.1`
- `Avalonia.Controls.WebView` `12.0.0`
- `ClassIsland.Markdown.Avalonia` `12.0.0`
- `FluentAvaloniaUI` `3.0.0-preview1`
- `FluentIcons.Avalonia` `2.1.325`
- `Material.Avalonia` `3.16.0`
- `Material.Icons.Avalonia` `3.0.2`
### Requirement: Official WebView
The host SHALL use `Avalonia.Controls.NativeWebView` for the browser widget and SHALL NOT reference `WebView.Avalonia`, `AvaloniaWebView`, or `.UseDesktopWebView()`.
Windows WebView2 user data configuration SHALL be supplied through `EnvironmentRequested` using `WindowsWebView2EnvironmentRequestedEventArgs.UserDataFolder`.
### Requirement: Plugin SDK v5
The Plugin SDK API baseline SHALL be `5.0.0`. SDK v4 plugins are treated as incompatible until rebuilt.
The SDK SHALL keep the existing public UI extension shape, including `SettingsPageBase` and Avalonia `Control` based desktop components.
### Requirement: Launcher data location stability
Launcher data location configuration SHALL be read from a fixed bootstrap Launcher data directory so resolving the selected data root cannot recursively require resolving itself.
### Requirement: OOBE state compatibility
The Launcher SHALL read current OOBE state from the resolved `Launcher/state` directory and SHALL continue to migrate the legacy `.launcher/state/first_run_completed` marker.
## Acceptance
- `dotnet build LanMountainDesktop.slnx -c Debug` completes with 0 errors.
- `OobeStateServiceTests` pass.
- Full `dotnet test LanMountainDesktop.slnx -c Debug` no longer aborts from `DataLocationResolver` recursion.
- Plugin template defaults to SDK package version `5.0.0` and manifest `apiVersion` `5.0.0`.
- Current developer documentation points to SDK v5 and Avalonia 12.

View File

@@ -0,0 +1,18 @@
# Tasks
- [x] Centralize Avalonia 12 package versions in `Directory.Packages.props`.
- [x] Move the host, Launcher, Plugin SDK, DesktopHost, Shared.Contracts, and Avalonia-facing projects onto central package versions.
- [x] Replace third-party `WebView.Avalonia` usage with official `NativeWebView`.
- [x] Configure WebView2 user data through `EnvironmentRequested`.
- [x] Move FluentAvalonia usages to the FA3 control names and package baseline.
- [x] Move FluentIcons usage to `FluentIcons.Avalonia` and remove the old `.Fluent` package.
- [x] Update Plugin SDK package version and API baseline to `5.0.0`.
- [x] Update plugin runtime shared assembly policy for Avalonia 12 / FluentAvalonia / FluentIcons / Material.
- [x] Fix Avalonia 12 compile breaks in window chrome, binding plugin access, clipboard, bitmap copy, and icon source usage.
- [x] Fix Launcher data location recursion by using a fixed bootstrap config path.
- [x] Fix OOBE state tests and legacy marker compatibility.
- [x] Update PluginTemplate defaults to SDK v5.
- [x] Add SDK v5 migration documentation.
- [x] Update current docs from SDK v4 / Avalonia 11 examples to SDK v5 / Avalonia 12.
- [x] Run full solution tests and record any remaining non-upgrade failures.
- [ ] Perform Windows manual smoke test for host, Launcher, settings, component editor, BrowserWidget, and WebView2 missing-runtime handling.