Files
hjc-web/server/utils/case.ts
T
gxwebsoft 2b69686795 feat(app): 添加多模板关于我们页面及相关路由和404页面
- 新增404页面,优化未找到页面体验,避免被搜索引擎索引
- 增加文件代理接口,隐藏真实文件服务器地址,支持文件请求代理
- 实现/article、/case、/product及/page动态路由兼容列表与详情展示
- 添加动态CMS页面兼容入口处理旧式路径,统一路由与SEO设置
- 新增模板1、模板7、模板2、模板3关于我们页面,实现多模板支持
- 模板增强支持CMS单页内容加载及SEO信息动态设置
- 配置环境变量及Git忽略文件规则辅助开发和构建环境管理
2026-09-08 12:13:44 +08:00

46 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { CaseItem } from '~/app/types'
/**
* 将 CMS 后端案例对象(字段:caseId / caseName / customer …)
* 映射为前端模板约定的 CaseItem(字段:id / title / clientName …)。
*
* 后端 cms-case 控制器返回的是 caseId / caseName / customer
* 而 website-template 的全部模板组件(template-01 ~ template-07)均按
* id / title / clientName 渲染,故在此统一做一次字段归一化,
* 避免 8 套模板各自散落做字段转换。
*/
export function normalizeCaseItem(raw: any): CaseItem {
if (!raw) return raw
return {
// 主键与标题
id: raw.caseId ?? raw.id,
title: raw.caseName ?? raw.title,
// 封面 / 摘要 / 正文
cover: raw.cover ?? '',
summary: raw.summary ?? raw.subtitle ?? '',
// 正文:部分 CMS 版本正文在 description,兜底回退(content 优先)
content: raw.content ?? raw.description ?? '',
// 分类
categoryId: raw.categoryId ?? null,
categoryName: raw.categoryName ?? '',
// 客户(后端字段名 customer)→ 前端 clientName
clientName: raw.customer ?? raw.clientName ?? '',
// 行业 / 项目时间(后端无 projectTime 字段,回退到创建时间)
industry: raw.industry ?? '',
projectTime: raw.projectTime ?? raw.createTime ?? '',
// 关联产品(后端 productUsed)作为标签兜底
tags: raw.productUsed ? [raw.productUsed] : (raw.tags ?? []),
// 排序 / 状态 / 浏览量
sortNumber: raw.sortNum ?? raw.sortNumber ?? 0,
status: raw.status,
views: raw.views ?? 0,
// 置顶 / 推荐(当前上游 cms-case 暂无此字段,透传以便后续版本自动生效;
// 前端 useRecommend 检测到该字段后会将案例区块自动切换为「推荐」过滤)
top: raw.top ?? 0,
recommend: raw.recommend ?? 0,
createTime: raw.createTime ?? '',
updateTime: raw.updateTime ?? ''
}
}