Skip to content

Commit 08a9a87

Browse files
fix(#693 app): 修复开发者模式下添加插件失败的问题
MSIX 安装目录(C:\Program Files\WindowsApps\...)是只读的, 而插件 XAML 热重载暂存目录 HotReloadRoot 之前放在 AppContext.BaseDirectory 下, 导致 PrepareResourceRoot 创建目录时抛出 UnauthorizedAccessException。 改为使用 AppStoragePaths.LocalDataPath(已正确处理 MSIX/便携/无包身份三种情况)。
1 parent 805c55f commit 08a9a87

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

.kilocode/rules/project-info-galgamemanager.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GalgameManager Client (PotatoVN) - Detailed Knowledge Base
1+
# GalgameManager Client (PotatoVN) - Detailed Knowledge Base
22

33
> After finishing editing, please remember to run GalgameManager.Test to ensure no tests are broken.
44
>
@@ -169,7 +169,7 @@ This section highlights important files and directories specific to the client a
169169
* All source services implement `IGalgameSourceService` interface which defines standard operations like `SaveMetaAsync`, `LoadMetaAsync`, `RemoveMetaAsync` for meta information management.
170170
* **`Helpers/`**: Contains utility classes and extension methods that provide common, reusable functions (e.g., file I/O helpers, string manipulation, UI helpers).
171171
* `VisibilityHelper.cs`: Provides converters for XAML bindings, e.g., converting a string's null/empty status to a `Visibility` value.
172-
* `GalgameManager/Services/PluginService/PluginXamlHost.cs`: Bridges dynamically loaded plugin assemblies into the host app's WinUI XAML system by loading plugin PRI resources and registering plugin `IXamlMetadataProvider` implementations before plugin UI is initialized.
172+
* `GalgameManager/Services/PluginService/PluginXamlHost.cs`: Bridges dynamically loaded plugin assemblies into the host app's WinUI XAML system by loading plugin PRI resources and registering plugin `IXamlMetadataProvider` implementations before plugin UI is initialized. Its dev-plugin hot-reload staging directory (`HotReloadRoot`) must live under `AppStoragePaths.LocalDataPath`, never `AppContext.BaseDirectory`: for MSIX installs the base directory is the read-only `C:\Program Files\WindowsApps\...` folder, so writing there throws `UnauthorizedAccessException` (issue #693). In general, never write runtime files under `AppContext.BaseDirectory`; use `AppStoragePaths.LocalDataPath`/`TempPath` (they handle MSIX, portable, and unpackaged cases).
173173
* **`Helpers/Phrase/`**: Contains the mixed phraser system for aggregating game information from multiple sources:
174174
* `MixedPhraser.cs`: The main mixed phraser implementation that combines data from multiple game information sources (Bangumi, VNDB, Ymgal, Steam, Hikarinagi). It supports selective enabling/disabling of individual phrasers through the `MixedPhraserEnabled` configuration. `GetGalgameInfo` waits on all parallel source tasks with a unified soft timeout (`TimeoutSeconds`); incomplete/faulted sources are dropped before merge.
175175
* `VndbPhraser.cs`: VNDB queries that use the `search` filter must sort by `searchrank`; ID-based queries should keep their native ordering. API calls that may be throttled should use the shared retry wrapper so a retry preserves the original query.

GalgameManager/Services/PluginService/PluginXamlHost.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ namespace GalgameManager.Services;
1212

1313
internal static class PluginXamlHost
1414
{
15-
public static string HotReloadRoot => Path.Combine(AppContext.BaseDirectory, "_PluginXamlHotReload");
15+
// MSIX 的安装目录是只读的,热重载暂存目录必须放在可写的应用数据目录下(见 issue #693)
16+
public static string HotReloadRoot => Path.Combine(AppStoragePaths.LocalDataPath, "_PluginXamlHotReload");
1617
private static readonly object SyncRoot = new();
1718
private static readonly ConcurrentDictionary<string, PluginAssemblyRegistration> Registrations = new();
1819

0 commit comments

Comments
 (0)