feat: 记住资源搜索结果的排序选择 - #691
Open
sokouu87 wants to merge 1 commit into
Open
Conversation
搜索结果页的排序条件与方向此前只存在于组件状态里,每次重新进入结果页 都会回到「默认 + 降序」,用户每次都要手动重选一遍(例如习惯按大小降序)。 参照同一页面里视图类型的既有做法,把排序条件与方向持久化到 localStorage (MPTorrentsSortField / MPTorrentsSortType),进入结果页时恢复,变更时保存。 恢复时会校验取值合法性:排序条件必须是 sortTitles 里已存在的键, 方向只接受 asc / desc,非法值一律回落到原有默认行为。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
PR-Agent Code Review
此 PR 为资源搜索结果页新增排序字段与方向的本地持久化,并在恢复时校验存储值的合法性。改动未发现明确的行为缺陷,暂无需要提出的审查意见。
审查提交:0dd13aa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
资源搜索结果页的排序条件与方向只存在于组件状态里(
useTorrentFilter的sortField/sortType),每次重新进入结果页都会回到「默认 + 降序」。习惯固定用某种排序找资源的用户(例如按大小降序挑原盘/REMUX),每搜一次就要手点一遍。同一个页面里的「视图类型」已经通过
localStorage['MPTorrentsViewType']记住了,排序却没有。改动
只动
src/pages/resource.vue,18 行:localStorage恢复MPTorrentsSortField/MPTorrentsSortType恢复时做了合法性校验:排序条件必须是
sortTitles里已存在的键,方向只接受asc/desc,非法或缺失一律回落到原有默认值。所以首次使用、清空存储、以及从旧版本升级上来的行为都和现在完全一致。没有改
useTorrentFiltercomposable —— 持久化只发生在页面层,composable 的默认值与单测行为均不受影响。验证
yarn vitest run src/pages/__tests__/resource.spec.ts src/composables/__tests__/useTorrentFilter.spec.ts→ 47 passedyarn typecheck(vue-tsc --noEmit)→ 通过npx eslint src/pages/resource.vue --max-warnings=0→ 通过🤖 Generated with Claude Code
PR-Agent 摘要
🤖 Generated by PR Agent at 0dd13aa