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