fix: 修正搜索页路由跳转逻辑 #50
@ -124,6 +124,10 @@
|
||||
return localePath({ path: `/solutions/${slug}` });
|
||||
}
|
||||
|
||||
if (item.type === 'document') {
|
||||
return localePath({ path: `/download/${slug}` });
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
@ -63,10 +63,11 @@ describe('converters', () => {
|
||||
title: 'User Manual',
|
||||
products: ['Product A'],
|
||||
product_types: ['Type A'],
|
||||
fileUUID: 'TEST-UUID',
|
||||
};
|
||||
const result = converters.product_documents(item);
|
||||
expect(result).toEqual({
|
||||
id: 1,
|
||||
id: 'TEST-UUID',
|
||||
title: 'User Manual',
|
||||
summary: undefined,
|
||||
type: 'document',
|
||||
|
||||
@ -28,7 +28,7 @@ export const converters: {
|
||||
product_documents: (
|
||||
item: MeiliIndexMap['product_documents']
|
||||
): SearchItemView => ({
|
||||
id: item.id,
|
||||
id: item.fileUUID || item.id,
|
||||
type: 'document',
|
||||
title: item.title,
|
||||
}),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
export interface SearchItemView {
|
||||
/** 唯一标识符 **/
|
||||
id: number;
|
||||
id: number | string;
|
||||
|
||||
/** 条目类型 **/
|
||||
type: 'product' | 'solution' | 'question' | 'document';
|
||||
|
||||
@ -73,6 +73,9 @@ export interface MeiliProductDocumentIndex {
|
||||
|
||||
/** 相关产品类型 **/
|
||||
product_types: string[];
|
||||
|
||||
/** 文件UUID **/
|
||||
fileUUID: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import type { SearchResponse } from 'meilisearch';
|
||||
import type { MeiliSearchItemType } from './meili-index';
|
||||
|
||||
/**
|
||||
* 原始搜索分段结果
|
||||
|
||||
Reference in New Issue
Block a user