Files
hjc-web/app/pages/search.vue
T
weicw-dshsa 5a1a8610e5 refactor(search): 搜索结果页补类型并去掉重复的 usePageSeo 调用
代码审查(standards)发现的唯一 should-fix 项:新增的搜索结果页通篇用 any,
而仓库既有 Article / CaseItem / Tender 类型且 sibling 页面一律在用。

- 引入 Article、CaseItem、Tender 类型,新增 SearchResponse / Section<T>
  描述 /api/search 的响应形状(Section 用联合类型表达「成功 | 故障」,
  让 `'error' in s` 的判别在类型层面成立)
- section() 改为泛型 + 按 key 推导载荷类型,去掉 7 处 any
- 补充注释说明为何用 useFetch 而非 useRequestFetch(匿名只读页无需转
  Cookie,与各列表页一致)

同时处理一个 nitpick:search.vue 与 SearchResult.vue 重复调用 usePageSeo,
且页面层那次漏传 siteInfo(后写覆盖先写,重复设置只造成「哪次生效」的歧义)。
按 sibling 惯例只保留组件内那次(它带 siteInfo,且标题能带回关键词)。

行为未变:回归实测「消防」总数 9、23 条详情链接;「测试」标书命中 2 条、
价格 0.01 与截止时间正常渲染、默认 Tab 正确落在标书(第一个非空类)。
eslint 对该文件从 7 个 warning 降到 0。
2026-09-29 05:01:44 +08:00

20 lines
764 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<SearchResult />
</template>
<script setup lang="ts">
/**
* 统一搜索结果页 /search?keywords=xxx
*
* 一套公共页服务全部 10 套模板(不走模板组件清单,见 issues/01 的决定 3)。
* 页面实现在 app/components/SearchResult.vue(Nuxt 自动导入)。
*
* 路由优先级:Nuxt 文件路由中静态段优先于动态段,故 /search 命中本文件,
* 不会被 app/pages/[slug].vue 抢走。
*
* SEO 由 SearchResult.vue 统一设置(标题带回关键词、带关键词时 noindex,follow)——
* 本文件不重复调用 usePageSeo:两次调用后写会覆盖先写,且页面层拿不到 siteInfo,
* 重复设置只会造成「哪次生效」的歧义。
*/
</script>