完善搜索功能:

1. 添加搜索方法实现,支持关键词搜索
2. 实现取消搜索功能,清空搜索结果
3. 添加搜索结果展示组件
4. 优化搜索结果样式,使用Element Plus风格
5. 添加搜索输入验证,防止空搜索
This commit is contained in:
Huangzhe
2025-05-12 14:18:06 +08:00
parent d10ab302d5
commit a648ef27fc
23 changed files with 385 additions and 12833 deletions

View File

@@ -0,0 +1,73 @@
<script setup lang="ts">
import { AiFillHome } from 'vue-icons-plus/ai';
import { h, ref } from 'vue';
import { useRouter, type RouteLocationRaw } from 'vue-router';
const router = useRouter()
const navigation = ref([
{
title: '主页',
link: {
name: 'home',
path: '/home'
},
icon: h(AiFillHome)
},
{
title: '伊调研',
link: {
name: 'home',
path: '/home'
},
icon: h(AiFillHome)
},
{
title: '我的',
link: {
name: '',
path: '/survey'
},
icon: h(AiFillHome)
}
]);
/**
* Handle changing of navigation
* @param {object} nav - the navigation item selected
*/
function handleChangeNav(nav: any) {
const params = {} as RouteLocationRaw
// 如果有 name 表示,优先取 name 参数
nav.link.name.length != 0 ? (params.name = nav.link.name as string) : (params.path = nav.link.path)
router.push(params)
}
</script>
<template>
<div class="navigation">
<section @click="handleChangeNav(item)" v-for="item in navigation" :key="item.title" class="navigation-item">
<component :is="item.icon"></component>
<div>{{ item.title }}</div>
</section>
</div>
</template>
<style scoped lang="scss">
.navigation {
width: 100vw;
background-color: white;
display: flex;
flex-flow: row;
justify-content: space-around;
position: fixed;
bottom: 0px;
z-index: 10;
}
.navigation-item {
display: flex;
flex-flow: column nowrap;
align-items: center;
}
</style>