feat(cms): 案例/文章列表与详情改读 publishTime

配合后端拆出独立的 publish_time 列(见 ADR 0016)。

- 案例列表/详情、文章列表/详情统一取 publishTime,不再回退 createTime
  (createTime 是系统记录时间,运营没设过,展示它等于显示错误值)
- 案例详情页标签由「项目时间」更正为「发布时间」,并补 dayjs 格式化
  (原先直出 2026-09-23 19:06:37 完整时间戳)
- server/utils/case.ts 废弃 projectTime,改为输出 publishTime
- CaseItem 类型同步

仅改 template-07:其余 9 套模板的 CaseDetail 仍读已废弃的 projectTime,
因 CaseItem 带索引签名不会报编译错误,只会在换模板时静默显示创建时间。
该技术债已记入 docs/adr/0016 的「后果」一节,换模板前须先补这 9 套。
This commit is contained in:
2026-09-29 03:36:04 +08:00
parent 8e9969d516
commit cfe0749aff
6 changed files with 16 additions and 7 deletions
@@ -12,7 +12,7 @@
<span v-if="caseItem.clientName" class="px-3 py-1 bg-blue-50 text-blue-600 rounded-full">
{{ caseItem.clientName }}
</span>
<span v-if="caseItem.projectTime">项目时间:{{ caseItem.projectTime }}</span>
<span v-if="caseItem.publishTime">发布时间:{{ formatDate(caseItem.publishTime) }}</span>
<span v-if="caseItem.categoryName">行业:{{ caseItem.categoryName }}</span>
</div>
@@ -41,6 +41,7 @@
</template>
<script setup lang="ts">
import dayjs from 'dayjs'
import type { CaseItem } from '~/types'
/**
@@ -53,4 +54,9 @@ const { fileUrl } = useFileUrl()
const { data: caseItem } = await useFetch<CaseItem | null>(`/api/case/detail?id=${id}`, {
key: `case-${id}`
})
function formatDate(date?: string) {
if (!date) return ''
return dayjs(date).format('YYYY-MM-DD')
}
</script>
+1 -1
View File
@@ -17,7 +17,7 @@
<NuxtLink :to="`/case/${item.id}`" class="block py-4 group">
<div class="flex items-baseline gap-4">
<span class="shrink-0 text-xs text-gray-400 tabular-nums">
{{ formatDate(item.projectTime || item.createTime) }}
{{ formatDate(item.publishTime) }}
</span>
<h2 class="flex-1 min-w-0 text-base text-gray-900 truncate group-hover:text-blue-600 transition-colors">
{{ item.title }}
@@ -14,7 +14,7 @@
<span v-if="article.categoryName" class="px-3 py-1 bg-blue-50 text-blue-600 rounded-full">
{{ article.categoryName }}
</span>
<span>发布时间:{{ formatDate(article.publishTime || article.createTime) }}</span>
<span v-if="article.publishTime">发布时间:{{ formatDate(article.publishTime) }}</span>
<span v-if="article.author">作者:{{ article.author }}</span>
</div>
+1 -1
View File
@@ -22,7 +22,7 @@
class="flex items-baseline gap-4 py-4 group"
>
<span class="shrink-0 text-xs text-gray-400 tabular-nums">
{{ formatDate(item.publishTime || item.createTime) }}
{{ formatDate(item.publishTime) }}
</span>
<span class="flex-1 min-w-0 text-base text-gray-900 truncate group-hover:text-blue-600 transition-colors">
{{ item.title }}
+3 -1
View File
@@ -417,7 +417,8 @@ export interface CaseItem {
categoryId?: number
categoryName?: string
clientName?: string
projectTime?: string
/** 发布时间:运营可见的对外时间,列表与详情展示、排序的锚点 */
publishTime?: string
tags?: string[]
sortNumber?: number
status?: number
@@ -425,6 +426,7 @@ export interface CaseItem {
top?: number
/** 推荐标识:1=推荐(当前上游 cms-case 表暂无此字段,预留以便后续版本自动生效) */
recommend?: number
/** 创建时间:系统记录时间,官网不展示 */
createTime?: string
updateTime?: string
[key: string]: unknown
+3 -2
View File
@@ -26,9 +26,10 @@ export function normalizeCaseItem(raw: any): CaseItem {
categoryName: raw.categoryName ?? '',
// 客户(后端字段名 customer)→ 前端 clientName
clientName: raw.customer ?? raw.clientName ?? '',
// 行业 / 项目时间(后端无 projectTime 字段,回退到创建时间)
industry: raw.industry ?? '',
projectTime: raw.projectTime ?? raw.createTime ?? '',
// 发布时间:运营可见的对外时间,官网展示与排序的锚点(后端 cms_case.publish_time)。
// 不再回退 createTime——那是系统记录时间,运营没设过,展示它等于显示错误值。
publishTime: raw.publishTime ?? '',
// 关联产品(后端 productUsed)作为标签兜底
tags: raw.productUsed ? [raw.productUsed] : (raw.tags ?? []),
// 排序 / 状态 / 浏览量