feat: directus视图与转换函数

- views: 用于前端渲染的视图模型
- mapper: 用于视图模型转换的转换函数
- utils: 相关工具函数
This commit is contained in:
2025-10-15 16:48:38 +08:00
parent de7c03a7a9
commit 98f978484c
9 changed files with 332 additions and 0 deletions

View File

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

View File

@ -0,0 +1,20 @@
/**
* 产品列表视图模型
* 用于产品列表(/products)渲染的数据结构
*/
export interface ProductListView {
/** 唯一标识符 **/
id: number;
/** 产品名称 **/
name: string;
/** 产品简介 **/
summary: string;
/** 产品类型 **/
product_type: string;
/** 产品封面(图片的id) **/
cover: 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,38 @@
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: QuestionView[];
/** 产品文档 **/
documents: ProductDocumentView[];
}

View File

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