feat: 将搜索页面由Strapi迁移至Direcuts

- 路由页面相关源码修改
- 类型标注与组合式API
- 相关工具函数
This commit is contained in:
2025-10-24 16:18:26 +08:00
parent 05938550e6
commit f62c4a3987
11 changed files with 309 additions and 151 deletions

View File

@ -0,0 +1,2 @@
export * from './meili-index';
export * from './search-result';

View File

@ -0,0 +1,88 @@
/**
* 产品索引文档结构
*/
export interface MeiliProductIndex {
/** 唯一标识符 **/
id: number;
/** 产品名称 **/
name: string;
/** 产品简介 **/
summary: string;
/** 产品详情 **/
description: string;
/** 产品类型 **/
type: string;
}
/**
* 解决方案索引文档结构
*/
export interface MeiliSolutionIndex {
/** 唯一标识符 **/
id: number;
/** 解决方案标题 **/
title: string;
/** 解决方案摘要 **/
summary: string;
/** 解决方案内容 **/
content: string;
/** 解决方案类型 **/
type: string;
}
/**
* 相关问题索引文档结构
*/
export interface MeiliQuestionIndex {
/** 唯一标识符 **/
id: number;
/** 问题标题 **/
title: string;
/** 问题内容 **/
content: string;
/** 相关产品 **/
products: string[];
/** 相关产品类型 **/
product_types: string[];
}
/**
* 相关文档索引文档结构
*/
export interface MeiliProductDocumentIndex {
/** 唯一标识符 **/
id: number;
/** 文档标题 **/
title: string;
/** 相关产品 **/
products: string[];
/** 相关产品类型 **/
product_types: string[];
}
/**
* 索引名与类型映射
*/
export interface MeiliIndexMap {
products: MeiliProductIndex;
solutions: MeiliSolutionIndex;
questions: MeiliQuestionIndex;
product_documents: MeiliProductDocumentIndex;
}
export type MeiliSearchItemType = keyof MeiliIndexMap;

View File

@ -0,0 +1,42 @@
import type { SearchResponse } from 'meilisearch';
/**
* 原始搜索分段结果
* @template T 索引类型
*/
export interface RawSearchSection<T> {
/** 索引名 **/
indexUid: string;
/** 响应数据 **/
response: SearchResponse<T>;
}
/**
* 搜索结果
*/
export interface SearchHit extends Record<string, unknown> {
objectID?: string | number;
}
/**
* 搜索分段结果
* @template T 索引类型
*/
export interface SearchSection<T> {
/** 索引名 **/
indexUid: string;
/** 原始索引名 **/
rawIndex: MeiliSearchItemType;
/** 命中条目 **/
hits: T[];
// hits: SearchHit[];
/** 条目总数 **/
estimatedTotalHits: number;
/** 处理时间 **/
processingTimeMs: number;
}