feat(app): 添加多模板关于我们页面及相关路由和404页面

- 新增404页面,优化未找到页面体验,避免被搜索引擎索引
- 增加文件代理接口,隐藏真实文件服务器地址,支持文件请求代理
- 实现/article、/case、/product及/page动态路由兼容列表与详情展示
- 添加动态CMS页面兼容入口处理旧式路径,统一路由与SEO设置
- 新增模板1、模板7、模板2、模板3关于我们页面,实现多模板支持
- 模板增强支持CMS单页内容加载及SEO信息动态设置
- 配置环境变量及Git忽略文件规则辅助开发和构建环境管理
This commit is contained in:
2026-09-08 12:13:44 +08:00
commit 2b69686795
381 changed files with 59891 additions and 0 deletions
@@ -0,0 +1,90 @@
<template>
<footer class="bg-[var(--t8-footer-bg)] border-t border-white/10 py-10">
<div class="container mx-auto px-4">
<div class="flex flex-col md:flex-row md:items-start md:justify-between gap-8">
<!-- 品牌 -->
<div class="max-w-xs">
<SiteBrand
link-class="mb-2"
:logo="siteLogo"
:icon="siteIcon"
:name="siteName"
logo-class="h-8 w-auto max-w-[180px] object-contain"
icon-class="h-6 w-auto object-contain"
name-class="font-bold text-[var(--t8-primary)] text-lg"
/>
<p v-if="slogan" class="text-sm text-gray-400 mb-2">{{ slogan }}</p>
<p class="text-sm text-gray-400 leading-relaxed">{{ siteInfo?.comments || '专注企业数字化官网建设,提供品牌展示与业务增长一体化解决方案。' }}</p>
</div>
<!-- 快速链接 -->
<nav class="flex flex-col gap-2">
<div class="text-sm font-semibold text-[var(--t8-primary-light)] mb-1">快速链接</div>
<NuxtLink
v-for="link in quickLinks"
:key="link.navigationId || link.path"
:to="getNavLink(link)"
:target="link.target === '_blank' ? '_blank' : undefined"
class="text-sm text-gray-300 hover:text-[var(--t8-primary-light)] transition-colors"
>
{{ link.title }}
</NuxtLink>
</nav>
<!-- 联系方式 -->
<div class="flex flex-col gap-1 text-sm text-gray-300">
<div class="font-semibold text-[var(--t8-primary-light)] mb-1">联系我们</div>
<span v-if="phone">电话{{ phone }}</span>
<span v-if="email">邮箱{{ email }}</span>
<span v-if="address">地址{{ address }}</span>
<span v-if="officialWebsite">官网:<a :href="officialWebsiteUrl" target="_blank" rel="nofollow" class="hover:text-[var(--t8-primary)] transition-colors">{{ officialWebsite }}</a></span>
</div>
<!-- 关注我们 -->
<div v-if="wxQrcode || socialLinks.length" class="flex flex-col gap-2">
<div class="font-semibold text-[var(--t8-primary-light)] mb-1">关注我们</div>
<img v-if="wxQrcode" :src="wxQrcode" alt="微信二维码" class="w-28 h-28 object-contain border border-white/10 rounded-lg">
<p v-if="wxQrcode" class="text-xs text-gray-400">{{ siteConfig?.wxQrcodeText || '扫码关注' }}</p>
<a
v-for="link in socialLinks"
:key="link.url"
:href="link.url"
target="_blank"
rel="nofollow"
class="text-sm text-gray-300 hover:text-[var(--t8-primary-light)] transition-colors"
>{{ link.name || link.type }}</a>
</div>
</div>
<div class="mt-8 pt-6 border-t border-white/10 flex flex-wrap items-center justify-between gap-2 text-xs text-gray-400">
<span>{{ copyright || '© ' + new Date().getFullYear() + ' ' + (siteName || '企业官网') }}</span>
<div class="flex items-center gap-3">
<span v-if="icpNo">{{ icpNo }}</span>
<span v-if="siteInfo?.policeNo">{{ siteInfo.policeNo }}</span>
<a
rel="nofollow"
href="https://site.websoft.top"
target="_blank"
class="hover:text-[var(--t8-primary-light)] transition-colors"
>Powered by ·企业官网</a>
</div>
</div>
</div>
</footer>
</template>
<script setup lang="ts">
/**
* 模板 8 - Footer 组件(金棕企业风,深金棕底 + 浅字)
* 使用 config 与 useSite 的 bottomNavigationstop!==1 的页脚链接)渲染
*/
import type { CmsNavigation } from '~/types'
const { siteInfo, siteName, siteLogo, siteIcon, siteConfig, bottomNavigations, phone, email, address, copyright, wxQrcode, icpNo, slogan, officialWebsite, officialWebsiteUrl, socialLinks } = useSite()
/** 快速链接:取顶级导航中非首页且无子菜单的项 */
const quickLinks = computed<CmsNavigation[]>(() => {
const navs = bottomNavigations.value || []
return navs.filter((nav) => nav.model !== 'index').slice(0, 6)
})
</script>
@@ -0,0 +1,158 @@
<template>
<header class="sticky top-0 z-50">
<!-- 上层白底 Logo + 移动端菜单按钮 / 服务热线 -->
<div class="bg-white border-b border-[var(--t8-border)]">
<div class="container mx-auto px-4 h-24 flex items-center justify-between">
<SiteBrand
link-class="min-w-0 shrink"
:logo="siteLogo"
:icon="siteIcon"
:name="siteName"
logo-class="h-10 w-auto max-w-[70vw] object-contain sm:h-14 sm:max-w-[220px] lg:h-[82px] lg:max-w-[420px]"
icon-class="h-8 w-auto object-contain"
name-class="font-bold text-[var(--t8-primary)] truncate max-w-[200px]"
/>
<div class="flex items-center gap-2">
<!-- 服务热线桌面端显示 -->
<div class="hidden sm:flex items-center gap-2 text-[var(--t8-text)]">
<span class="w-9 h-9 rounded-full bg-[var(--t8-primary-soft)] flex items-center justify-center flex-shrink-0">
<svg class="w-5 h-5 text-[var(--t8-primary)]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />
</svg>
</span>
<div class="leading-tight">
<div class="text-xs text-[var(--t8-text-secondary)]">服务热线</div>
<div class="font-semibold text-[var(--t8-primary)]">{{ phone || '400-000-0000' }}</div>
</div>
</div>
<!-- 移动端菜单按钮放在上层右侧 logo 同高居中 -->
<button
class="md:hidden p-2 rounded-lg hover:bg-gray-100 flex items-center"
@click="mobileMenuOpen = !mobileMenuOpen"
>
<svg v-if="!mobileMenuOpen" class="w-6 h-6 text-[var(--t8-text)]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg>
<svg v-else class="w-6 h-6 text-[var(--t8-text)]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
</div>
</div>
<!-- 下层金棕渐变导航条移动端隐藏 -->
<div :style="{ backgroundImage: 'var(--t8-navbar-bg)' }" class="hidden md:block">
<div class="container mx-auto px-4 flex items-center justify-between h-14">
<!-- 桌面端导航居左 -->
<nav class="hidden md:flex items-center gap-3">
<template v-for="item in navItems" :key="item.navigationId || item.path">
<!-- 有子菜单 -->
<div v-if="item.children && item.children.length > 0" class="relative group h-full flex items-center">
<button
class="relative h-full px-5 text-white/90 hover:text-white hover:bg-white/5 transition-colors flex items-center gap-1 text-lg font-medium
after:absolute after:bottom-0 after:left-1/2 after:-translate-x-1/2 after:h-[2px] after:w-0 after:bg-[var(--t8-accent)] after:transition-all after:duration-200 group-hover:after:w-[70%]"
>
{{ item.title }}
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
<div class="absolute left-0 top-full pt-1 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all">
<div class="bg-white rounded-lg shadow-lg border border-[var(--t8-border)] py-2 min-w-[160px]">
<NuxtLink
v-for="child in item.children"
:key="child.navigationId"
:to="getChildPath(child)"
class="block px-4 py-2 text-[15px] text-[var(--t8-text)] hover:text-[var(--t8-primary)] hover:bg-[var(--t8-primary-soft)] transition-colors whitespace-nowrap"
>
{{ child.title }}
</NuxtLink>
</div>
</div>
</div>
<!-- 无子菜单 -->
<NuxtLink
v-else
:to="getNavLink(item)"
:target="item.target === '_blank' ? '_blank' : undefined"
class="relative h-full px-5 flex items-center text-white/90 hover:text-white hover:bg-white/5 transition-colors text-lg font-medium
after:absolute after:bottom-0 after:left-1/2 after:-translate-x-1/2 after:h-[2px] after:w-0 after:bg-[var(--t8-accent)] after:transition-all after:duration-200 hover:after:w-[70%]"
active-class="!text-white bg-white/15"
>
{{ item.title }}
</NuxtLink>
</template>
</nav>
<!-- 搜索框后台 setting.searchBtn 控制是否显示 -->
<SiteSearchBox
v-if="showHeaderSearch"
variant="light"
accent="var(--t8-primary)"
placeholder="请输入关键词..."
class="hidden md:flex items-center"
/>
</div>
</div>
<!-- 移动端菜单 -->
<div
v-if="mobileMenuOpen"
class="md:hidden bg-white border-t border-[var(--t8-border)]"
>
<div class="container mx-auto px-4 py-4 space-y-1">
<template v-for="item in navItems" :key="item.navigationId || item.path">
<div v-if="item.children && item.children.length > 0">
<div class="px-4 py-3 text-base font-semibold text-[var(--t8-primary)]">
{{ item.title }}
</div>
<NuxtLink
v-for="child in item.children"
:key="child.navigationId"
:to="getChildPath(child)"
class="block px-8 py-2 text-sm text-[var(--t8-text-secondary)] hover:text-[var(--t8-primary)] hover:bg-[var(--t8-primary-soft)] rounded-lg transition-colors"
@click="mobileMenuOpen = false"
>
{{ child.title }}
</NuxtLink>
</div>
<NuxtLink
v-else
:to="getNavLink(item)"
:target="item.target === '_blank' ? '_blank' : undefined"
class="block px-4 py-3 text-base font-medium text-[var(--t8-text)] hover:text-[var(--t8-primary)] hover:bg-[var(--t8-primary-soft)] rounded-lg transition-colors"
active-class="text-[var(--t8-primary)] bg-[var(--t8-primary-soft)]"
@click="mobileMenuOpen = false"
>
{{ item.title }}
</NuxtLink>
</template>
</div>
</div>
</header>
</template>
<script setup lang="ts">
/**
* 模板 8 - Header 组件(金棕企业风,对齐 gxhrtc 截图)
* 双层结构:上层白底(Logo + 服务热线),下层金棕渐变导航条(菜单居左 + 搜索居右)
*/
import type { CmsNavigation } from '~/types'
const { siteInfo, siteName, siteLogo, siteIcon, navigations, phone, showHeaderSearch, fetchSiteInfo } = useSite()
const mobileMenuOpen = ref(false)
/** 子导航链接统一走 app/utils 的 getNavLink */
function getChildPath(child: CmsNavigation): string {
return getNavLink(child)
}
// 获取站点信息(含导航数据)
await fetchSiteInfo()
/** 导航项(从 useSite 的 navigations 获取,已合并 topNavs + bottomNavs 并过滤 top===1 */
const navItems = computed<CmsNavigation[]>(() => {
return navigations.value || []
})
</script>
@@ -0,0 +1,195 @@
<template>
<section class="relative overflow-hidden group h-[280px] sm:h-[400px] lg:h-[600px]">
<!-- 底色金棕渐变兜底 -->
<div class="absolute inset-0" :style="{ backgroundImage: 'var(--t8-navbar-bg)' }"></div>
<!-- 轮播图模式 -->
<template v-if="bannerMode">
<div class="absolute inset-0">
<div
v-for="(b, i) in banners"
:key="b.id || i"
class="absolute inset-0 transition-opacity duration-1000 ease-in-out"
:class="i === currentBannerIndex ? 'opacity-100' : 'opacity-0 pointer-events-none'"
>
<a v-if="bannerLink(b)" :href="bannerLink(b)" target="_blank" rel="noopener" class="block w-full h-full">
<img :src="bannerImg(b)" :alt="b.title || siteName" class="w-full h-full object-cover">
</a>
<img v-else :src="bannerImg(b)" :alt="b.title || siteName" class="w-full h-full object-cover">
</div>
</div>
<div class="absolute inset-0 bg-black/35 pointer-events-none"></div>
</template>
<!-- 无图渐变兜底装饰 -->
<template v-else>
<div class="absolute -top-24 -left-16 w-80 h-80 rounded-full bg-white/15 blur-3xl"></div>
<div class="absolute -bottom-28 -right-10 w-96 h-96 rounded-full bg-black/10 blur-3xl"></div>
</template>
<!-- 文案叠加始终显示bannerMode 下取当前帧 title/subtitle否则用站点 slogan/comments -->
<div class="relative z-10 h-full container mx-auto px-4 flex flex-col items-center justify-center text-center text-white pointer-events-none">
<h1 :key="'h-' + currentBannerIndex" class="hero-fade text-3xl sm:text-4xl lg:text-6xl font-bold mb-4 sm:mb-5 tracking-wide drop-shadow-sm">{{ currentTitle }}</h1>
<p v-if="currentSubtitle" :key="'p-' + currentBannerIndex" class="hero-fade text-sm sm:text-base lg:text-xl max-w-2xl mb-6 sm:mb-8 text-white/90">{{ currentSubtitle }}</p>
<NuxtLink
:to="ctaLink"
class="inline-flex items-center justify-center px-8 py-3 bg-white text-[var(--t8-primary-dark)] text-sm sm:text-base font-semibold rounded-full hover:bg-[var(--t8-primary-soft)] transition-colors shadow-lg pointer-events-auto"
>
了解更多
<svg class="w-4 h-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</NuxtLink>
</div>
<!-- 左右箭头 -->
<button
v-if="bannerMode && banners.length > 1"
type="button" aria-label="上一张"
class="absolute left-3 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-black/30 hover:bg-black/50 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition z-20"
@click="prev"
>
<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" /></svg>
</button>
<button
v-if="bannerMode && banners.length > 1"
type="button" aria-label="下一张"
class="absolute right-3 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-black/30 hover:bg-black/50 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition z-20"
@click="next"
>
<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" /></svg>
</button>
<!-- 指示点 -->
<div v-if="bannerMode && banners.length > 1" class="absolute bottom-5 left-1/2 -translate-x-1/2 flex gap-2 z-20">
<button
v-for="(b, i) in banners"
:key="'dot-' + (b.id || i)"
type="button"
:aria-label="'切换到第 ' + (i + 1) + ' '"
class="w-2.5 h-2.5 rounded-full transition"
:class="i === currentBannerIndex ? 'bg-white scale-110' : 'bg-white/50 hover:bg-white/80'"
@click="goTo(i)"
/>
</div>
</section>
</template>
<script setup lang="ts">
/**
* 模板 8 - Hero 主视觉区(支持 CMS 轮播图)
*
* 双模式二选一:
* - 有轮播图(/api/banner 返回 ≥1 张):全宽铺满走马灯 + 遮罩 + 左右箭头/指示点 + 了解更多按钮;
* - 无轮播图:金棕渐变背景 + 居中大标题文案 + 了解更多按钮。
*/
import type { CmsNavigation, CmsBanner, ApiEnvelope, PageResult } from '~/types'
import { ensureFullUrl } from '~/utils/image'
import { getNavLink, getBannerLink } from '~/utils'
const { siteInfo, siteName, navigations, fetchSiteInfo } = useSite()
await fetchSiteInfo()
/** 轮播图数据(SSR 预取,首屏即有) */
const { data: bannerRes } = await useFetch<ApiEnvelope<PageResult<CmsBanner>> | PageResult<CmsBanner>>('/api/banner', {
query: { position: 'home_slider' }
})
const banners = computed<CmsBanner[]>(() => {
const d = bannerRes.value as (ApiEnvelope<PageResult<CmsBanner>> | PageResult<CmsBanner>) | null
if (!d) return []
const list = ((d as ApiEnvelope<PageResult<CmsBanner>>)?.data?.list
?? (d as PageResult<CmsBanner>)?.list
?? []) as CmsBanner[]
return list
.filter((b) => hasImage(b) && b.deleted !== 1 && b.status !== 2)
.sort((a, b) => (a.sortNum ?? 0) - (b.sortNum ?? 0))
})
/** 是否有轮播图:决定走全屏走马灯还是金棕渐变背景 */
const bannerMode = computed(() => banners.value.length > 0)
/** 当前帧索引 */
const currentBannerIndex = ref(0)
let bannerTimer: ReturnType<typeof setInterval> | null = null
function startAuto() {
if (banners.value.length > 1) {
bannerTimer = setInterval(() => {
currentBannerIndex.value = (currentBannerIndex.value + 1) % banners.value.length
}, 5000)
}
}
function stopAuto() {
if (bannerTimer) { clearInterval(bannerTimer); bannerTimer = null }
}
onMounted(() => { startAuto() })
onBeforeUnmount(() => { stopAuto() })
function prev() {
const n = banners.value.length
currentBannerIndex.value = (currentBannerIndex.value - 1 + n) % n
}
function next() {
const n = banners.value.length
currentBannerIndex.value = (currentBannerIndex.value + 1) % n
}
function goTo(i: number) {
currentBannerIndex.value = i
}
/** 取轮播图地址(兼容 image/imageUrl/pic/url,并提升 OSS 压缩宽度) */
function bannerImg(b: CmsBanner): string {
const raw = ensureFullUrl(b.image || b.imageUrl || b.pic || b.url || '')
return raw.replace(/resize,w_\d+/, 'resize,w_1920')
}
/** 取轮播图跳转链接(统一走 utils.getBannerLink,兼容 link/linkUrl/link_url 多字段名) */
function bannerLink(b: CmsBanner): string {
return getBannerLink(b)
}
/** 是否有可用图片 */
function hasImage(b: CmsBanner): boolean {
return !!(b.image || b.imageUrl || b.pic || b.url)
}
const heroTitle = computed(() => siteInfo.value?.slogan || siteName.value || '欢迎来到我们的官网')
const heroSubtitle = computed(() => siteInfo.value?.comments || '我们致力于为企业提供专业的数字化官网解决方案,从品牌展示到客户转化,全流程助力企业互联网营销。')
/** 当前帧(用于文案切换) */
const currentBanner = computed<CmsBanner | undefined>(() => banners.value[currentBannerIndex.value])
/** 当前帧文案:优先用 banner 自带的 title/subtitle,回退到站点 slogan/comments */
const currentTitle = computed(() => {
const bTitle = currentBanner.value?.title?.trim()
return bTitle || heroTitle.value
})
const currentSubtitle = computed(() => {
const bSubtitle = currentBanner.value?.subtitle?.trim()
return bSubtitle || heroSubtitle.value
})
const aboutNav = computed<CmsNavigation | undefined>(() => {
const navs = navigations.value || []
return navs.find((n) => n.model === 'page' && (n.title || '').includes('关于'))
|| navs.find((n) => n.model === 'page')
})
const ctaLink = computed(() => aboutNav.value ? (aboutNav.value.path || getNavLink(aboutNav.value)) : '/about')
</script>
<style scoped>
/* 轮播切换时文案淡入(:key 变化触发 remount,节点入场跑一次) */
.hero-fade {
animation: hero-fade-in 0.7s ease-out both;
}
@keyframes hero-fade-in {
from {
opacity: 0;
transform: translateY(8px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>