Skip to content

fix: 修复功能隐藏的各种奇妙小问题#2630

Open
xrlzu wants to merge 10 commits intodevfrom
fix/hidden
Open

fix: 修复功能隐藏的各种奇妙小问题#2630
xrlzu wants to merge 10 commits intodevfrom
fix/hidden

Conversation

@xrlzu
Copy link
Member

@xrlzu xrlzu commented Mar 21, 2026

功能隐藏 Bug 多多😰

Summary by Sourcery

调整 tools 和 setup 页面,在选择默认子页面和显示分类标题时遵从隐藏功能(hidden-feature)配置。

Bug 修复:

  • 确保 tools 页面根据第一个未隐藏的工具配置初始化选中的子页面,并在当前为隐藏页面时跳过重新加载。
  • 修复 setup 页面的默认选择和页面 ID 初始化顺序,使第一个可见的设置部分能够根据隐藏偏好被正确选中。
  • 同步 tools 分类标题的可见性与各个工具的可见性以及 hidden-force-show 模式。
  • 从左侧导航中移除已废弃的 tools 页面子类型处理,以避免错误的页面解析。

增强:

  • 在加载 tools 页面时触发一次可见性刷新,以便在首次加载时一致地应用隐藏功能状态。
Original summary in English

Summary by Sourcery

Adjust tools and setup pages to respect hidden-feature configuration while selecting default subpages and displaying category headers.

Bug Fixes:

  • Ensure tools page initializes the selected subpage based on the first non-hidden tool configuration and skips reloading when a hidden page is active.
  • Fix setup page default selection and page ID initialization order so the first visible setup section is chosen correctly according to hide preferences.
  • Synchronize visibility of tools category headers with individual tool visibility and hidden-force-show mode.
  • Remove obsolete tools page subtype handling from left navigation to avoid incorrect page resolution.

Enhancements:

  • Trigger a visibility refresh when loading the tools page so hidden-feature state is applied consistently on first load.

@pcl-ce-automation pcl-ce-automation bot added 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 size: S PR 大小评估:小型 labels Mar 21, 2026
@sourcery-ai
Copy link

sourcery-ai bot commented Mar 21, 2026

Reviewer's Guide

调整工具和设置页面的可见性逻辑,使初始选择和分类标题能够正确尊重隐藏功能配置和强制显示模式,并从导航中移除未使用的工具页面子类型分支。

工具页面加载和可见性刷新时序图

sequenceDiagram
    actor User
    participant FormMain
    participant PageToolsLeft
    participant PageSetupUI
    participant ConfigPreferenceHide

    User->>FormMain: NavigateToTools()
    FormMain->>PageToolsLeft: Show()
    PageToolsLeft->>PageToolsLeft: PageLinkLeft_Loaded()
    PageToolsLeft->>ConfigPreferenceHide: Read Hide config
    PageToolsLeft->>PageToolsLeft: Determine IsHiddenPage
    PageToolsLeft->>PageSetupUI: HiddenRefresh()
    PageSetupUI->>ConfigPreferenceHide: Read Hide config
    PageSetupUI->>PageToolsLeft: Set item visibility
    PageSetupUI->>PageToolsLeft: Set TextGameLinkCategory visibility
    PageSetupUI->>PageToolsLeft: Set TextToolsCategory visibility
    PageToolsLeft->>PageToolsLeft: If not IsLoad or IsHiddenPage
    PageToolsLeft->>PageToolsLeft: Select first nonhidden tools subtype
    PageToolsLeft->>FormMain: Update PageID for tools
    FormMain-->>User: Tools page shown with correct items and headers
Loading

更新后的设置与工具导航可见性逻辑类图

classDiagram
    class PageToolsLeft {
        -IsLoad Boolean
        -IsPageSwitched Boolean
        +PageID FormMain_PageSubType
        +AnimatedControl Object
        +New()
        +PageLinkLeft_Loaded(sender Object, e RoutedEventArgs) Void
        +PageGet(ID FormMain_PageSubType) Object
        +ItemGameLink Object
        +ItemLauncherHelp Object
        +ItemTest Object
        +TextGameLinkCategory Object
        +TextToolsCategory Object
    }

    class PageSetupLeft {
        -IsLoad Boolean
        -IsPageSwitched Boolean
        +PageID FormMain_PageSubType
        +New()
        +PageLinkLeft_Loaded(sender Object, e RoutedEventArgs) Void
        +ItemLaunch Object
        +ItemJava Object
        +ItemGameManage Object
        +ItemGameLink Object
        +ItemUI Object
        +ItemLauncherMisc Object
        +ItemAbout Object
        +ItemUpdate Object
        +ItemFeedback Object
        +ItemLog Object
    }

    class PageSetupUI {
        +HiddenForceShow Boolean
        +HiddenRefresh() Void
    }

    class ConfigPreferenceHide {
        +ToolsGameLink Boolean
        +ToolsHelp Boolean
        +ToolsTest Boolean
        +SetupLaunch Boolean
        +SetupJava Boolean
        +SetupGameManage Boolean
        +SetupGameLink Boolean
        +SetupUi Boolean
        +SetupLauncherMisc Boolean
        +SetupAbout Boolean
        +SetupUpdate Boolean
        +SetupFeedback Boolean
        +SetupLog Boolean
    }

    class ConfigPreference {
        +Hide ConfigPreferenceHide
    }

    class Config {
        +Preference ConfigPreference
    }

    class FormMain_PageSubType {
        <<enumeration>>
        +ToolsGameLink
        +ToolsTest
        +ToolsLauncherHelp
        +SetupLaunch
        +SetupJava
        +SetupGameManage
        +SetupGameLink
        +SetupUI
        +SetupLauncherMisc
        +SetupAbout
        +SetupUpdate
        +SetupFeedback
        +SetupLog
    }

    PageSetupUI --> ConfigPreferenceHide : reads
    PageToolsLeft --> ConfigPreferenceHide : reads
    PageSetupLeft --> ConfigPreferenceHide : reads
    ConfigPreferenceHide <-- ConfigPreference
    ConfigPreference <-- Config
    PageToolsLeft --> FormMain_PageSubType : uses
    PageSetupLeft --> FormMain_PageSubType : uses
    PageSetupUI --> PageToolsLeft : updates visibility
Loading

File-Level Changes

Change Details Files
将工具页面的初始选择和导航与隐藏配置及强制显示行为对齐,并移除未使用的子类型。
  • 在工具左侧页面加载时,根据 Config.Preference.HideHiddenForceShow 计算当前已勾选项是否被隐藏,刷新可见性,并且只在已经加载且仍然可见时才提前返回。
  • 在工具左侧页面加载以及构造函数中更改默认子页面选择逻辑,选取第一个未隐藏的工具子页面,当全部被隐藏时使用回退方案。
  • 从工具左侧的 PageGet 中移除已废弃的 SetupGameLink 分支以及隐式的数值分支,使其只解析工具子类型。
Plain Craft Launcher 2/Pages/PageTools/PageToolsLeft.xaml.vb
将设置页面的隐藏处理扩展到所有设置子页面,并使初始选择与该排序保持一致。
  • 在设置左侧页面加载时扩展 IsHiddenPage 计算范围,使其在沿用 HiddenForceShow 的前提下,将 Java、GameLink、LauncherMisc、About、Update、Feedback 和 Log 条目也纳入计算。
  • 重新排序设置左侧页面加载时默认勾选项的选择逻辑,按新的优先级顺序选择第一个未隐藏的条目(Launch → Java → GameManage → GameLink → UI → LauncherMisc → About → Update → Feedback → Log)。
  • 在设置左侧构造函数中初始化 PageID 时同样遵循该优先级顺序,以保证底层页面子类型与可见的默认选项卡一致。
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLeft.xaml.vb
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLeft.xaml
保持工具分类标题与条目可见性和强制显示模式同步。
  • HiddenRefresh 中,在更新工具条目可见性之后,根据当前隐藏配置和 HiddenForceShow 计算 GameLink 和 Tools 分类标题的可见性。
  • 当标题可见时,将其不透明度设为 0.6,以匹配预期样式,同时在没有子项显示时确保标题完全隐藏。
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.vb
Plain Craft Launcher 2/Pages/PageTools/PageToolsLeft.xaml

Tips and commands

Interacting with Sourcery

  • 触发新的代码评审: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论。
  • 从评审评论生成 GitHub Issue: 通过回复某条评审评论,要求 Sourcery 基于该评论创建一个 Issue。你也可以在评审评论下回复 @sourcery-ai issue 来从该评论创建 Issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 正文任意位置写上 @sourcery-ai summary,即可在该位置生成 PR 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成评审者指南: 在 Pull Request 中评论 @sourcery-ai guide,即可随时(重新)生成评审者指南。
  • 解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已经处理完所有评论且不想再看到它们,这会非常有用。
  • 取消所有 Sourcery 评审: 在 Pull Request 中评论 @sourcery-ai dismiss,即可取消所有现有的 Sourcery 评审。尤其适合在你想重新开始一次新的评审时使用——别忘了再评论一次 @sourcery-ai review 来触发新评审!

Customizing Your Experience

访问你的 dashboard 以:

  • 启用或禁用评审功能,例如 Sourcery 生成的 Pull Request 摘要、评审者指南等。
  • 更改评审语言。
  • 添加、移除或编辑自定义评审说明。
  • 调整其他评审设置。

Getting Help

Original review guide in English

Reviewer's Guide

Adjusts tools and setup page visibility logic so initial selection and category headers correctly respect hidden-feature configuration and force-show mode, and removes an unused tools page subtype branch from navigation.

Sequence diagram for tools page load and visibility refresh

sequenceDiagram
    actor User
    participant FormMain
    participant PageToolsLeft
    participant PageSetupUI
    participant ConfigPreferenceHide

    User->>FormMain: NavigateToTools()
    FormMain->>PageToolsLeft: Show()
    PageToolsLeft->>PageToolsLeft: PageLinkLeft_Loaded()
    PageToolsLeft->>ConfigPreferenceHide: Read Hide config
    PageToolsLeft->>PageToolsLeft: Determine IsHiddenPage
    PageToolsLeft->>PageSetupUI: HiddenRefresh()
    PageSetupUI->>ConfigPreferenceHide: Read Hide config
    PageSetupUI->>PageToolsLeft: Set item visibility
    PageSetupUI->>PageToolsLeft: Set TextGameLinkCategory visibility
    PageSetupUI->>PageToolsLeft: Set TextToolsCategory visibility
    PageToolsLeft->>PageToolsLeft: If not IsLoad or IsHiddenPage
    PageToolsLeft->>PageToolsLeft: Select first nonhidden tools subtype
    PageToolsLeft->>FormMain: Update PageID for tools
    FormMain-->>User: Tools page shown with correct items and headers
Loading

Class diagram for updated setup and tools navigation visibility logic

classDiagram
    class PageToolsLeft {
        -IsLoad Boolean
        -IsPageSwitched Boolean
        +PageID FormMain_PageSubType
        +AnimatedControl Object
        +New()
        +PageLinkLeft_Loaded(sender Object, e RoutedEventArgs) Void
        +PageGet(ID FormMain_PageSubType) Object
        +ItemGameLink Object
        +ItemLauncherHelp Object
        +ItemTest Object
        +TextGameLinkCategory Object
        +TextToolsCategory Object
    }

    class PageSetupLeft {
        -IsLoad Boolean
        -IsPageSwitched Boolean
        +PageID FormMain_PageSubType
        +New()
        +PageLinkLeft_Loaded(sender Object, e RoutedEventArgs) Void
        +ItemLaunch Object
        +ItemJava Object
        +ItemGameManage Object
        +ItemGameLink Object
        +ItemUI Object
        +ItemLauncherMisc Object
        +ItemAbout Object
        +ItemUpdate Object
        +ItemFeedback Object
        +ItemLog Object
    }

    class PageSetupUI {
        +HiddenForceShow Boolean
        +HiddenRefresh() Void
    }

    class ConfigPreferenceHide {
        +ToolsGameLink Boolean
        +ToolsHelp Boolean
        +ToolsTest Boolean
        +SetupLaunch Boolean
        +SetupJava Boolean
        +SetupGameManage Boolean
        +SetupGameLink Boolean
        +SetupUi Boolean
        +SetupLauncherMisc Boolean
        +SetupAbout Boolean
        +SetupUpdate Boolean
        +SetupFeedback Boolean
        +SetupLog Boolean
    }

    class ConfigPreference {
        +Hide ConfigPreferenceHide
    }

    class Config {
        +Preference ConfigPreference
    }

    class FormMain_PageSubType {
        <<enumeration>>
        +ToolsGameLink
        +ToolsTest
        +ToolsLauncherHelp
        +SetupLaunch
        +SetupJava
        +SetupGameManage
        +SetupGameLink
        +SetupUI
        +SetupLauncherMisc
        +SetupAbout
        +SetupUpdate
        +SetupFeedback
        +SetupLog
    }

    PageSetupUI --> ConfigPreferenceHide : reads
    PageToolsLeft --> ConfigPreferenceHide : reads
    PageSetupLeft --> ConfigPreferenceHide : reads
    ConfigPreferenceHide <-- ConfigPreference
    ConfigPreference <-- Config
    PageToolsLeft --> FormMain_PageSubType : uses
    PageSetupLeft --> FormMain_PageSubType : uses
    PageSetupUI --> PageToolsLeft : updates visibility
Loading

File-Level Changes

Change Details Files
Align tools page initial selection and navigation with hide configuration and force-show behavior, and drop unused subtype.
  • On tools-left load, compute whether the current checked item is hidden based on Config.Preference.Hide and HiddenForceShow, refresh visibility, and only short-circuit when already loaded and still visible.
  • Change default subpage selection on tools-left load and in the constructor to choose the first non-hidden tools subpage, with a fallback when all are hidden.
  • Remove the obsolete SetupGameLink case from tools-left PageGet and the implicit numeric case branch, so only tools subtypes are resolved.
Plain Craft Launcher 2/Pages/PageTools/PageToolsLeft.xaml.vb
Expand setup page hide handling to all setup subpages and make initial selection consistent with that ordering.
  • Extend IsHiddenPage computation on setup-left load to include Java, GameLink, LauncherMisc, About, Update, Feedback, and Log items in addition to existing ones, all honoring HiddenForceShow.
  • Reorder the default checked item selection on setup-left load to pick the first non-hidden item in a new priority order (Launch → Java → GameManage → GameLink → UI → LauncherMisc → About → Update → Feedback → Log).
  • Mirror the same priority order when initializing PageID in the setup-left constructor so the backing page subtype matches the visible default tab.
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLeft.xaml.vb
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLeft.xaml
Keep tools category headers in sync with item visibility and force-show mode.
  • In HiddenRefresh, after updating tools item visibility, compute visibility for the GameLink and Tools category headers based on the current hide configuration and HiddenForceShow.
  • Set header opacity to 0.6 when visible to match intended styling while ensuring headers fully hide when no child items are shown.
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.vb
Plain Craft Launcher 2/Pages/PageTools/PageToolsLeft.xaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@pcl-ce-automation pcl-ce-automation bot added size: M PR 大小评估:中型 and removed size: S PR 大小评估:小型 labels Mar 22, 2026
@pcl-ce-automation pcl-ce-automation bot added size: L PR 大小评估:大型 and removed size: M PR 大小评估:中型 labels Mar 22, 2026
@pcl-ce-automation pcl-ce-automation bot added size: M PR 大小评估:中型 and removed size: L PR 大小评估:大型 labels Mar 22, 2026
@pcl-ce-automation pcl-ce-automation bot added size: L PR 大小评估:大型 and removed size: M PR 大小评估:中型 labels Mar 22, 2026
@xrlzu xrlzu marked this pull request as ready for review March 22, 2026 05:40
@pcl-ce-automation pcl-ce-automation bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 and removed 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 labels Mar 22, 2026
@xrlzu xrlzu requested review from a team and MoYuan-CN March 22, 2026 05:40
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出一些总体反馈:

  • 用于选择第一个未隐藏工具子页面的逻辑在 PageToolsLeft.NewPageToolsLeft_Loaded 之间有重复;可以考虑把这段逻辑抽取到一个共享的辅助方法中,这样选择规则就集中在一个地方了。
  • PageSetupLeft_Loaded 中,对不同的条目既有使用本地变量 hide,也有直接访问 Config.Preference.Hide 的情况;统一采用一种方式会让可见性条件更容易理解,也更不容易出错。
  • PageSetupUI.HiddenRefresh 中针对工具分类标题的新可见性逻辑,在每个条件里都显式包含了 HiddenForceShow,但它其实已经在全局层面处理过了;你可能可以简化这些表达式,在不改变行为的前提下提升可读性。
给 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- The logic for choosing the first non-hidden tools subpage is duplicated between PageToolsLeft.New and PageToolsLeft_Loaded; consider extracting this into a shared helper to keep the selection rules in one place.
- In PageSetupLeft_Loaded you mix use of the local `hide` variable and direct `Config.Preference.Hide` access for different items; standardizing on one approach will make the visibility conditions easier to follow and less error-prone.
- The new visibility logic for tools category headers in PageSetupUI.HiddenRefresh includes `HiddenForceShow` in each condition even though it's already handled globally; you may be able to simplify these expressions to improve readability without changing behavior.

Sourcery 对开源项目免费 —— 如果你觉得我们的评审有帮助,欢迎帮忙分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈来改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • The logic for choosing the first non-hidden tools subpage is duplicated between PageToolsLeft.New and PageToolsLeft_Loaded; consider extracting this into a shared helper to keep the selection rules in one place.
  • In PageSetupLeft_Loaded you mix use of the local hide variable and direct Config.Preference.Hide access for different items; standardizing on one approach will make the visibility conditions easier to follow and less error-prone.
  • The new visibility logic for tools category headers in PageSetupUI.HiddenRefresh includes HiddenForceShow in each condition even though it's already handled globally; you may be able to simplify these expressions to improve readability without changing behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The logic for choosing the first non-hidden tools subpage is duplicated between PageToolsLeft.New and PageToolsLeft_Loaded; consider extracting this into a shared helper to keep the selection rules in one place.
- In PageSetupLeft_Loaded you mix use of the local `hide` variable and direct `Config.Preference.Hide` access for different items; standardizing on one approach will make the visibility conditions easier to follow and less error-prone.
- The new visibility logic for tools category headers in PageSetupUI.HiddenRefresh includes `HiddenForceShow` in each condition even though it's already handled globally; you may be able to simplify these expressions to improve readability without changing behavior.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L PR 大小评估:大型 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants