refactor: 将Data到ViewModel的转换由App转移至Server端
All checks were successful
deploy to server / build-and-deploy (push) Successful in 3m15s

- 将逻辑转移到Server端后,简化前端逻辑
This commit is contained in:
2025-11-13 20:45:43 +08:00
parent e215a4d498
commit 23f2700c0f
70 changed files with 904 additions and 614 deletions

View File

@ -1,2 +1,3 @@
export * from './directus';
export * from './meilisearch';
export * from './views';

View File

@ -0,0 +1,10 @@
/**
* 公司简介视图模型
*/
export interface CompanyProfileView {
/** 唯一标识符 **/
id: number;
/** 内容 **/
content: string;
}

View File

@ -0,0 +1,10 @@
/**
* 联系信息视图模型
*/
export interface ContactInfoView {
/** 唯一标识符 **/
id: number;
/** 内容 **/
content: string;
}

View File

@ -0,0 +1,45 @@
/**
* 文档关联产品类型模型
* 用于在文档库中提供产品筛选功能
*/
export interface DocumentListProductType {
id: number;
name: string;
}
/**
* 文档关联产品模型
* 用于在文档库中提供产品筛选功能
*/
export interface DocumentListProduct {
id: number;
name: string;
type: DocumentListProductType;
}
/**
* 文档列表模型
* 用于文档库(/support/documents)页面渲染的数据结构
*/
export interface DocumentListView {
/** 唯一标识符 **/
id: number;
/** 文件UUID **/
fileId: string;
/** 文件名 **/
filename: string;
/** 文档标题 **/
title: string;
/** 文档大小 **/
size: number;
/** 文档链接 **/
url: string;
/** 相关产品 **/
products: DocumentListProduct[];
}

View File

@ -0,0 +1,50 @@
/**
* 主页推荐产品视图模型
*/
export interface HomepageProductView {
/** 唯一标识符 **/
id: number;
/** 产品名称 **/
name: string;
/** 产品简介 **/
summary: string;
/** 产品封面 **/
cover: string;
}
/**
* 主页推荐解决方案视图模型
*/
export interface HomepageSolutionView {
/** 唯一标识符 **/
id: number;
/** 解决方案标题 **/
title: string;
/** 解决方案摘要 **/
summary: string;
/** 解决方案封面 **/
cover: string;
}
/**
* 主页视图模型
*/
export interface HomepageView {
/** 唯一标识符 **/
id: number;
/** 首页图片 **/
carousel: string[];
/** 首页推荐产品 **/
recommendProducts: HomepageProductView[];
/** 首页推荐解决方案 **/
recommendSolutions: HomepageSolutionView[];
}

View File

@ -0,0 +1,13 @@
export * from './solution-view';
export * from './solution-list-view';
export * from './product-view';
export * from './product-list-view';
export * from './product-spec-group-view';
export * from './product-document-view';
export * from './product-question-view';
export * from './document-list-view';
export * from './question-list-view';
export * from './company-profile-view';
export * from './contact-info-view';
export * from './homepage-view';
export * from './search-item-view';

View File

@ -0,0 +1,23 @@
/**
* 文档视图模型
* 用于文档列表渲染的数据结构
*/
export interface ProductDocumentView {
/** 唯一标识符 **/
id: number;
/** 文件UUID **/
fileId: string;
/** 文件名 **/
filename: string;
/** 文档标题 **/
title: string;
/** 文档大小 **/
size: number;
/** 文档链接 **/
url: string;
}

View File

@ -0,0 +1,35 @@
/**
* 产品类型视图模型
* 用于产品列表页的section渲染与排序
*/
export interface ProductTypeView {
/** 唯一标识符 **/
id: number;
/** 类型名 **/
name: string;
/** 排序字段 **/
sort: number;
}
/**
* 产品列表视图模型
* 用于产品列表(/products)渲染的数据结构
*/
export interface ProductListView {
/** 唯一标识符 **/
id: number;
/** 产品名称 **/
name: string;
/** 产品简介 **/
summary: string;
/** 产品类型 **/
product_type: ProductTypeView;
/** 产品封面(图片的id) **/
cover: string;
}

View File

@ -0,0 +1,14 @@
/**
* 常见问题视图模型
* 用于产品页常见问题渲染的数据结构
*/
export interface ProductQuestionView {
/** 唯一标识符 **/
id: number;
/** 问题标题 **/
title: string;
/** 问题内容 **/
content: string;
}

View File

@ -0,0 +1,29 @@
/**
* 产品规格模型
* 用于产品规格渲染的数据结构
*/
export interface ProductSpecView {
/** 唯一标识符 **/
id: number;
/** 规格名称 **/
key: string;
/** 规格值 **/
value: string;
}
/**
* 产品规格表模型
* 用于产品规格表渲染的数据结构
*/
export interface ProductSpecGroupView {
/** 唯一标识符 **/
id: number;
/** 规格组名称 **/
name: string;
/** 规格组 **/
specs: ProductSpecView[];
}

View File

@ -0,0 +1,42 @@
import type { ProductSpecGroupView } from './product-spec-group-view';
import type { ProductQuestionView } from './product-question-view';
import type { ProductDocumentView } from './product-document-view';
interface ImageView {
id: number;
image: string;
caption: string;
}
/**
* 产品视图模型
* 用于产品详情页(/products/[slug])渲染的数据结构
*/
export interface ProductView {
/** 唯一标识符 **/
id: number;
/** 产品名称 **/
name: string;
/** 产品简介 **/
summary: string;
/** 产品类型 **/
product_type: string;
/** 产品图片 **/
images: ImageView[];
/** 产品详情 **/
description: string;
/** 产品规格 **/
specs: ProductSpecGroupView[];
/** 产品常见问题 **/
faqs: ProductQuestionView[];
/** 产品文档 **/
documents: ProductDocumentView[];
}

View File

@ -0,0 +1,36 @@
/**
* 问题关联产品类型模型
* 用于在常见问题列表中提供产品筛选功能
*/
export interface QuestionListProductType {
id: number;
name: string;
}
/**
* 问题关联产品模型
* 用于在常见问题列表中提供产品筛选功能
*/
export interface QuestionListProduct {
id: number;
name: string;
type: QuestionListProductType;
}
/**
* 常见问题列表视图模型
* 用于常见问题列表(/support/faq)页面渲染的数据结构
*/
export interface QuestionListView {
/** 唯一标识符 **/
id: number;
/** 问题标题 **/
title: string;
/** 问题内容 **/
content: string;
/** 关联产品 **/
products: QuestionListProduct[];
}

View File

@ -0,0 +1,13 @@
export interface SearchItemView {
/** 唯一标识符 **/
id: number | string;
/** 条目类型 **/
type: 'product' | 'solution' | 'question' | 'document';
/** 条目标题 **/
title: string;
/** 条目摘要 **/
summary: string;
}

View File

@ -0,0 +1,35 @@
/**
* 解决方案类型视图模型
* 用于解决方案列表页标签栏的渲染与排序
*/
export interface SolutionTypeView {
/** 唯一标识符 **/
id: number;
/** 类型名 **/
name: string;
/** 排序字段 **/
sort: number;
}
/**
* 解决方案列表模型
* 用于解决方案列表(/solutions)渲染的数据结构
*/
export interface SolutionListView {
/** 唯一标识符 **/
id: number;
/** 标题 **/
title: string;
/** 摘要 **/
summary: string;
/** 解决方案类型 **/
solution_type: SolutionTypeView;
/** 解决方案封面(图片id) **/
cover: string;
}

View File

@ -0,0 +1,20 @@
/**
* 解决方案模型
* 用于解决方案页(/solutions/[slug])渲染的数据结构
*/
export interface SolutionView {
/** 唯一标识符 **/
id: number;
/** 标题 **/
title: string;
/** 摘要 **/
summary: string;
/** 内容 **/
content: string;
/** 创建时间 **/
createAt: string;
}