d013e64500
上一提交只改了 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 中记录的该技术债 已标记为消除。
64 lines
2.2 KiB
Vue
64 lines
2.2 KiB
Vue
<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="article" class="max-w-4xl mx-auto">
|
||
<div class="mb-8">
|
||
<NuxtLink :to="`/article${article?.navigationId ? '?navId=' + article.navigationId : ''}`" class="text-sm text-gray-500 hover:text-[var(--t2-primary)]">← 返回新闻列表</NuxtLink>
|
||
</div>
|
||
|
||
<h1 class="text-3xl sm:text-4xl font-bold text-gray-900 mb-4">
|
||
{{ article.title }}
|
||
</h1>
|
||
|
||
<div class="flex flex-wrap items-center gap-4 text-sm text-gray-500 mb-8 pb-8 border-b border-gray-100">
|
||
<span v-if="article.categoryName" class="px-3 py-1 bg-[var(--t2-primary-light)] text-[var(--t2-primary)] rounded-full">
|
||
{{ article.categoryName }}
|
||
</span>
|
||
<span>发布时间:{{ formatDate(article.publishTime) }}</span>
|
||
<span v-if="article.author">作者:{{ article.author }}</span>
|
||
</div>
|
||
|
||
<div v-if="article.image || article.cover" class="aspect-video bg-gray-100 rounded-xl overflow-hidden mb-10">
|
||
<img
|
||
:src="fileUrl(article.image || article.cover)"
|
||
:alt="article.title"
|
||
class="w-full h-full object-cover"
|
||
>
|
||
</div>
|
||
|
||
<RichText :content="article.content" />
|
||
<PageAttachments
|
||
v-if="article?.files?.length"
|
||
:attachments="article.files"
|
||
/>
|
||
</div>
|
||
|
||
<div v-else class="text-center py-20">
|
||
<h1 class="text-2xl font-bold text-gray-900 mb-4">文章不存在或已下架</h1>
|
||
<NuxtLink :to="`/article${article?.navigationId ? '?navId=' + article.navigationId : ''}`" class="text-[var(--t2-primary)] hover:underline">返回新闻列表</NuxtLink>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import dayjs from 'dayjs'
|
||
import type { Article } from '~/types'
|
||
|
||
/**
|
||
* 模板 1 - 新闻详情页
|
||
*/
|
||
const route = useRoute()
|
||
const id = route.params.id as string
|
||
const { fileUrl } = useFileUrl()
|
||
|
||
const { data: article } = await useFetch<Article | null>(`/api/article/detail?id=${id}`, {
|
||
key: `article-${id}`
|
||
})
|
||
|
||
function formatDate(date?: string) {
|
||
if (!date) return ''
|
||
return dayjs(date).format('YYYY-MM-DD')
|
||
}
|
||
</script>
|