feat: 添加download路由用于展示文档信息
All checks were successful
deploy to server / build-and-deploy (push) Successful in 5m4s
All checks were successful
deploy to server / build-and-deploy (push) Successful in 5m4s
- 添加/download/documentID路由用于文档下载 - server端添加文档元数据获取与下载API - 将app中的types移至shared,与server共享
This commit is contained in:
2
shared/types/meilisearch/index.ts
Normal file
2
shared/types/meilisearch/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './meili-index';
|
||||
export * from './search-result';
|
||||
88
shared/types/meilisearch/meili-index.ts
Normal file
88
shared/types/meilisearch/meili-index.ts
Normal 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;
|
||||
42
shared/types/meilisearch/search-result.ts
Normal file
42
shared/types/meilisearch/search-result.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user