Files
hjc-web/app/templates/template-05/pages/CaseDetail.vue
T
weicw-dshsa d013e64500 fix(cms): 其余 9 套模板一并改读 publishTime,消除静默失效隐患
上一提交只改了 template-07(当时 cms_website.template_id = 7),其余模板
仍读已废弃的 projectTime、文章页仍写 publishTime || createTime。
由于 CaseItem 带索引签名,这些引用不报编译错误,只在换模板时静默显示
系统创建时间——而 template_id 是数据库里可随时改的数字,改它不需发版。

本次补全全部模板:
- template-01..10 的 CaseDetail 改读 publishTime,标签更正为「发布时间」
- 其中 8 套原先没有 formatDate,一并补 dayjs 导入与格式化
  (此前直出 2026-09-23 19:06:37 完整时间戳)
- 文章侧 38 处 publishTime || createTime 统一为 publishTime
- useModuleRoute 的 SEO datePublished 不再回退 createTime
  (结构化数据应与页面展示的发布时间一致)

保留 server/api/sitemap.xml.ts 的 lastmod 回退链——那是抓取提示不是页面
展示,回退到创建时间是合理的保守行为。

现在官网上已不存在读取 createTime 的内容页。ADR 0016 中记录的该技术债
已标记为消除。
2026-09-29 03:50:58 +08:00

63 lines
2.3 KiB
Vue
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.
<template>
<div class="min-h-screen py-16 bg-white">
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
<div v-if="caseItem" class="max-w-4xl mx-auto">
<div class="mb-8">
<NuxtLink :to="`/case${caseItem?.navigationId ? '?navId=' + caseItem.navigationId : ''}`" class="text-sm text-[#8A7B6B] hover:text-[#E5472E]">← 返回案例列表</NuxtLink>
</div>
<h1 class="text-3xl sm:text-4xl font-bold text-[#33291F] mb-4">{{ caseItem.title }}</h1>
<div class="flex flex-wrap items-center gap-4 text-sm text-[#8A7B6B] mb-8 pb-8 border-b border-[#F0E2D5]">
<span v-if="caseItem.clientName" class="px-3 py-1 bg-[#FFF1E6] text-[#E5472E] rounded-full">
{{ caseItem.clientName }}
</span>
<span v-if="caseItem.publishTime">发布时间:{{ formatDate(caseItem.publishTime) }}</span>
<span v-if="caseItem.categoryName">行业:{{ caseItem.categoryName }}</span>
</div>
<div class="aspect-video bg-[#FFF1E6] rounded-3xl overflow-hidden mb-10 flex items-center justify-center">
<img
v-if="caseItem.cover"
:src="fileUrl(caseItem.cover)"
:alt="caseItem.title"
class="w-full h-full object-contain"
>
</div>
<p v-if="caseItem.summary" class="text-lg text-[#8A7B6B] mb-8 leading-relaxed">
{{ caseItem.summary }}
</p>
<RichText :content="caseItem.content" />
</div>
<div v-else class="text-center py-20">
<h1 class="text-2xl font-bold text-[#33291F] mb-4">案例不存在或已下架</h1>
<NuxtLink :to="`/case${caseItem?.navigationId ? '?navId=' + caseItem.navigationId : ''}`" class="text-[#E5472E] hover:underline">返回案例列表</NuxtLink>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import dayjs from 'dayjs'
import type { CaseItem } from '~/types'
/**
* 模板 5 - 案例详情页(温暖自然食品风)
*/
const route = useRoute()
const id = route.params.id as string
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>