cfe0749aff
配合后端拆出独立的 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 套。
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-[1200px] mx-auto">
|
||
<div class="mb-8">
|
||
<NuxtLink :to="`/article${article?.navigationId ? '?navId=' + article.navigationId : ''}`" class="text-sm text-gray-500 hover:text-blue-600">← 返回新闻列表</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-blue-50 text-blue-600 rounded-full">
|
||
{{ article.categoryName }}
|
||
</span>
|
||
<span v-if="article.publishTime">发布时间:{{ 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-blue-600 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>
|