fix(custom-page): 修复自定义主页不能正常跳转的问题 - #3528
Conversation
审阅者指南实现了新的 HelpDetail 页面以及自定义事件帮助 URL 的路由支持,包括远程 JSON/XAML 帮助内容支持,并重构了 GetAbsoluteUrls,以在解析和下载在线帮助定义的同时,将其接入主页面导航栈。 自定义 EventType.OpenHelp 处理与 HelpDetail 导航的时序图sequenceDiagram
participant CustomEvent
participant ModBase
participant GetAbsoluteUrls
participant PageHelpDetail
participant FormMain
CustomEvent->>CustomEvent: _OpenHelp(arg, type)
CustomEvent->>CustomEvent: SplitArgs(arg)
CustomEvent->>CustomEvent: Uri.TryCreate(args[0])
alt invalid_or_non_http_https_uri
CustomEvent->>ModBase: OpenWebsite(https://docs.pclc.cc/ce)
else valid_http_https_uri
CustomEvent->>ModBase: RunInThread(lambda)
ModBase->>GetAbsoluteUrls: GetAbsoluteUrls(args[0], type)
GetAbsoluteUrls-->>ModBase: [location, pclDir]
ModBase->>PageHelpDetail: LoadContent(location)
PageHelpDetail-->>ModBase: HelpContent
ModBase->>ModBase: RunInUiWait(lambda)
ModBase->>FormMain: PageChange(new PageStackData { page = PageType.HelpDetail, helpPage = new PageHelpDetail(content) })
end
文件级变更
与关联 issue 的对照评估
可能关联的 issues
技巧与指令与 Sourcery 交互
自定义你的使用体验访问你的 控制面板 可以:
获取帮助Original review guide in EnglishReviewer's GuideImplements a new HelpDetail page and routing for custom-event help URLs, including support for remote JSON/XAML-based help content, and refactors GetAbsoluteUrls to resolve and download online help definitions while wiring them into the main page navigation stack. Sequence diagram for custom EventType.OpenHelp handling and HelpDetail navigationsequenceDiagram
participant CustomEvent
participant ModBase
participant GetAbsoluteUrls
participant PageHelpDetail
participant FormMain
CustomEvent->>CustomEvent: _OpenHelp(arg, type)
CustomEvent->>CustomEvent: SplitArgs(arg)
CustomEvent->>CustomEvent: Uri.TryCreate(args[0])
alt invalid_or_non_http_https_uri
CustomEvent->>ModBase: OpenWebsite(https://docs.pclc.cc/ce)
else valid_http_https_uri
CustomEvent->>ModBase: RunInThread(lambda)
ModBase->>GetAbsoluteUrls: GetAbsoluteUrls(args[0], type)
GetAbsoluteUrls-->>ModBase: [location, pclDir]
ModBase->>PageHelpDetail: LoadContent(location)
PageHelpDetail-->>ModBase: HelpContent
ModBase->>ModBase: RunInUiWait(lambda)
ModBase->>FormMain: PageChange(new PageStackData { page = PageType.HelpDetail, helpPage = new PageHelpDetail(content) })
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我在这里给出了一些整体性的反馈:
- 在
_OpenHelp中,使用了SplitArgs(arg),并且在未检查数组长度的情况下访问了args[0],如果事件参数为空或格式错误,就可能抛出异常;建议在索引前先对args进行校验。
给 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- In `_OpenHelp`, `SplitArgs(arg)` is used and `args[0]` is accessed without checking the array length, which can throw if the event arg is empty or malformed; consider validating `args` before indexing.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've left some high level feedback:
- In
_OpenHelp,SplitArgs(arg)is used andargs[0]is accessed without checking the array length, which can throw if the event arg is empty or malformed; consider validatingargsbefore indexing.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `_OpenHelp`, `SplitArgs(arg)` is used and `args[0]` is accessed without checking the array length, which can throw if the event arg is empty or malformed; consider validating `args` before indexing.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8f47f5c44
ℹ️ 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".
| var json = ModMain.ArgumentReplace(File.ReadAllText(jsonPath), SecurityElement.Escape); | ||
| using var document = JsonDocument.Parse(json); |
There was a problem hiding this comment.
Escape replacement values as JSON, not XML
When the help JSON contains a launcher placeholder such as {path} or {version_path}, ArgumentReplace passes its Windows value through SecurityElement.Escape, which does not escape backslashes for JSON. The resulting value contains sequences such as C:\PCL/\P, so JsonDocument.Parse treats them as invalid JSON escapes and the custom help page never opens. Use JSON string escaping (or parse/replace the relevant JSON value) instead of XML escaping.
Useful? React with 👍 / 👎.
Close #3517
Summary by Sourcery
通过将 JSON/XAML 内容加载到专用的帮助详情页,添加从事件打开自定义帮助/主页的支持。
新特性:
EventType.OpenHelp解析本地或远程帮助资源,并在启动器中导航到相应的详情页。缺陷修复:
EventType.OpenHelp时能够正确打开目标帮助详情内容,而不再总是重定向到默认文档。增强功能:
Original summary in English
Summary by Sourcery
Add support for opening custom help/home pages from events by loading JSON/XAML content into a dedicated help detail page.
New Features:
Bug Fixes:
Enhancements: