feat(邀请金币代理页面): 搜索功能使用防抖功能
This commit is contained in:
parent
96be02a679
commit
c9087428ff
@ -204,6 +204,7 @@
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { setDocumentDirection } from '@/locales/i18n'
|
||||
import { useDebounce } from '@/utils/useDebounce'
|
||||
import { showError, showSuccess } from '@/utils/toast.js'
|
||||
import { handleAvatarImageError } from '@/utils/imageHandler.js'
|
||||
|
||||
@ -256,19 +257,28 @@ const handleInputChange = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 回车搜索
|
||||
const handleEnterPress = async () => {
|
||||
console.log('搜索用户id:', searchQuery.value)
|
||||
searchResults.value = []
|
||||
selectedUser.value = {}
|
||||
disInvite.value = true
|
||||
if (searchQuery.value.trim()) {
|
||||
const resSearchUser = await searchUser(searchQuery.value)
|
||||
if (resSearchUser.status && resSearchUser.body) {
|
||||
let targetUserInfo = { userProfile: resSearchUser.body }
|
||||
searchResults.value.push(targetUserInfo)
|
||||
// 创建防抖版本的搜索函数
|
||||
const debouncedSearch = useDebounce(
|
||||
async () => {
|
||||
console.log('搜索用户id:', searchQuery.value)
|
||||
searchResults.value = []
|
||||
selectedUser.value = {}
|
||||
disInvite.value = true
|
||||
if (searchQuery.value.trim()) {
|
||||
const resSearchUser = await searchUser(searchQuery.value)
|
||||
if (resSearchUser.status && resSearchUser.body) {
|
||||
let targetUserInfo = { userProfile: resSearchUser.body }
|
||||
searchResults.value.push(targetUserInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
500,
|
||||
true
|
||||
)
|
||||
|
||||
// 回车防抖搜索
|
||||
const handleEnterPress = () => {
|
||||
debouncedSearch()
|
||||
}
|
||||
|
||||
// 选择用户
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user