refactor: 优化导航搜索跳转逻辑和代码格式

This commit is contained in:
wangqiao
2025-08-30 17:04:22 +08:00
parent 18d93d3a2a
commit cb89a861c1

View File

@ -11,7 +11,7 @@
placeholder="电子产品"
:prefix-icon="Search"
class="search-input h-[40px] w-[328px]"
@focus="handleHot(), (showHotList = true)"
@focus="(handleHot(), (showHotList = true))"
@input="handleInput"
></el-input>
<!-- 搜索框 获取到焦点 显示热门列表 -->
@ -67,11 +67,11 @@
import { top } from '~/api/home/index'
import type { ProjectDrawStatisticAppRespVO } from '~/api/home/type'
import { Search } from '@element-plus/icons-vue'
import refreshToken from "~/utils/RefreshToken";
import refreshToken from '~/utils/RefreshToken'
import useUserStore from '~/stores/user'
const userStore = useUserStore()
const app = useNuxtApp()
const props = defineProps({
active: {
type: String,
@ -131,22 +131,25 @@
}
const handleHotItem = (item: ProjectDrawStatisticAppRespVO) => {
const normal = { id: '0', name: '图纸库', isChildren: false }
const level = item.pairs?.filter(Boolean).map((item) => ({ id: item?.id, name: item?.name, isChildren: false })) || []
level.unshift(normal)
// const normal = { id: '0', name: '图纸库', isChildren: false }
// const level = item.pairs?.filter(Boolean).map((item) => ({ id: item?.id, name: item?.name, isChildren: false })) || []
// level.unshift(normal)
if (item.type === 1) {
navigateTo(`/drawe?level=${JSON.stringify(level)}&keywords=${item.title || ''}`)
navigateTo(`/drawe/${item.projectType}/1/12/-1`)
// navigateTo(`/drawe?level=${JSON.stringify(level)}&keywords=${item.title || ''}`)
} else if (item.type === 2) {
navigateTo(`/text?level=${JSON.stringify(level)}&keywords=${item.title || ''}`)
navigateTo(`/text/${item.projectType}/1/12/-1`)
// navigateTo(`/text?level=${JSON.stringify(level)}&keywords=${item.title || ''}`)
} else if (item.type === 3) {
navigateTo(`/model?level=${JSON.stringify(level)}&keywords=${item.title || ''}`)
navigateTo(`/model/${item.projectType}/1/12/-1`)
// navigateTo(`/model?level=${JSON.stringify(level)}&keywords=${item.title || ''}`)
}
}
const handleClick = (item: string) => {
switch (item) {
case '首页':
navigateTo({ path: '/'}) // 修改为在新窗口打开
navigateTo({ path: '/' }) // 修改为在新窗口打开
break
case '图纸':
navigateTo('/drawe') // 修改为在新窗口打开