2b69686795
- 新增404页面,优化未找到页面体验,避免被搜索引擎索引 - 增加文件代理接口,隐藏真实文件服务器地址,支持文件请求代理 - 实现/article、/case、/product及/page动态路由兼容列表与详情展示 - 添加动态CMS页面兼容入口处理旧式路径,统一路由与SEO设置 - 新增模板1、模板7、模板2、模板3关于我们页面,实现多模板支持 - 模板增强支持CMS单页内容加载及SEO信息动态设置 - 配置环境变量及Git忽略文件规则辅助开发和构建环境管理
49 lines
2.5 KiB
Vue
49 lines
2.5 KiB
Vue
<template>
|
||
<div class="min-h-screen bg-white">
|
||
<div class="container mx-auto px-4 sm:px-6 lg:px-8 py-12">
|
||
<div v-if="article" class="max-w-4xl mx-auto">
|
||
<div class="mb-6"><NuxtLink :to="`/article${article?.navigationId ? '?navId=' + article.navigationId : ''}`" class="text-sm text-[#666666] hover:text-[#CF1313]">← 返回新闻列表</NuxtLink></div>
|
||
<h1 class="text-3xl sm:text-4xl font-bold text-[#1E2A47] mb-4">{{ article.title }}</h1>
|
||
<div class="flex flex-wrap items-center gap-4 text-sm text-[#666666] mb-8 pb-8 border-b border-[#E5E7EB]">
|
||
<span v-if="article.categoryName" class="px-3 py-1 bg-[#FDECEC] text-[#CF1313] rounded-full">{{ article.categoryName }}</span>
|
||
<span>发布时间:{{ formatDate(article.publishTime || article.createTime) }}</span>
|
||
<span v-if="article.author">作者:{{ article.author }}</span>
|
||
</div>
|
||
<div v-if="article.image || article.cover" class="rounded-2xl overflow-hidden mb-10 bg-[#F4F6FA] flex items-center justify-center">
|
||
<img :src="fileUrl(article.image || article.cover)" :alt="article.title" class="w-full max-h-[420px] object-contain">
|
||
</div>
|
||
<div class="cms-content">
|
||
<RichText :content="article.content" />
|
||
<PageAttachments
|
||
v-if="article?.files?.length"
|
||
:attachments="article.files"
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div v-else class="text-center py-20">
|
||
<h1 class="text-2xl font-bold text-[#1E2A47] mb-4">文章不存在或已下架</h1>
|
||
<NuxtLink :to="`/article${article?.navigationId ? '?navId=' + article.navigationId : ''}`" class="text-[#CF1313] hover:underline">返回新闻列表</NuxtLink>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import dayjs from 'dayjs'
|
||
import type { Article } from '~/types'
|
||
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>
|
||
|
||
<style scoped>
|
||
.cms-content :deep(h2),
|
||
.cms-content :deep(h3),
|
||
.cms-content :deep(h4) { color: #1E2A47; margin-top: 1.5em; margin-bottom: .75em; }
|
||
.cms-content :deep(p) { color: #333333; line-height: 1.85; margin-bottom: 1em; }
|
||
.cms-content :deep(a) { color: #CF1313; }
|
||
.cms-content :deep(img) { border-radius: 12px; }
|
||
</style>
|