perf: 优化搜索替换体验

This commit is contained in:
pipipi-pikachu 2023-09-10 14:55:10 +08:00
parent c41f23a2f3
commit 3528368507

View File

@ -13,7 +13,7 @@
:class="{ 'active': type === tab.key }"
v-for="tab in tabs"
:key="tab.key"
@click="type = tab.key"
@click="changeTab(tab.key)"
@mousedown.stop
>{{tab.label}}</div>
</div>
@ -37,7 +37,7 @@
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import { nextTick, onMounted, ref } from 'vue'
import { useMainStore } from '@/store'
import useSearch from '@/hooks/useSearch'
import MoveablePanel from '@/components/MoveablePanel.vue'
@ -80,6 +80,13 @@ const searchInpRef = ref<HTMLInputElement>()
onMounted(() => {
searchInpRef.value!.focus()
})
const changeTab = (key: TypeKey) => {
type.value = key
nextTick(() => {
searchInpRef.value!.focus()
})
}
</script>
<style lang="scss" scoped>