fix: 搜索防抖、防止旧结果覆盖新搜索、修复 Windows 假失焦#1252
Open
Moeblack wants to merge 1 commit into
Open
Conversation
- SearchInput 添加 200ms 防抖,减少频繁查库 - useHistoryList 添加 fetchId 机制,丢弃过期请求结果,防止旧结果覆盖新搜索 - useHistoryList 添加 pendingReload,查询中途触发新搜索时自动接力 - useTauriFocus 添加 isFocused() 二次确认,缓解 Windows 上假失焦导致的 hideWindow/autoClear 相关 issues:EcoPasteHub#524 EcoPasteHub#882 EcoPasteHub#966
445c425 to
f5906ae
Compare
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.
概述
修复搜索历史记录时的三个问题:频繁查库卡顿、旧搜索结果覆盖新搜索、Windows 上假失焦导致窗口消失/搜索框清空。
问题 1:搜索无防抖
每个按键都立即触发一次数据库查询,快速输入时造成多次无意义的全表扫描。
修复:SearchInput 添加 200ms 防抖。
问题 2:旧搜索结果覆盖新搜索
用户快速输入时,先发出的查询可能晚于后发的查询返回,导致列表显示旧结果(视觉上"搜索回退")。
修复:
fetchId机制,每次查询递增 ID,返回时比对是否仍是最新请求queryKey比对,确保结果对应当前搜索条件pendingReload,查询中途触发新搜索时自动接力问题 3:Windows 假失焦
Windows 上
onFocusChanged偶尔会发出错误的失焦事件,触发hideWindow()隐藏窗口和autoClear清空搜索框。修复:
useTauriFocus在收到失焦事件后,用appWindow.isFocused()二次确认,减少误触发。相关 issues:#524 #882 #966