完善社区接入、模组翻译与商店打包 - #5
Conversation
|
@copilot 检查一下 有关于 社区 Mod 这个 WinUI 是否存在崩溃 |
|
@DZXH-TX Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub. You can ask me to try again later by mentioning me in a new comment. If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: Sorry for the inconvenience! |
Co-authored-by: DZXH-TX <132790617+DZXH-TX@users.noreply.github.com>
已排查并修复一个社区 Mod 页面的 WinUI 崩溃风险:在页面导航离开时, |
There was a problem hiding this comment.
Pull request overview
This PR expands LocaleSmith with a first-party “Mod community” experience (authenticated via PAT stored in the existing credential-backed secret store), strengthens archive packaging safety via layered static validation and explicit unsigned-copy behavior for signed JARs, and updates packaging/docs/contracts to match the new capabilities and Store identity.
Changes:
- Add Mod Platform integration (models/contracts, credential services, endpoint policy, artifact downloader) and wire it into the WinUI app (Community page + navigation + DI).
- Introduce layered archive static validation and unsigned-copy manifest sanitization (including signature/digest claim cleanup), with new/updated contract tests.
- Update MSIX packaging identity/dependencies, publish profiles (self-contained), and expand five-language UI/package resources + README updates.
Reviewed changes
Copilot reviewed 58 out of 58 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/LocaleSmith.Archive.Tests/ModArtifactStaticValidationTests.cs | New end-to-end tests covering static validation, unsigned copy, and tamper detection. |
| tests/LocaleSmith.Archive.Tests/ArchiveWorkspaceBackendTests.cs | Updates signature/manifest cleanup expectations for unsigned copies. |
| tests/LocaleSmith.App.Tests/XamlThemeContractTests.cs | New contract test ensuring Expander motion behavior isn’t tied to internal WinUI style keys. |
| tests/LocaleSmith.App.Tests/ShellNavigationMapTests.cs | Adds Community section routing assertions. |
| tests/LocaleSmith.App.Tests/PipelineTranslationQueueServiceTests.cs | Asserts queue defaults for unsigned-copy handling + hardcoded string mode. |
| tests/LocaleSmith.App.Tests/NavigationInitializationCoordinatorTests.cs | New concurrency/behavior tests for navigation initialization coordination. |
| tests/LocaleSmith.App.Tests/LocalizationResourceContractTests.cs | Adds Community page UI/resource contracts + Store manifest identity/capability contracts. |
| tests/LocaleSmith.App.Tests/LegacyAppDataMigratorTests.cs | Adds migration coverage for previous LocaleSmith package identity roots. |
| tests/LocaleSmith.App.Tests/LegacyAppDataLocatorTests.cs | Extends legacy root discovery/prioritization to include LocaleSmith.Desktop identity. |
| src/LocaleSmith.Presentation/Models/AppConfiguration.cs | Adds ShellSection.Community. |
| src/LocaleSmith.McpHost/Properties/PublishProfiles/win-x64.pubxml | Switches publish to self-contained output. |
| src/LocaleSmith.Infrastructure/ModPlatform/SecretStoreModPlatformCredentialService.cs | New PAT persistence service backed by credential-backed secret store. |
| src/LocaleSmith.Infrastructure/ModPlatform/SecretStoreModPlatformAccessTokenProvider.cs | New secret resolver wrapper for optional PAT lookup. |
| src/LocaleSmith.Infrastructure/ModPlatform/ModPlatformHttpClientFactory.cs | Centralizes HTTP handler/timeouts for Mod Platform requests/transfers. |
| src/LocaleSmith.Infrastructure/ModPlatform/ModPlatformException.cs | Adds stable service-error contract for Mod Platform failures. |
| src/LocaleSmith.Infrastructure/ModPlatform/ModPlatformEndpointPolicy.cs | Pins production origin; allows loopback override only in Development with strict constraints. |
| src/LocaleSmith.Infrastructure/ModPlatform/ModPlatformArtifactDownloader.cs | Implements resumable artifact download with same-origin + ETag + SHA-256 verification. |
| src/LocaleSmith.Infrastructure/ModPlatform/ModPlatformApiContract.cs | Enforces transport-level API version invariants for /api/v1/ endpoints. |
| src/LocaleSmith.Core/Models/ModPlatformModels.cs | Adds Mod Platform DTOs for meta/auth/mod/forum/report/upload/download flows. |
| src/LocaleSmith.Core/Abstractions/ModPlatformContracts.cs | Adds Mod Platform client/downloader/token/provider/credential service abstractions. |
| src/LocaleSmith.Archive/LocaleSmith.Archive.csproj | Exposes internals to Archive test project. |
| src/LocaleSmith.Archive/JarManifestDocument.cs | New strict manifest parser/rewriter to remove signature/digest claims for unsigned copies. |
| src/LocaleSmith.Archive/ArchiveWorkspace.cs | Adds unsigned manifest override generation + static validation + staged override byte verification. |
| src/LocaleSmith.Archive/ArchivePathSafety.cs | Extends signature path detection to include SIG-*. |
| src/LocaleSmith.Application/Models/PipelineModels.cs | Extends verification model with validation mode, compilation flag, completed checks, warnings. |
| src/LocaleSmith.App/Themes/Controls.xaml | Removes Expander style dependency on internal WinUI key. |
| src/LocaleSmith.App/Strings/zh-CN/Resources.resw | Adds Community UI strings and reporting strings (zh-CN). |
| src/LocaleSmith.App/Strings/ru-RU/Resources.resw | Adds Community UI strings and reporting strings (ru-RU). |
| src/LocaleSmith.App/Strings/ja-JP/Resources.resw | Adds Community UI strings and reporting strings (ja-JP). |
| src/LocaleSmith.App/Strings/fr-FR/Resources.resw | Adds Community UI strings and reporting strings (fr-FR). |
| src/LocaleSmith.App/Strings/en-US/Resources.resw | Adds Community UI strings and reporting strings (en-US). |
| src/LocaleSmith.App/ShellNavigationMap.cs | Maps Community section to CommunityPage. |
| src/LocaleSmith.App/Services/PipelineTranslationQueueService.cs | Changes default signed-archive behavior to “explicit unsigned copy”. |
| src/LocaleSmith.App/Services/NavigationInitializationCoordinator.cs | New helper to serialize initialization across navigation cycles. |
| src/LocaleSmith.App/Services/LegacyAppDataMigrator.cs | Adds migration path for previous LocaleSmith package identity configuration location. |
| src/LocaleSmith.App/Services/LegacyAppDataLocator.cs | Adds LocaleSmith.Desktop identity discovery + priority ordering. |
| src/LocaleSmith.App/Properties/PublishProfiles/win-x64.pubxml | Switches publish to self-contained output. |
| src/LocaleSmith.App/Pages/CommunityPage.xaml.cs | New Community page code-behind: initialization, sign-in flow, and report dialogs. |
| src/LocaleSmith.App/MainWindow.xaml | Adds Community navigation item. |
| src/LocaleSmith.App/Dialogs/CliConfirmationDialog.xaml | Adds per-control Expander motion feedback property. |
| src/LocaleSmith.App/App.xaml.cs | Registers Mod Platform services + CommunityViewModel in DI. |
| README.md | Documents community feature, unsigned-copy behavior, Store identity, and updated test/resource baselines. |
| README.en.md | English equivalent documentation updates for the same contracts/baselines. |
| packaging/LocaleSmith.Package/Strings/zh-CN/Resources.resw | Updates PublisherDisplayName string. |
| packaging/LocaleSmith.Package/Strings/ru-RU/Resources.resw | Updates PublisherDisplayName string. |
| packaging/LocaleSmith.Package/Strings/ja-JP/Resources.resw | Updates PublisherDisplayName string. |
| packaging/LocaleSmith.Package/Strings/fr-FR/Resources.resw | Updates PublisherDisplayName string. |
| packaging/LocaleSmith.Package/Strings/en-US/Resources.resw | Updates PublisherDisplayName string. |
| packaging/LocaleSmith.Package/Package.appxmanifest | Switches to Partner Center identity/version; adds VCLibs dependency; updates PublisherDisplayName. |
| native/localesmith_core/tests/archive_scan.rs | Adds test for SIG-* signature-block detection. |
| native/localesmith_core/src/scanner.rs | Updates signature scanning + repack warning text; includes SIG-* blocks. |
| native/localesmith_core/src/model.rs | Updates signature block doc to include SIG-*. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (name.Length is 0 or > 70 || !char.IsAsciiLetterOrDigit(name[0]) || | ||
| name.Any(static character => !char.IsAsciiLetterOrDigit(character) && character is not '_' and not '-')) |
| if (!baseUri.IsAbsoluteUri | ||
| || (!string.Equals(baseUri.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase) | ||
| && !(allowLoopbackHttp | ||
| && baseUri.IsLoopback | ||
| && string.Equals(baseUri.Scheme, Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase))) | ||
| || !string.IsNullOrEmpty(baseUri.UserInfo) |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83d0901550
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <Grid | ||
| x:Name="AuthenticatedCommunityContent" | ||
| Grid.Row="2" | ||
| ColumnSpacing="16" | ||
| Visibility="{Binding IsAuthenticated, Converter={StaticResource BooleanToVisibilityConverter}}"> |
There was a problem hiding this comment.
Keep public community content visible when signed out
Remove the authentication-only visibility gate from the browsing surface. When no PAT is configured, IsAuthenticated is false, so this grid—and therefore every mod, thread, post, and pagination control—is collapsed and replaced by the sign-in form. This defeats the public read path already implemented with unauthenticated GetModsAsync, GetThreadsAsync, and GetPostsAsync calls, and prevents signed-out users from browsing the public community.
Useful? React with 👍 / 👎.
| builder.Services.AddSingleton(static _ => ModPlatformArtifactDownloader.CreateForApplication()); | ||
| builder.Services.AddSingleton<IModPlatformArtifactDownloader>(static services => | ||
| services.GetRequiredService<ModPlatformArtifactDownloader>()); |
There was a problem hiding this comment.
Connect the artifact downloader to the community flow
Wire this downloader registration into a user-facing download action. A repository-wide search finds no production consumer of IModPlatformArtifactDownloader beyond this registration: CommunityViewModel does not inject it, and CommunityPage exposes no download command or handler. Consequently, users can see LatestVersion metadata but can never invoke the newly added resumable, hash-verified downloader.
Useful? React with 👍 / 👎.
| var normalizedUsername = username?.Trim() ?? string.Empty; | ||
| if (normalizedUsername.Length == 0 || password.IsEmpty || applicationToken.IsEmpty) | ||
| { | ||
| ErrorMessage = Text( | ||
| "CommunityApplicationLoginFieldsRequiredError", | ||
| "Enter the username, password, and application token."); | ||
| return; |
There was a problem hiding this comment.
Allow passwordless compatibility-mode sign-in
Require the password only when SupportsApplicationLogin is true. If the server omits application_login_v1, the branch below authenticates solely through VerifyApplicationTokenAsync and explicitly says the password is neither sent nor saved, but this unconditional check still rejects an empty password before reaching that branch. Users of the compatibility endpoint therefore cannot sign in with the username and PAT that the endpoint actually requires.
Useful? React with 👍 / 👎.
| if (containsSourceBuild) | ||
| { | ||
| AddIssue( | ||
| blockingErrors, | ||
| "source or Gradle/build entries were detected. The archive pipeline will not execute untrusted build scripts; " + | ||
| "compile this source in an explicitly trusted build workflow and translate the resulting artifact."); |
There was a problem hiding this comment.
Reject source archives before invoking translation
Move this source/build-project gate ahead of the translation stage. TranslationPipeline calls the translation engine and applies its results before StagePackageAsync invokes this validator, so a source ZIP containing translatable language resources can consume model requests and complete all translation work only to be rejected here with no output. Detecting the same condition during inspection or extraction would fail unsupported source projects before users incur that time or API cost.
Useful? React with 👍 / 👎.
变更概要
验证
dotnet test LocaleSmith.slnx -c Release --no-restore:651/651 通过dotnet format LocaleSmith.slnx --verify-no-changes --no-restore:通过cargo fmt --manifest-path native/localesmith_core/Cargo.toml --all -- --check:通过cargo clippy --manifest-path native/localesmith_core/Cargo.toml --all-targets -- -D warnings:通过cargo test --manifest-path native/localesmith_core/Cargo.toml --all-targets:28/28 通过说明
此 PR 保持 Draft,等待人工审查后再合并;未启用自动合并。