头部搜索定位到搜索列表

This commit is contained in:
付民康
2025-03-19 12:46:46 +08:00
parent 96dc1240ec
commit 8f99b673db
2 changed files with 14 additions and 2 deletions

View File

@@ -57,7 +57,7 @@ const search = () => {
document.querySelector('#golbalSearch').blur();
return;
}
router.push({ name: 'Search', query: { val: searchStr.value || '', type: route?.query?.type || 'License' }});
router.push({ name: 'Search', query: { searchWord: searchStr.value || '', type: route?.query?.type || 'software' }});
};
const handleClear = () => {
router.push({ name: 'home' });

View File

@@ -107,7 +107,7 @@
import AdvanceSearch from '@/components/AdvanceSearch/index.vue'
import SettingTitle from '@/components/Setting/SettingTitle/index.vue';
import SettingText from '@/components/Setting/SettingText/index.vue';
import { ref,reactive, onMounted } from 'vue';
import { ref,reactive, onMounted,watch } from 'vue';
import { getGroupClaList, setGroupClaStatus, deleteGroupCla } from '@/api/cla';
import { useRouter, useRoute } from 'vue-router';
import { GModal } from '@/components/Setting/index';
@@ -322,6 +322,18 @@ onMounted(() => {
...query
};
});
// 监听路由变化,更新 searchWord
watch(
() => route.query.searchWord, // 监听路由的 searchWord 参数
(newSearchWord) => {
if (newSearchWord) {
newFormData.value.searchWord = newSearchWord; // 更新组件的 searchWord
getReleaseList(); // 重新调用接口
}
},
{ immediate: true } // 立即执行一次
);
</script>
<style scoped lang="scss">