Skip to content

feat(SearchInp): 支持搜索词同步#886

Merged
imsyy merged 1 commit into
SPlayer-Dev:devfrom
MoYingJi:pr/s
Feb 15, 2026
Merged

feat(SearchInp): 支持搜索词同步#886
imsyy merged 1 commit into
SPlayer-Dev:devfrom
MoYingJi:pr/s

Conversation

@MoYingJi
Copy link
Copy Markdown
Collaborator

clearSearchOnBlur 设置项扩充为 searchInputBehavior,保留原有的 normalclear 模式,增加了 sync 模式(如果当前是搜索页,则同步搜索页的搜索词到搜索框,如果是其他页面,则清空搜索框)

Copilot AI review requested due to automatic review settings February 14, 2026 09:37
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @MoYingJi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在增强应用程序中搜索框的用户体验和灵活性。通过将单一的“失焦自动清空”设置项扩展为一个更全面的“搜索框行为”设置,引入了“同步搜索词”模式。这意味着用户现在可以选择在搜索框失去焦点时保留搜索词、清空搜索词,或者在导航到搜索页面时自动同步页面上的搜索关键词,从而提供更智能和个性化的搜索交互。

Highlights

  • 搜索框行为设置扩展: 将原有的单一“失焦自动清空搜索框”设置项升级为更灵活的“搜索框模式”选择,提供了“保留搜索词”、“失焦后清空”和“同步搜索词”三种模式。
  • 新增搜索词同步功能: 引入了“同步搜索词”模式,当用户处于搜索页面时,搜索框会自动同步当前页面的搜索关键词;在其他页面则清空搜索框内容,提升了搜索体验的智能化。
  • 设置界面与数据迁移更新: 更新了设置界面以支持新的多模式选择,并实现了设置项的数据迁移逻辑,确保从旧版设置平滑过渡到新的行为模式。
Changelog
  • src/components/Search/SearchInp.vue
    • 引入了 useRoute 钩子以访问当前路由信息。
    • 新增 syncSearchInput 函数,用于根据当前路由(特别是搜索页)同步或清空搜索框内容。
    • 修改了 closeSearchFocus 函数,使其根据 searchInputBehavior 设置来处理搜索框的清空或同步逻辑。
    • 更新了 toSearch 函数中清空搜索框的条件判断,以适配新的 searchInputBehavior 设置。
    • 添加了路由和 searchInputBehavior 变化的监听器,以在“同步搜索词”模式下自动更新搜索框。
  • src/components/Setting/config/general.ts
    • clearSearchOnBlur 设置项替换为 searchInputBehavior,并将其类型从开关改为选择器。
    • searchInputBehavior 提供了“保留搜索词”、“失焦后清空”和“同步搜索词”三个选项。
  • src/stores/migrations/settingMigrations.ts
    • 将设置 Schema 版本号从 9 更新到 10。
    • 添加了版本 10 的迁移逻辑,将旧的 clearSearchOnBlur 设置转换为新的 searchInputBehavior 设置。
  • src/stores/setting.ts
    • 更新了 SettingState 接口,将 clearSearchOnBlur 属性替换为 searchInputBehavior,并定义了其可能的字符串字面量类型。
    • 修改了 useSettingStoresearchInputBehavior 的默认值为 "normal"
Activity
  • 此拉取请求目前没有额外的评论或审查活动。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

这个 PR 通过引入 searchInputBehavior 设置项,很好地扩展了搜索框的行为,替代了原有的 clearSearchOnBlur。代码实现很清晰,包括了对旧设置的迁移、UI 的更新以及核心逻辑的实现。我只发现了一个小问题,即在处理 URL 查询参数时可以更健壮一些,并已在代码中提出了具体建议。总体来说,这是一个高质量的提交。

const syncSearchInput = () => {
// 如果当前是搜索页,则同步搜索页的搜索词到搜索框,如果是其他页面,则清空搜索框
if (String(route.name).startsWith("search") && route.query.keyword) {
statusStore.searchInputValue = String(route.query.keyword);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

route.query.keyword 是一个数组时(例如 URL 为 ...?keyword=a&keyword=b),String(route.query.keyword) 会将其转换为逗号分隔的字符串,如 "a,b"。这可能不是预期的行为。建议只取数组的第一个元素,以使行为更明确和健壮。

    statusStore.searchInputValue = (Array.isArray(route.query.keyword) ? route.query.keyword[0] : route.query.keyword) ?? "";

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the search input behavior by expanding the boolean clearSearchOnBlur setting into an enum-based searchInputBehavior setting with three modes: "normal" (retain search term), "clear" (clear on blur), and "sync" (synchronize with current page's search term).

Changes:

  • Replaced boolean clearSearchOnBlur setting with enum searchInputBehavior supporting three modes
  • Added migration logic to convert existing user settings from boolean to enum
  • Implemented "sync" mode that keeps the search input synchronized with the current route's search keyword
  • Updated settings UI from a switch to a select dropdown with three options

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/stores/setting.ts Updated setting type definition and default value from boolean to enum
src/stores/migrations/settingMigrations.ts Added migration v10 to convert old boolean setting to new enum
src/components/Setting/config/general.ts Changed UI control from switch to select with three mode options
src/components/Search/SearchInp.vue Implemented sync logic with route watcher and updated blur/search behavior handling

Comment thread src/components/Search/SearchInp.vue Outdated
@imsyy imsyy merged commit 749770e into SPlayer-Dev:dev Feb 15, 2026
@MoYingJi MoYingJi deleted the pr/s branch February 15, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants