feat(app): 添加多模板关于我们页面及相关路由和404页面
- 新增404页面,优化未找到页面体验,避免被搜索引擎索引 - 增加文件代理接口,隐藏真实文件服务器地址,支持文件请求代理 - 实现/article、/case、/product及/page动态路由兼容列表与详情展示 - 添加动态CMS页面兼容入口处理旧式路径,统一路由与SEO设置 - 新增模板1、模板7、模板2、模板3关于我们页面,实现多模板支持 - 模板增强支持CMS单页内容加载及SEO信息动态设置 - 配置环境变量及Git忽略文件规则辅助开发和构建环境管理
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<section v-if="enabled" class="py-16 lg:py-20 bg-[#0f0f0f]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="text-center mb-12">
|
||||
<h2 class="text-2xl sm:text-3xl font-bold text-white mb-4" data-reveal>
|
||||
{{ title }}
|
||||
</h2>
|
||||
<div class="w-16 h-1 bg-[#d4af37] mx-auto mb-4" data-reveal data-reveal-delay="100" />
|
||||
<p v-if="subtitle" class="text-[#a0a0a0] max-w-2xl mx-auto" data-reveal data-reveal-delay="200">
|
||||
{{ subtitle }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid sm:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
<div
|
||||
v-for="(item, index) in items"
|
||||
:key="item.title || index"
|
||||
class="bg-[#1a1a1a] border border-[#333] rounded-xl p-6 hover:border-[#d4af37]/50 transition-all duration-300 anim-card group"
|
||||
data-reveal
|
||||
:data-reveal-delay="index * 100"
|
||||
>
|
||||
<div
|
||||
class="w-12 h-12 rounded-lg bg-[#d4af37]/10 flex items-center justify-center mb-4 transition-transform duration-300 group-hover:scale-110"
|
||||
>
|
||||
<FeatureIcon :name="item.icon" class="w-6 h-6 text-[#d4af37]" />
|
||||
</div>
|
||||
<h3 class="text-lg font-semibold text-white mb-2">{{ item.title }}</h3>
|
||||
<p class="text-sm text-[#a0a0a0] leading-relaxed">{{ item.desc }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 模板 4 - 核心业务模块(黑金高端风,后台可配置)
|
||||
* 数据来自 useFeatures(),未配置时回退到人力资源行业默认数据。
|
||||
*/
|
||||
import FeatureIcon from '~/components/FeatureIcon.vue'
|
||||
import { useFeatures } from '~/composables/useFeatures'
|
||||
import type { FeatureItem } from '~/types'
|
||||
|
||||
const defaultFeatures: FeatureItem[] = [
|
||||
{ title: '人才招聘', desc: '覆盖蓝领、白领、高端人才全渠道招聘,精准匹配企业用工需求。', icon: 'users' },
|
||||
{ title: '劳务派遣', desc: '合规灵活的派遣方案,降低用工风险,提升组织弹性。', icon: 'user' },
|
||||
{ title: '人事外包', desc: '入离职、档案、考勤、薪酬全流程外包,让企业聚焦核心业务。', icon: 'document' },
|
||||
{ title: '薪酬社保', desc: '专业薪税筹划与社保代缴,确保合规准时,省心省力。', icon: 'money' }
|
||||
]
|
||||
|
||||
const { enabled, title, subtitle, items } = useFeatures(defaultFeatures)
|
||||
</script>
|
||||
@@ -0,0 +1,90 @@
|
||||
<template>
|
||||
<footer class="bg-[#1a1a1a] border-t border-[#333] 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-[#d4af37] 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-[#d4af37] 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-[#d4af37] transition-colors"
|
||||
>
|
||||
{{ link.title }}
|
||||
</NuxtLink>
|
||||
</nav>
|
||||
|
||||
<!-- 联系方式 -->
|
||||
<div class="flex flex-col gap-1 text-sm text-gray-300">
|
||||
<div class="font-semibold text-[#d4af37] 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-[#d4af37] transition-colors">{{ officialWebsite }}</a></span>
|
||||
</div>
|
||||
|
||||
<!-- 关注我们 -->
|
||||
<div v-if="wxQrcode || socialLinks.length" class="flex flex-col gap-2">
|
||||
<div class="font-semibold text-[#d4af37] mb-1">关注我们</div>
|
||||
<img v-if="wxQrcode" :src="wxQrcode" alt="微信二维码" class="w-28 h-28 object-contain border border-[#333] rounded-lg">
|
||||
<p v-if="wxQrcode" class="text-xs text-gray-500">{{ 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-[#d4af37] transition-colors"
|
||||
>{{ link.name || link.type }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-8 pt-6 border-t border-[#333] flex flex-wrap items-center justify-between gap-2 text-xs text-gray-500">
|
||||
<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-[#d4af37] transition-colors"
|
||||
>Powered by 云·企业官网</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 模板 4 - Footer 组件(深色高端风)
|
||||
* 使用 config 与 useSite 的 bottomNavigations(top!==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,147 @@
|
||||
<template>
|
||||
<header class="sticky top-0 z-50 bg-[#1a1a1a] border-b border-[#333]">
|
||||
<div class="container mx-auto px-4 h-16 flex items-center justify-between">
|
||||
<!-- Logo -->
|
||||
<SiteBrand
|
||||
link-class="flex-shrink-0"
|
||||
:logo="siteLogo"
|
||||
:icon="siteIcon"
|
||||
:name="siteName"
|
||||
logo-class="h-12 w-auto max-w-[200px] object-contain"
|
||||
icon-class="h-8 w-auto object-contain"
|
||||
name-class="font-bold text-[#d4af37] truncate max-w-[160px] sm:max-w-xs"
|
||||
/>
|
||||
|
||||
<!-- 搜索框(后台 setting.searchBtn 控制是否显示) -->
|
||||
<SiteSearchBox v-if="showHeaderSearch" variant="dark" accent="#d4af37" class="hidden lg:flex items-center ml-8 mr-auto" />
|
||||
|
||||
<!-- 桌面端导航 -->
|
||||
<nav class="hidden md:flex items-center gap-6 text-base">
|
||||
<template v-for="item in navItems" :key="item.navigationId || item.path">
|
||||
<!-- 有子菜单 -->
|
||||
<div v-if="item.children && item.children.length > 0" class="relative group">
|
||||
<button class="font-medium text-gray-200 hover:text-[#d4af37] transition-colors flex items-center gap-1">
|
||||
{{ 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-2 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all">
|
||||
<div class="bg-[#222] rounded-lg shadow-lg border border-[#333] 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-gray-200 hover:text-[#d4af37] hover:bg-[#333] transition-colors whitespace-nowrap"
|
||||
>
|
||||
{{ child.title }}
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 无子菜单 -->
|
||||
<NuxtLink
|
||||
v-else
|
||||
:to="getNavLink(item)"
|
||||
:target="item.target === '_blank' ? '_blank' : undefined"
|
||||
class="font-medium text-gray-200 hover:text-[#d4af37] transition-colors"
|
||||
active-class="text-[#d4af37]"
|
||||
>
|
||||
{{ item.title }}
|
||||
</NuxtLink>
|
||||
</template>
|
||||
</nav>
|
||||
|
||||
<!-- CTA -->
|
||||
<div class="hidden md:block ml-6">
|
||||
<NuxtLink
|
||||
to="/contact"
|
||||
class="inline-flex items-center justify-center px-4 py-2 bg-[#d4af37] text-[#1a1a1a] text-base font-semibold rounded-full hover:bg-[#e6c35a] transition-colors"
|
||||
>
|
||||
在线咨询
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- 移动端菜单按钮 -->
|
||||
<button
|
||||
class="md:hidden p-2 rounded-lg hover:bg-[#333]"
|
||||
@click="mobileMenuOpen = !mobileMenuOpen"
|
||||
>
|
||||
<svg v-if="!mobileMenuOpen" class="w-6 h-6 text-[#d4af37]" 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-[#d4af37]" 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
|
||||
v-if="mobileMenuOpen"
|
||||
class="md:hidden bg-[#1a1a1a] border-t border-[#333]"
|
||||
>
|
||||
<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-[#d4af37]">
|
||||
{{ 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-gray-300 hover:text-[#d4af37] hover:bg-[#333] 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-gray-200 hover:text-[#d4af37] hover:bg-[#333] rounded-lg transition-colors"
|
||||
active-class="text-[#d4af37] bg-[#333]"
|
||||
@click="mobileMenuOpen = false"
|
||||
>
|
||||
{{ item.title }}
|
||||
</NuxtLink>
|
||||
</template>
|
||||
<NuxtLink
|
||||
to="/contact"
|
||||
class="block px-4 py-3 mt-2 text-center bg-[#d4af37] text-[#1a1a1a] font-semibold rounded-lg hover:bg-[#e6c35a] transition-colors"
|
||||
@click="mobileMenuOpen = false"
|
||||
>
|
||||
在线咨询
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 模板 4 - Header 组件(深色高端风)
|
||||
* 使用 useSite 的 navigations(合并 topNavs + bottomNavs,过滤 top===1)渲染导航菜单
|
||||
*/
|
||||
import type { CmsNavigation } from '~/types'
|
||||
|
||||
const { siteInfo, siteName, siteLogo, siteIcon, navigations, showHeaderSearch, fetchSiteInfo } = useSite()
|
||||
const mobileMenuOpen = ref(false)
|
||||
|
||||
/** 子导航链接统一走 app/utils 的 getNavLink(自动避免 /page/4598?navId=4598 冗余拼接) */
|
||||
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,270 @@
|
||||
<template>
|
||||
<section
|
||||
class="relative overflow-hidden"
|
||||
:class="bannerMode ? 'group text-white' : 'bg-[#0f0f0f] text-white'"
|
||||
>
|
||||
<!-- 模式 B:有轮播图 → 全宽轮播背景 + 文案叠加 -->
|
||||
<template v-if="bannerMode">
|
||||
<div class="relative w-full min-h-[520px] lg:min-h-[600px] flex items-center">
|
||||
<!-- 轮播图背景 -->
|
||||
<div class="absolute inset-0">
|
||||
<div
|
||||
v-for="(b, i) in banners"
|
||||
:key="b.id || i"
|
||||
class="absolute inset-0 w-full h-full transition-opacity duration-700 ease-in-out"
|
||||
:class="i === currentBannerIndex ? 'opacity-100 z-10' : 'opacity-0 z-0'"
|
||||
>
|
||||
<img
|
||||
:src="bannerImg(b)"
|
||||
:alt="b.title || ''"
|
||||
class="w-full h-full object-cover"
|
||||
>
|
||||
<!-- 黑色遮罩,保证文案可读 -->
|
||||
<div class="absolute inset-0 bg-gradient-to-r from-black/85 via-black/60 to-black/30" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 文案内容 -->
|
||||
<div class="relative z-20 w-full">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8 py-20 lg:py-28">
|
||||
<div class="max-w-2xl">
|
||||
<h1
|
||||
class="text-3xl sm:text-4xl lg:text-5xl font-bold leading-tight mb-6"
|
||||
data-reveal
|
||||
>
|
||||
{{ heroTitle }}
|
||||
</h1>
|
||||
<p
|
||||
class="text-base sm:text-lg text-gray-200 mb-8 leading-relaxed"
|
||||
data-reveal
|
||||
data-reveal-delay="100"
|
||||
>
|
||||
{{ heroSubtitle }}
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-4" data-reveal data-reveal-delay="200">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center px-6 py-3 bg-[#d4af37] text-[#1a1a1a] font-semibold rounded hover:bg-[#e6c35a] transition-colors"
|
||||
@click="openConsult()"
|
||||
>
|
||||
立即咨询
|
||||
</button>
|
||||
<NuxtLink
|
||||
v-if="newsNav"
|
||||
:to="newsNav.path || '/article'"
|
||||
class="inline-flex items-center justify-center px-6 py-3 border border-[#d4af37] text-[#d4af37] font-semibold rounded hover:bg-[#d4af37]/10 transition-colors"
|
||||
>
|
||||
了解更多
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 左右箭头 -->
|
||||
<button
|
||||
v-if="banners.length > 1"
|
||||
type="button"
|
||||
aria-label="上一张"
|
||||
class="absolute left-4 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-black/40 hover:bg-black/60 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition z-30"
|
||||
@click="prev"
|
||||
>
|
||||
<svg class="w-5 h-5" 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="banners.length > 1"
|
||||
type="button"
|
||||
aria-label="下一张"
|
||||
class="absolute right-4 top-1/2 -translate-y-1/2 w-10 h-10 rounded-full bg-black/40 hover:bg-black/60 text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition z-30"
|
||||
@click="next"
|
||||
>
|
||||
<svg class="w-5 h-5" 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="banners.length > 1"
|
||||
class="absolute bottom-6 left-1/2 -translate-x-1/2 flex gap-2 z-30"
|
||||
>
|
||||
<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-[#d4af37] scale-110' : 'bg-white/50 hover:bg-white/80'"
|
||||
@click="goTo(i)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 模式 A:无轮播图 → 黑金背景 + 文案 + 右侧特性卡片 -->
|
||||
<template v-else>
|
||||
<!-- 装饰光晕 -->
|
||||
<div class="absolute top-0 right-0 w-[500px] h-[500px] bg-[#d4af37]/10 rounded-full blur-[120px] -translate-y-1/3 translate-x-1/4" />
|
||||
<div class="absolute bottom-0 left-0 w-[400px] h-[400px] bg-[#d4af37]/5 rounded-full blur-[100px] translate-y-1/3 -translate-x-1/4" />
|
||||
|
||||
<div class="relative z-10 container mx-auto px-4 sm:px-6 lg:px-8 py-20 lg:py-28">
|
||||
<div class="grid lg:grid-cols-2 gap-12 lg:gap-16 items-center">
|
||||
<!-- 左侧文案 -->
|
||||
<div class="max-w-2xl">
|
||||
<div class="inline-flex items-center gap-2 px-3 py-1 rounded-full border border-[#d4af37]/30 bg-[#d4af37]/10 text-[#d4af37] text-sm mb-6" data-reveal>
|
||||
<span class="w-1.5 h-1.5 rounded-full bg-[#d4af37]" />
|
||||
专业 · 高效 · 可信赖
|
||||
</div>
|
||||
<h1 class="text-3xl sm:text-4xl lg:text-5xl font-bold leading-tight mb-6" data-reveal data-reveal-delay="100">
|
||||
{{ heroTitle }}
|
||||
</h1>
|
||||
<p class="text-base sm:text-lg text-gray-300 mb-8 leading-relaxed" data-reveal data-reveal-delay="200">
|
||||
{{ heroSubtitle }}
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-4" data-reveal data-reveal-delay="300">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center px-6 py-3 bg-[#d4af37] text-[#1a1a1a] font-semibold rounded hover:bg-[#e6c35a] transition-colors"
|
||||
@click="openConsult()"
|
||||
>
|
||||
立即咨询
|
||||
</button>
|
||||
<NuxtLink
|
||||
v-if="newsNav"
|
||||
:to="newsNav.path || '/article'"
|
||||
class="inline-flex items-center justify-center px-6 py-3 border border-[#d4af37] text-[#d4af37] font-semibold rounded hover:bg-[#d4af37]/10 transition-colors"
|
||||
>
|
||||
了解更多
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧特性卡片 -->
|
||||
<div class="grid sm:grid-cols-2 gap-4" data-reveal data-reveal-delay="400">
|
||||
<div
|
||||
v-for="(f, i) in displayFeatures"
|
||||
:key="i"
|
||||
class="bg-[#1a1a1a]/80 border border-[#333] rounded-lg p-5 hover:border-[#d4af37]/50 transition-colors"
|
||||
:data-reveal-delay="400 + i * 100"
|
||||
>
|
||||
<div class="w-10 h-10 rounded-lg bg-[#d4af37]/10 flex items-center justify-center mb-3">
|
||||
<svg class="w-5 h-5 text-[#d4af37]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
||||
</svg>
|
||||
</div>
|
||||
<p class="text-white font-medium">{{ f }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 模板 4 - Hero 主视觉区(黑金高端风)
|
||||
*
|
||||
* 双模式:
|
||||
* - 有轮播图(/api/banner 返回 ≥1 张):全宽轮播背景 + 文案叠加 + 左右箭头/指示点;
|
||||
* - 无轮播图:黑金背景 + 左侧文案/CTA + 右侧 4 个特性卡片。
|
||||
*/
|
||||
import type { CmsNavigation, CmsBanner, ApiEnvelope, PageResult } from '~/types'
|
||||
import { ensureFullUrl } from '~/utils/image'
|
||||
import { getBannerLink } from '~/utils'
|
||||
|
||||
const { siteInfo, siteName, navigations, fetchSiteInfo } = useSite()
|
||||
const { openConsult } = useConsult()
|
||||
|
||||
await fetchSiteInfo()
|
||||
|
||||
/** 轮播图数据 */
|
||||
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
|
||||
}
|
||||
|
||||
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')
|
||||
}
|
||||
|
||||
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(() => {
|
||||
return siteName.value ? `${siteName.value} · 让企业人才管理更简单` : '专业人力资源服务伙伴'
|
||||
})
|
||||
|
||||
const heroSubtitle = computed(() => {
|
||||
return siteInfo.value?.comments
|
||||
|| '提供人才招聘、劳务派遣、人事外包、薪酬社保等一站式人力资源解决方案,助力企业降本增效、专注核心业务。'
|
||||
})
|
||||
|
||||
const newsNav = computed<CmsNavigation | undefined>(() => {
|
||||
const navs = navigations.value || []
|
||||
return navs.find((n) => n.model === 'article')
|
||||
})
|
||||
|
||||
const defaultFeatures = [
|
||||
'人才招聘与配置',
|
||||
'劳务派遣外包',
|
||||
'薪酬社保代缴',
|
||||
'企业培训咨询'
|
||||
]
|
||||
|
||||
const { heroFeatures } = useFeatures()
|
||||
|
||||
const displayFeatures = computed<string[]>(() => {
|
||||
const cfg = heroFeatures.value
|
||||
if (cfg && cfg.length > 0) return cfg.slice(0, 4)
|
||||
return defaultFeatures
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { TemplateConfig } from '~/composables/useTemplate'
|
||||
|
||||
/**
|
||||
* 模板 4 配置
|
||||
* 黑金高端工业风格
|
||||
*/
|
||||
export default {
|
||||
id: 'template-04',
|
||||
name: '黑金高端模板',
|
||||
description: '黑金高端风格,适合工程、制造、高端服务类企业',
|
||||
preview: '/templates/cloud-website/template-04.png',
|
||||
supportedModules: ['home', 'products', 'cases', 'news', 'contact'],
|
||||
themeConfig: {
|
||||
primaryColor: '#d4af37',
|
||||
secondaryColor: '#1a1a1a',
|
||||
fontFamily: '"Noto Sans SC", "Source Han Sans SC", "思源黑体", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif'
|
||||
}
|
||||
} satisfies TemplateConfig
|
||||
@@ -0,0 +1,144 @@
|
||||
<template>
|
||||
<div class="bg-gray-50">
|
||||
<!-- 页头:科技蓝渐变色块 -->
|
||||
<section class="relative overflow-hidden bg-gradient-to-r from-blue-700 to-blue-500">
|
||||
<div class="absolute -top-20 -right-16 w-72 h-72 rounded-full bg-white/10 blur-3xl" />
|
||||
<div class="absolute -bottom-24 left-10 w-64 h-64 rounded-full bg-black/10 blur-3xl" />
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8 py-12 lg:py-16 relative z-10">
|
||||
<nav class="text-xs text-white/70 mb-3" aria-label="面包屑">
|
||||
<NuxtLink to="/" class="hover:text-white transition-colors">首页</NuxtLink>
|
||||
<span class="mx-2">/</span>
|
||||
<span class="text-white">{{ pageTitle }}</span>
|
||||
</nav>
|
||||
<h1 class="text-3xl sm:text-4xl font-bold text-white">{{ pageTitle }}</h1>
|
||||
<p v-if="subTitle" class="text-white/75 mt-3 max-w-2xl leading-relaxed line-clamp-2">
|
||||
{{ subTitle }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 正文 -->
|
||||
<section class="py-12 lg:py-16">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="max-w-5xl mx-auto">
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden">
|
||||
<!-- 单页配图(cms_page.image):作为正文顶部插图 -->
|
||||
<img
|
||||
v-if="coverImage"
|
||||
:src="coverImage"
|
||||
:alt="pageTitle"
|
||||
class="w-full h-56 sm:h-72 lg:h-80 object-cover"
|
||||
>
|
||||
|
||||
<div class="p-6 sm:p-10">
|
||||
<template v-if="hasContent">
|
||||
<div class="flex flex-wrap items-center gap-3 mb-6 pb-6 border-b border-gray-100">
|
||||
<span class="w-1.5 h-6 rounded-full bg-blue-600" />
|
||||
<h2 class="text-xl sm:text-2xl font-bold text-gray-900">{{ pageTitle }}</h2>
|
||||
<span v-if="updateTimeText" class="sm:ml-auto text-sm text-gray-500">
|
||||
更新于 {{ updateTimeText }}
|
||||
</span>
|
||||
</div>
|
||||
<RichText :content="pageData?.content" />
|
||||
<PageAttachments
|
||||
v-if="pageData?.attachments?.length"
|
||||
:attachments="pageData.attachments"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- 空态 / 错误态 -->
|
||||
<div v-else class="text-center py-16">
|
||||
<svg class="w-16 h-16 mx-auto text-gray-300 mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z" />
|
||||
</svg>
|
||||
<p class="text-gray-900 font-medium mb-2">{{ emptyState.title }}</p>
|
||||
<p class="text-gray-500 text-sm leading-relaxed mb-6">{{ emptyState.desc }}</p>
|
||||
<NuxtLink to="/" class="text-blue-600 hover:underline">返回首页</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底部 CTA -->
|
||||
<div class="mt-10 rounded-2xl border border-blue-100 bg-blue-50 p-8 sm:p-10 text-center">
|
||||
<h3 class="text-xl sm:text-2xl font-bold text-gray-900 mb-3">想进一步了解我们?</h3>
|
||||
<p class="text-gray-600 mb-6">欢迎来电咨询或在线留言,我们将安排专业顾问与您对接</p>
|
||||
<div class="flex flex-wrap items-center justify-center gap-4">
|
||||
<NuxtLink
|
||||
to="/contact"
|
||||
class="inline-flex items-center px-6 py-3 bg-blue-600 text-white font-semibold rounded-lg hover:bg-blue-700 transition-colors shadow-sm"
|
||||
>
|
||||
联系我们
|
||||
</NuxtLink>
|
||||
<a
|
||||
v-if="siteInfo?.phone"
|
||||
:href="`tel:${siteInfo.phone}`"
|
||||
class="inline-flex items-center px-6 py-3 border border-blue-600 text-blue-600 font-semibold rounded-lg hover:bg-blue-100 transition-colors"
|
||||
>
|
||||
{{ siteInfo.phone }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 模板 7 - 关于我们(科技蓝)
|
||||
*
|
||||
* 数据源:后台「单页管理」cms_page 表中 path=about 的记录。
|
||||
* 链路:useFetch('/api/page/detail', { path: 'about' })
|
||||
* → server/api/page/detail.get.ts 的 path 分支
|
||||
* → 上游 /cms/cms-page/getByPath/about(带 TenantId)
|
||||
*/
|
||||
import dayjs from 'dayjs'
|
||||
import type { PageDetail } from '~/types'
|
||||
|
||||
const { siteInfo, fetchSiteInfo } = useSite()
|
||||
const { fileUrl } = useFileUrl()
|
||||
|
||||
await fetchSiteInfo()
|
||||
|
||||
const { data: pageData } = await useFetch<PageDetail>('/api/page/detail', {
|
||||
key: 'page-about',
|
||||
query: { path: 'about' }
|
||||
})
|
||||
|
||||
const pageTitle = computed(() => pageData.value?.title?.trim() || '关于我们')
|
||||
const coverImage = computed(() => fileUrl(pageData.value?.photo || ''))
|
||||
const hasContent = computed(() => Boolean(pageData.value?.hasContent && pageData.value?.content))
|
||||
|
||||
const subTitle = computed(() => {
|
||||
const desc = pageData.value?.description?.trim()
|
||||
if (desc) return desc
|
||||
return (siteInfo.value?.comments || '').trim()
|
||||
})
|
||||
|
||||
const updateTimeText = computed(() => {
|
||||
const t = pageData.value?.updateTime
|
||||
return t ? dayjs(t).format('YYYY-MM-DD') : ''
|
||||
})
|
||||
|
||||
const emptyState = computed(() => {
|
||||
if (pageData.value?.status === 'error') {
|
||||
return { title: '内容暂时无法加载', desc: '内容接口暂时不可用,请稍后再试。' }
|
||||
}
|
||||
return {
|
||||
title: '内容尚未录入',
|
||||
desc: '请前往管理后台「单页管理」补充 path 为 about 的页面正文。'
|
||||
}
|
||||
})
|
||||
|
||||
usePageSeo(
|
||||
{
|
||||
title: pageTitle.value,
|
||||
path: '/about',
|
||||
keywords: pageData.value?.keywords || undefined,
|
||||
description: pageData.value?.description || undefined,
|
||||
image: coverImage.value || undefined
|
||||
},
|
||||
siteInfo.value
|
||||
)
|
||||
</script>
|
||||
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<div class="min-h-screen py-16 bg-[#1a1a1a]">
|
||||
<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-[#a89f8f] hover:text-[#d4af37]">← 返回案例列表</NuxtLink>
|
||||
</div>
|
||||
|
||||
<h1 class="text-3xl sm:text-4xl font-bold text-[#f5f0e6] mb-4">{{ caseItem.title }}</h1>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-4 text-sm text-[#a89f8f] mb-8 pb-8 border-b border-[#333333]">
|
||||
<span v-if="caseItem.clientName" class="px-3 py-1 bg-[#2e2a1c] text-[#d4af37] rounded-full">
|
||||
{{ caseItem.clientName }}
|
||||
</span>
|
||||
<span v-if="caseItem.projectTime">项目时间:{{ caseItem.projectTime }}</span>
|
||||
<span v-if="caseItem.categoryName">行业:{{ caseItem.categoryName }}</span>
|
||||
</div>
|
||||
|
||||
<div class="aspect-video bg-[#2e2e2e] rounded-3xl overflow-hidden mb-10">
|
||||
<img
|
||||
v-if="caseItem.cover"
|
||||
:src="fileUrl(caseItem.cover)"
|
||||
:alt="caseItem.title"
|
||||
class="w-full h-full object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<p v-if="caseItem.summary" class="text-lg text-[#a89f8f] mb-8 leading-relaxed">
|
||||
{{ caseItem.summary }}
|
||||
</p>
|
||||
|
||||
<div class="cms-content">
|
||||
<RichText :content="caseItem.content" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="text-center py-20">
|
||||
<h1 class="text-2xl font-bold text-[#f5f0e6] mb-4">案例不存在或已下架</h1>
|
||||
<NuxtLink :to="`/case${caseItem?.navigationId ? '?navId=' + caseItem.navigationId : ''}`" class="text-[#d4af37] hover:underline">返回案例列表</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { CaseItem } from '~/types'
|
||||
|
||||
/**
|
||||
* 模板 4 - 案例详情页(暗金商务风)
|
||||
*/
|
||||
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}`
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.cms-content :deep(h2) {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin: 1.2em 0 0.6em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(h3) {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin: 1em 0 0.5em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(h4) {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
margin: 0.8em 0 0.4em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(p) {
|
||||
margin-bottom: 1em;
|
||||
line-height: 1.8;
|
||||
color: #d8d2c4;
|
||||
}
|
||||
.cms-content :deep(a) {
|
||||
color: #d4af37;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.cms-content :deep(img) {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0.75rem;
|
||||
margin: 1em 0;
|
||||
}
|
||||
.cms-content :deep(ul),
|
||||
.cms-content :deep(ol) {
|
||||
padding-left: 1.5em;
|
||||
margin-bottom: 1em;
|
||||
color: #d8d2c4;
|
||||
}
|
||||
.cms-content :deep(li) {
|
||||
margin-bottom: 0.4em;
|
||||
}
|
||||
.cms-content :deep(strong) {
|
||||
color: #f5f0e6;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,139 @@
|
||||
<template>
|
||||
<div class="min-h-screen py-16 bg-[#1a1a1a]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="text-center mb-12">
|
||||
<span class="inline-block px-3 py-1 rounded-full bg-[#2e2a1c] text-[#d4af37] text-sm font-semibold mb-4">{{ pageTitle }}</span>
|
||||
<h1 class="text-3xl font-bold text-[#f5f0e6] mb-4">{{ pageTitle }}</h1>
|
||||
<p class="text-[#a89f8f] max-w-2xl mx-auto">展示我们的成功案例与行业经验</p>
|
||||
</div>
|
||||
|
||||
<div v-if="pending" class="flex justify-center py-12">
|
||||
<SiteLoading />
|
||||
</div>
|
||||
<SiteError v-else-if="error" message="获取案例列表失败" />
|
||||
|
||||
<div v-else class="grid sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<article
|
||||
v-for="item in cases"
|
||||
:key="item.id"
|
||||
class="group bg-[#242424] rounded-3xl overflow-hidden shadow-sm hover:shadow-md transition-shadow border border-[#333333]"
|
||||
>
|
||||
<NuxtLink :to="`/case/${item.id}`" class="block">
|
||||
<div class="aspect-[4/3] bg-[#2e2e2e] overflow-hidden">
|
||||
<img
|
||||
v-if="item.cover"
|
||||
:src="fileUrl(item.cover)"
|
||||
:alt="item.title"
|
||||
class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"
|
||||
>
|
||||
<span v-else class="flex items-center justify-center h-full text-[#6f6757]">暂无图片</span>
|
||||
</div>
|
||||
<div class="p-5">
|
||||
<h2 class="text-lg font-semibold text-[#f5f0e6] mb-2 group-hover:text-[#d4af37] transition-colors">
|
||||
{{ item.title }}
|
||||
</h2>
|
||||
<p class="text-sm text-[#a89f8f] line-clamp-2">{{ stripHtml(item.summary) }}</p>
|
||||
<div v-if="item.clientName" class="mt-3 text-xs text-[#a89f8f]">
|
||||
客户:{{ item.clientName }}
|
||||
</div>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-if="!pending && !error && cases.length === 0" class="text-center py-20">
|
||||
<svg class="w-16 h-16 mx-auto text-[#3a3a3a] mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
|
||||
</svg>
|
||||
<p class="text-[#a89f8f]">暂无案例内容</p>
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div v-if="totalPages > 1" class="flex justify-center mt-12">
|
||||
<nav class="flex items-center gap-2">
|
||||
<button
|
||||
v-for="p in totalPages"
|
||||
:key="p"
|
||||
class="px-4 py-2 text-sm rounded-lg transition-colors"
|
||||
:class="p === currentPage ? 'bg-[#d4af37] text-[#1a1a1a]' : 'bg-[#242424] text-[#a89f8f] hover:bg-[#2e2e2e]'"
|
||||
@click="currentPage = p"
|
||||
>
|
||||
{{ p }}
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { CaseItem, PageResult } from '~/types'
|
||||
import { collectDescendantNavIds } from '~/utils/nav-tree'
|
||||
|
||||
/**
|
||||
* 模板 4 - 案例列表页(暗金商务风)
|
||||
*/
|
||||
const { fileUrl } = useFileUrl()
|
||||
const route = useRoute()
|
||||
const { allNavigations, fetchSiteInfo } = useSite()
|
||||
|
||||
// 确保导航数据已加载(用于栏目标题与分类判定)
|
||||
await fetchSiteInfo()
|
||||
|
||||
// 列表(栏目)入口 /case/{navigationId} 时按分类过滤;/case 根目录展示全部案例
|
||||
const navigationId = computed<number | undefined>(() => {
|
||||
const id = route.params.id
|
||||
return id ? Number(id) : undefined
|
||||
})
|
||||
|
||||
// 聚合:父栏目访问时递归收集自身 + 所有后代栏目 navigationId,交给后端 IN 查询
|
||||
const categoryIds = computed<string | undefined>(() => {
|
||||
const ids = collectDescendantNavIds(navigationId.value, allNavigations.value || [])
|
||||
return ids.length ? ids.join(',') : undefined
|
||||
})
|
||||
|
||||
const currentPage = ref(1)
|
||||
const limit = 12
|
||||
|
||||
const { data, pending, error } = await useFetch<PageResult<CaseItem>>('/api/case/list', {
|
||||
key: `case-list-${categoryIds.value ?? navigationId.value ?? 'all'}-p${currentPage.value}`,
|
||||
query: {
|
||||
page: currentPage,
|
||||
limit,
|
||||
...(categoryIds.value
|
||||
? { categoryIds: categoryIds.value }
|
||||
: (navigationId.value ? { navigationId: navigationId.value } : {}))
|
||||
},
|
||||
watch: [currentPage, categoryIds, navigationId]
|
||||
})
|
||||
|
||||
const cases = computed(() => data.value?.list || [])
|
||||
|
||||
const totalCount = computed(() => data.value?.count ?? 0)
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(totalCount.value / limit)))
|
||||
|
||||
// 切换栏目时回到第 1 页
|
||||
watch([categoryIds, navigationId], () => {
|
||||
currentPage.value = 1
|
||||
})
|
||||
|
||||
// 栏目标题:命中导航取导航标题,否则用模块默认名
|
||||
const pageTitle = computed(() => {
|
||||
const id = navigationId.value
|
||||
if (id == null) return '案例展示'
|
||||
const navs = (allNavigations.value || []) as any[]
|
||||
const find = (items: any[]): any => {
|
||||
for (const it of items) {
|
||||
if (it.navigationId === id) return it
|
||||
if (it.children?.length) {
|
||||
const f = find(it.children)
|
||||
if (f) return f
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
return find(navs)?.title || '案例展示'
|
||||
})
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,90 @@
|
||||
<template>
|
||||
<div class="min-h-screen py-16 bg-[#1a1a1a]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="max-w-6xl mx-auto">
|
||||
<div class="text-center mb-12">
|
||||
<span class="inline-block px-3 py-1 rounded-full bg-[#2e2a1c] text-[#d4af37] text-sm font-semibold mb-4">联系我们</span>
|
||||
<h1 class="text-3xl font-bold text-[#f5f0e6] mb-4">期待与您相遇</h1>
|
||||
<p class="text-[#a89f8f] max-w-2xl mx-auto">有任何问题或合作意向,欢迎随时与我们联系</p>
|
||||
</div>
|
||||
|
||||
<div class="grid lg:grid-cols-2 gap-10">
|
||||
<!-- 联系信息 -->
|
||||
<div class="bg-[#242424] rounded-3xl p-8 shadow-sm border border-[#333333]">
|
||||
<h2 class="text-xl font-bold text-[#f5f0e6] mb-6">联系方式</h2>
|
||||
<div class="space-y-6">
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="w-10 h-10 rounded-xl bg-[#2e2a1c] flex items-center justify-center flex-shrink-0">
|
||||
<svg class="w-5 h-5 text-[#d4af37]" 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>
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="font-medium text-[#f5f0e6]">电话咨询</h3>
|
||||
<p class="text-[#a89f8f] mt-1">{{ siteInfo?.phone || '400-000-0000' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="w-10 h-10 rounded-xl bg-[#2e2a1c] flex items-center justify-center flex-shrink-0">
|
||||
<svg class="w-5 h-5 text-[#d4af37]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="font-medium text-[#f5f0e6]">电子邮箱</h3>
|
||||
<p class="text-[#a89f8f] mt-1">{{ siteInfo?.email || 'contact@example.com' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-start gap-4">
|
||||
<div class="w-10 h-10 rounded-xl bg-[#2e2a1c] flex items-center justify-center flex-shrink-0">
|
||||
<svg class="w-5 h-5 text-[#d4af37]" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="font-medium text-[#f5f0e6]">公司地址</h3>
|
||||
<p class="text-[#a89f8f] mt-1">{{ siteInfo?.address || '请填写公司地址' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 在线表单 -->
|
||||
<div class="bg-[#242424] rounded-3xl p-8 shadow-sm border border-[#333333]">
|
||||
<h2 class="text-xl font-bold text-[#f5f0e6] mb-6">在线留言</h2>
|
||||
<ContactForm
|
||||
input-class="w-full px-4 py-2.5 border border-[#333333] rounded-xl focus:outline-none focus:border-[#d4af37] bg-[#1a1a1a] text-[#f5f0e6] placeholder-[#6f6757]"
|
||||
submit-class="w-full px-6 py-3 bg-[#d4af37] text-[#1a1a1a] font-semibold rounded-xl hover:bg-[#c19b2e] transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
label-class="block text-sm font-medium text-[#f5f0e6] mb-1"
|
||||
:accent="config.themeConfig.primaryColor"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<PageAttachments
|
||||
v-if="contactAttachments.length"
|
||||
:attachments="contactAttachments"
|
||||
class="mt-10"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { PageDetail, PageAttachment } from '~/types'
|
||||
import config from '../config'
|
||||
/**
|
||||
* 模板 4 - 联系我们页(暗金商务风)
|
||||
*/
|
||||
const { siteInfo, fetchSiteInfo } = useSite()
|
||||
|
||||
await fetchSiteInfo()
|
||||
|
||||
// 联系页附件(CMS「单页管理」按 path=contact 维护)
|
||||
const { data: contactPage } = await useFetch<PageDetail>('/api/page/detail', { query: { path: 'contact' } })
|
||||
const contactAttachments = computed<PageAttachment[]>(() => contactPage.value?.attachments || [])
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,271 @@
|
||||
<template>
|
||||
<div class="bg-[#0f0f0f] flex-1">
|
||||
<!-- Hero 首屏 -->
|
||||
<HeroSection v-if="homeBlocks.hero" />
|
||||
|
||||
<!-- 核心业务 -->
|
||||
<FeatureSection v-if="homeBlocks.advantages" />
|
||||
|
||||
<!-- 关于我们 -->
|
||||
<AboutSection
|
||||
v-if="homeBlocks.banner"
|
||||
title-color="#ffffff"
|
||||
accent-color="#d4af37"
|
||||
summary-color="#a0a0a0"
|
||||
link-color="#d4af37"
|
||||
bg-color="#0f0f0f"
|
||||
container-class="container mx-auto px-4 sm:px-6 lg:px-8 grid lg:grid-cols-2 gap-12 items-center"
|
||||
image-bg-color="#1a1a1a"
|
||||
image-object-fit="object-cover"
|
||||
/>
|
||||
|
||||
<!-- 最新动态 -->
|
||||
<section v-if="homeBlocks.news && latestArticles.length > 0" class="py-16 lg:py-20 bg-[#0f0f0f]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="text-center mb-12">
|
||||
<h2 class="text-2xl sm:text-3xl font-bold text-white mb-4" data-reveal>最新动态</h2>
|
||||
<div class="w-16 h-1 bg-[#d4af37] mx-auto mb-4" data-reveal data-reveal-delay="100" />
|
||||
<p class="text-[#a0a0a0] max-w-2xl mx-auto" data-reveal data-reveal-delay="200">了解企业最新资讯与行业动态</p>
|
||||
</div>
|
||||
<div class="grid md:grid-cols-3 gap-6">
|
||||
<article
|
||||
v-for="(item, index) in latestArticles"
|
||||
:key="item.id || item.articleId"
|
||||
class="bg-[#1a1a1a] border border-[#333] rounded-xl overflow-hidden hover:border-[#d4af37]/50 transition-all anim-card group"
|
||||
data-reveal
|
||||
:data-reveal-delay="index * 100"
|
||||
>
|
||||
<NuxtLink :to="`/article/${item.id || item.articleId}`">
|
||||
<div class="aspect-video bg-[#222] flex items-center justify-center anim-card-media overflow-hidden">
|
||||
<img
|
||||
:src="articleImage(item)"
|
||||
:alt="item.title"
|
||||
class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"
|
||||
loading="lazy"
|
||||
@error="onArticleImgError($event)"
|
||||
>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
<div class="p-5">
|
||||
<div class="text-xs text-[#a0a0a0] mb-2">
|
||||
{{ formatDate(item.publishTime || item.createTime) }}
|
||||
<span v-if="item.categoryName" class="ml-2 text-[#d4af37]">{{ item.categoryName }}</span>
|
||||
</div>
|
||||
<h3 class="text-lg font-semibold text-white mb-2 line-clamp-2 group-hover:text-[#d4af37] transition-colors">
|
||||
<NuxtLink :to="`/article/${item.id || item.articleId}`">{{ item.title }}</NuxtLink>
|
||||
</h3>
|
||||
<p class="text-sm text-[#a0a0a0] line-clamp-2">{{ stripHtml(item.summary) }}</p>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<div v-if="newsNav" class="text-center mt-10">
|
||||
<NuxtLink
|
||||
:to="newsNav.path || '/article'"
|
||||
class="inline-flex items-center text-[#d4af37] font-semibold hover:text-[#e6c35a] transition-colors"
|
||||
>
|
||||
查看更多
|
||||
<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>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 成功案例 -->
|
||||
<section v-if="homeBlocks.cases && cases.length > 0" class="py-16 lg:py-20 bg-[#0f0f0f]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="text-center mb-12">
|
||||
<h2 class="text-2xl sm:text-3xl font-bold text-white mb-4" data-reveal>成功案例</h2>
|
||||
<div class="w-16 h-1 bg-[#d4af37] mx-auto mb-4" data-reveal data-reveal-delay="100" />
|
||||
<p class="text-[#a0a0a0] max-w-2xl mx-auto" data-reveal data-reveal-delay="200">来自不同行业的真实落地实践</p>
|
||||
</div>
|
||||
<div class="grid sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<article
|
||||
v-for="(item, index) in cases"
|
||||
:key="item.id"
|
||||
class="group bg-[#1a1a1a] border border-[#333] rounded-xl overflow-hidden hover:border-[#d4af37]/50 transition-all anim-card"
|
||||
data-reveal
|
||||
:data-reveal-delay="index * 100"
|
||||
>
|
||||
<NuxtLink :to="`/case/${item.id}`" class="block">
|
||||
<div class="aspect-[4/3] bg-[#222] overflow-hidden">
|
||||
<img
|
||||
v-if="item.cover"
|
||||
:src="fileUrl(item.cover)"
|
||||
:alt="item.title"
|
||||
class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"
|
||||
loading="lazy"
|
||||
>
|
||||
<span v-else class="flex items-center justify-center h-full text-[#a0a0a0]">暂无图片</span>
|
||||
</div>
|
||||
<div class="p-5">
|
||||
<h3 class="text-lg font-semibold text-white mb-2 group-hover:text-[#d4af37] transition-colors">
|
||||
{{ item.title }}
|
||||
</h3>
|
||||
<p class="text-sm text-[#a0a0a0] line-clamp-2">{{ stripHtml(item.summary) }}</p>
|
||||
<div v-if="item.clientName" class="mt-3 text-xs text-[#a0a0a0]">
|
||||
客户:{{ item.clientName }}
|
||||
</div>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</article>
|
||||
</div>
|
||||
<div v-if="caseNav" class="text-center mt-10">
|
||||
<NuxtLink
|
||||
:to="caseNav.path || '/case'"
|
||||
class="inline-flex items-center text-[#d4af37] font-semibold hover:text-[#e6c35a] transition-colors"
|
||||
>
|
||||
查看更多案例
|
||||
<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>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 联系我们 -->
|
||||
<section v-if="homeBlocks.cta" class="py-16 lg:py-20 bg-[#161616]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8 text-center">
|
||||
<h2 class="text-2xl sm:text-3xl font-bold text-white mb-4" data-reveal>
|
||||
准备好开始了吗?
|
||||
</h2>
|
||||
<div class="w-16 h-1 bg-[#d4af37] mx-auto mb-6" data-reveal data-reveal-delay="100" />
|
||||
<p class="text-[#a0a0a0] max-w-2xl mx-auto mb-8" data-reveal data-reveal-delay="200">
|
||||
立即联系我们,获取专属人力资源解决方案
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center px-8 py-3 bg-[#d4af37] text-[#1a1a1a] font-semibold rounded hover:bg-[#e6c35a] transition-colors anim-shimmer"
|
||||
@click="openConsult()"
|
||||
>
|
||||
立即咨询
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 模板 4 - 首页(黑金高端风)
|
||||
* 参考 template-07 结构,使用黑金配色并适配人力资源行业文案。
|
||||
*/
|
||||
import dayjs from 'dayjs'
|
||||
import HeroSection from '../components/HeroSection.vue'
|
||||
import FeatureSection from '../components/FeatureSection.vue'
|
||||
import type { CmsNavigation, Article, CaseItem, PageResult, ApiEnvelope } from '~/types'
|
||||
|
||||
const { siteName, navigations, bottomNavigations, fetchSiteInfo } = useSite()
|
||||
const { fileUrl } = useFileUrl()
|
||||
const { openConsult } = useConsult()
|
||||
const { homeBlocks } = useFeatures()
|
||||
|
||||
await fetchSiteInfo()
|
||||
|
||||
/** 从导航中找到"新闻/动态"相关的导航项 */
|
||||
const newsNav = computed<CmsNavigation | undefined>(() => {
|
||||
const all = [
|
||||
...(navigations.value || []),
|
||||
...(bottomNavigations.value || [])
|
||||
]
|
||||
const articleNavs = all.filter((n) => n.model === 'article')
|
||||
const byTitle = articleNavs.find((n) => /新闻|动态|资讯/.test(n.title || ''))
|
||||
if (byTitle) return byTitle
|
||||
return articleNavs[0]
|
||||
})
|
||||
|
||||
/** 从导航中找到"案例"相关的导航项 */
|
||||
const caseNav = computed<CmsNavigation | undefined>(() => {
|
||||
const navs = navigations.value || []
|
||||
return navs.find((n) => n.model === 'case')
|
||||
})
|
||||
|
||||
/** 所有 article 类型栏目(含子栏目) */
|
||||
const articleNavs = computed<CmsNavigation[]>(() => {
|
||||
const list: CmsNavigation[] = []
|
||||
const walk = (arr?: CmsNavigation[]) => {
|
||||
if (!arr) return
|
||||
for (const n of arr) {
|
||||
if (n.model === 'article' && !n.hide && !n.deleted) {
|
||||
list.push(n)
|
||||
}
|
||||
if (n.children?.length) walk(n.children)
|
||||
}
|
||||
}
|
||||
walk(navigations.value)
|
||||
walk(bottomNavigations.value)
|
||||
return list
|
||||
})
|
||||
|
||||
/** 获取最新文章 */
|
||||
const latestArticles = ref<Article[]>([])
|
||||
|
||||
for (const nav of articleNavs.value) {
|
||||
try {
|
||||
const res = await $fetch<ApiEnvelope<PageResult<Article>> | PageResult<Article>>(
|
||||
'/api/article/list',
|
||||
{
|
||||
query: {
|
||||
navigationId: nav.navigationId,
|
||||
page: 1,
|
||||
limit: 3
|
||||
}
|
||||
}
|
||||
)
|
||||
const envelope = res as ApiEnvelope<PageResult<Article>>
|
||||
const list = envelope?.data?.list || (res as PageResult<Article>)?.list || []
|
||||
if (list.length > 0) {
|
||||
latestArticles.value = list
|
||||
break
|
||||
}
|
||||
} catch {
|
||||
// 跳过失败栏目
|
||||
}
|
||||
}
|
||||
|
||||
/** 兜底:不限栏目拉最新文章 */
|
||||
if (latestArticles.value.length === 0) {
|
||||
try {
|
||||
const res = await $fetch<ApiEnvelope<PageResult<Article>> | PageResult<Article>>(
|
||||
'/api/article/list',
|
||||
{ query: { page: 1, limit: 3 } }
|
||||
)
|
||||
const envelope = res as ApiEnvelope<PageResult<Article>>
|
||||
latestArticles.value = envelope?.data?.list || (res as PageResult<Article>)?.list || []
|
||||
} catch {
|
||||
latestArticles.value = []
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取最新案例 */
|
||||
const cases = ref<CaseItem[]>([])
|
||||
try {
|
||||
const res = await $fetch<PageResult<CaseItem>>('/api/case/list', {
|
||||
query: { page: 1, limit: 6 }
|
||||
})
|
||||
cases.value = res?.list || []
|
||||
} catch {
|
||||
cases.value = []
|
||||
}
|
||||
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return ''
|
||||
return dayjs(date).format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
/** 文章封面图兜底 */
|
||||
const FALLBACK_NEWS_IMAGE = '/images/template-07/news-default.jpg'
|
||||
function articleImage(item: Article) {
|
||||
const raw = item.image || item.cover || item.photo || ''
|
||||
if (!raw) return FALLBACK_NEWS_IMAGE
|
||||
return fileUrl(raw)
|
||||
}
|
||||
function onArticleImgError(e: Event) {
|
||||
const el = e.target as HTMLImageElement
|
||||
if (el && el.src !== FALLBACK_NEWS_IMAGE) {
|
||||
el.src = FALLBACK_NEWS_IMAGE
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<div class="min-h-screen py-16 bg-[#1a1a1a]">
|
||||
<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-[#a89f8f] hover:text-[#d4af37]">← 返回新闻列表</NuxtLink>
|
||||
</div>
|
||||
|
||||
<h1 class="text-3xl sm:text-4xl font-bold text-[#f5f0e6] mb-4">
|
||||
{{ article.title }}
|
||||
</h1>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-4 text-sm text-[#a89f8f] mb-8 pb-8 border-b border-[#333333]">
|
||||
<span v-if="article.categoryName" class="px-3 py-1 bg-[#2e2a1c] text-[#d4af37] 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="aspect-video bg-[#2e2e2e] rounded-3xl overflow-hidden mb-10">
|
||||
<img
|
||||
:src="fileUrl(article.image || article.cover)"
|
||||
:alt="article.title"
|
||||
class="w-full h-full object-cover"
|
||||
>
|
||||
</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-[#f5f0e6] mb-4">文章不存在或已下架</h1>
|
||||
<NuxtLink :to="`/article${article?.navigationId ? '?navId=' + article.navigationId : ''}`" class="text-[#d4af37] hover:underline">返回新闻列表</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import dayjs from 'dayjs'
|
||||
import type { Article } from '~/types'
|
||||
|
||||
/**
|
||||
* 模板 4 - 新闻详情页(暗金商务风)
|
||||
*/
|
||||
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) {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin: 1.2em 0 0.6em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(h3) {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin: 1em 0 0.5em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(h4) {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
margin: 0.8em 0 0.4em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(p) {
|
||||
margin-bottom: 1em;
|
||||
line-height: 1.8;
|
||||
color: #d8d2c4;
|
||||
}
|
||||
.cms-content :deep(a) {
|
||||
color: #d4af37;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.cms-content :deep(img) {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0.75rem;
|
||||
margin: 1em 0;
|
||||
}
|
||||
.cms-content :deep(ul),
|
||||
.cms-content :deep(ol) {
|
||||
padding-left: 1.5em;
|
||||
margin-bottom: 1em;
|
||||
color: #d8d2c4;
|
||||
}
|
||||
.cms-content :deep(li) {
|
||||
margin-bottom: 0.4em;
|
||||
}
|
||||
.cms-content :deep(strong) {
|
||||
color: #f5f0e6;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,188 @@
|
||||
<template>
|
||||
<div class="min-h-screen py-16 bg-[#1a1a1a]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="text-center mb-12">
|
||||
<span class="inline-block px-3 py-1 rounded-full bg-[#2e2a1c] text-[#d4af37] text-sm font-semibold mb-4">品牌动态</span>
|
||||
<h1 class="text-3xl font-bold text-[#f5f0e6] mb-4">{{ pageTitle }}</h1>
|
||||
<p class="text-[#a89f8f] max-w-2xl mx-auto">了解品牌最新动态与行业资讯</p>
|
||||
</div>
|
||||
|
||||
<div v-if="pending" class="flex justify-center py-12">
|
||||
<SiteLoading />
|
||||
</div>
|
||||
<div v-else-if="error" class="text-center py-12">
|
||||
<SiteError message="获取新闻列表失败" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div v-if="articles.length > 0" class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<article
|
||||
v-for="item in articles"
|
||||
:key="item.id || item.articleId"
|
||||
class="bg-[#242424] rounded-3xl overflow-hidden shadow-sm hover:shadow-md transition-shadow border border-[#333333]"
|
||||
>
|
||||
<NuxtLink :to="`/article/${item.id || item.articleId}`">
|
||||
<div class="aspect-video bg-[#2e2e2e] flex items-center justify-center">
|
||||
<img
|
||||
v-if="item.image || item.cover || item.photo"
|
||||
:src="fileUrl(item.image || item.cover || item.photo || '')"
|
||||
:alt="item.title"
|
||||
class="w-full h-full object-cover"
|
||||
>
|
||||
<span v-else class="text-[#6f6757]">暂无图片</span>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
<div class="p-5">
|
||||
<div class="text-xs text-[#a89f8f] mb-2">
|
||||
{{ formatDate(item.publishTime || item.createTime) }}
|
||||
<span v-if="item.categoryName" class="ml-2 text-[#d4af37]">{{ item.categoryName }}</span>
|
||||
</div>
|
||||
<h2 class="text-lg font-semibold text-[#f5f0e6] mb-2 line-clamp-2 hover:text-[#d4af37] transition-colors">
|
||||
<NuxtLink :to="`/article/${item.id || item.articleId}`">{{ item.title }}</NuxtLink>
|
||||
</h2>
|
||||
<p class="text-sm text-[#a89f8f] line-clamp-2">{{ stripHtml(item.summary) }}</p>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-else class="text-center py-20">
|
||||
<svg class="w-16 h-16 mx-auto text-[#3a3a3a] mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z" />
|
||||
</svg>
|
||||
<p class="text-[#a89f8f]">暂无新闻内容</p>
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div v-if="totalPages > 1" class="flex justify-center mt-12">
|
||||
<nav class="flex items-center gap-2">
|
||||
<button
|
||||
v-for="p in totalPages"
|
||||
:key="p"
|
||||
class="w-10 h-10 text-sm rounded-full transition-colors"
|
||||
:class="p === currentPage
|
||||
? 'bg-[#d4af37] text-[#1a1a1a] font-semibold'
|
||||
: 'bg-[#242424] text-[#f5f0e6] border border-[#333333] hover:bg-[#2e2e2e]'"
|
||||
@click="currentPage = p"
|
||||
>
|
||||
{{ p }}
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 模板 4 - 新闻列表页(暗金商务风)
|
||||
*/
|
||||
import dayjs from 'dayjs'
|
||||
import type { Article, PageResult, ApiEnvelope, CmsNavigation } from '~/types'
|
||||
import { collectDescendantNavIds } from '~/utils/nav-tree'
|
||||
|
||||
const { allNavigations, fetchSiteInfo } = useSite()
|
||||
const { fileUrl } = useFileUrl()
|
||||
const route = useRoute()
|
||||
|
||||
await fetchSiteInfo()
|
||||
|
||||
/** 从路由参数、查询参数或导航中获取栏目 navigationId
|
||||
*
|
||||
* 优先级(2026-07-21 修正):
|
||||
* 1. route.query.navId(查询参数 ?navId=xxx,优先——导航子分类下拉切换时通过此方式传入,
|
||||
* 必须高于 route.params.id,否则 /article/4277?navId=4278 会因 params.id=4277 先命中而忽略 navId)
|
||||
* 2. route.params.id(路由参数 /article/:navigationId)
|
||||
* 3. navigations 中 model=article 的第一个栏目(兜底)
|
||||
*/
|
||||
const navigationId = computed<number | undefined>(() => {
|
||||
// 1. 查询参数优先(导航子分类下拉切换时传入)
|
||||
const queryNavId = route.query.navId as string
|
||||
if (queryNavId) {
|
||||
const num = Number(queryNavId)
|
||||
if (!Number.isNaN(num)) return num
|
||||
}
|
||||
// 2. 路由参数
|
||||
const routeId = route.params.id as string
|
||||
if (routeId) {
|
||||
const num = Number(routeId)
|
||||
if (!Number.isNaN(num)) return num
|
||||
}
|
||||
// 3. 兜底:从 navigations 中查找 model=article 的导航
|
||||
const navs = allNavigations.value || []
|
||||
const nav = navs.find((n) => n.model === 'article' || (n.path || '').split('/').filter(Boolean)[0] === 'article')
|
||||
return nav?.navigationId
|
||||
})
|
||||
|
||||
/** 聚合:父栏目访问时递归收集自身 + 所有后代栏目 navigationId,交给后端 IN 查询 */
|
||||
const categoryIds = computed<string | undefined>(() => {
|
||||
const ids = collectDescendantNavIds(navigationId.value, allNavigations.value || [])
|
||||
return ids.length ? ids.join(',') : undefined
|
||||
})
|
||||
|
||||
/** 页面标题 */
|
||||
const pageTitle = computed(() => {
|
||||
const navs = allNavigations.value || []
|
||||
const findNav = (items: CmsNavigation[]): CmsNavigation | undefined => {
|
||||
for (const item of items) {
|
||||
if (item.navigationId === navigationId.value) return item
|
||||
if (item.children?.length) {
|
||||
const found = findNav(item.children)
|
||||
if (found) return found
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
if (keywords.value) return `搜索:"${keywords.value}"`
|
||||
return findNav(navs)?.title || '新闻资讯'
|
||||
})
|
||||
|
||||
/** 搜索关键词(来自 Header 搜索框提交的 ?keywords=) */
|
||||
const keywords = computed(() => ((route.query.keywords as string) || '').trim())
|
||||
|
||||
const currentPage = ref(1)
|
||||
const limit = 12
|
||||
|
||||
// 响应式 query + watch 选项触发翻页/换栏目的重新请求;
|
||||
// key 带页码,保证每一页独立缓存、翻页必然重新拉取(避免共用 key 被缓存返回第 1 页)。
|
||||
// keywords 变化时同样触发重新请求,关键词搜索忽略栏目、全局检索。
|
||||
const { data, pending, error } = await useFetch<
|
||||
ApiEnvelope<PageResult<Article>> | PageResult<Article>
|
||||
>('/api/article/list', {
|
||||
key: `news-list-${keywords.value || 'all'}-${categoryIds.value ?? navigationId.value ?? 'default'}-p${currentPage.value}`,
|
||||
query: {
|
||||
categoryIds: keywords.value ? undefined : categoryIds.value,
|
||||
keywords: keywords.value || undefined,
|
||||
page: currentPage,
|
||||
limit
|
||||
},
|
||||
watch: [currentPage, navigationId, categoryIds, keywords]
|
||||
})
|
||||
|
||||
const articles = computed<Article[]>(() => {
|
||||
const envelope = data.value as ApiEnvelope<PageResult<Article>>
|
||||
const direct = data.value as PageResult<Article>
|
||||
return envelope?.data?.list || direct?.list || []
|
||||
})
|
||||
|
||||
const totalCount = computed(() => {
|
||||
const envelope = data.value as ApiEnvelope<PageResult<Article>>
|
||||
const direct = data.value as PageResult<Article>
|
||||
return envelope?.data?.count || envelope?.data?.total || direct?.count || direct?.total || 0
|
||||
})
|
||||
|
||||
const totalPages = computed(() => {
|
||||
return Math.ceil(totalCount.value / limit)
|
||||
})
|
||||
|
||||
// 栏目切换 / 关键词变化时回到第 1 页(watch 选项已负责重新请求)
|
||||
watch([navigationId, keywords], () => {
|
||||
currentPage.value = 1
|
||||
})
|
||||
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return ''
|
||||
return dayjs(date).format('YYYY-MM-DD')
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,216 @@
|
||||
<template>
|
||||
<div class="min-h-[60vh] flex items-center py-20 bg-[#1a1a1a]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<!-- 顶部:栏目标题 + 自身内容 -->
|
||||
<div v-if="pageTitle" class="max-w-4xl mx-auto">
|
||||
<div class="text-center mb-10">
|
||||
<h1 class="text-3xl sm:text-4xl font-bold text-[#f5f0e6] mb-4">
|
||||
{{ pageTitle }}
|
||||
</h1>
|
||||
<div class="w-16 h-1 bg-[#d4af37] rounded-full mx-auto" />
|
||||
</div>
|
||||
<div v-if="pageData && pageData.hasContent">
|
||||
<div v-if="pageData.updateTime" class="text-[#a89f8f] text-sm text-center mb-10">
|
||||
更新时间:{{ formatDate(pageData.updateTime) }}
|
||||
</div>
|
||||
<div class="cms-content">
|
||||
<RichText :content="pageData.content" />
|
||||
</div>
|
||||
</div>
|
||||
<PageAttachments
|
||||
v-if="pageData?.attachments?.length"
|
||||
:attachments="pageData.attachments"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 子栏目聚合列表 -->
|
||||
<div v-if="childCards.length" class="max-w-5xl mx-auto mt-16">
|
||||
<h2 class="text-2xl font-bold text-[#f5f0e6] mb-8 text-center">子栏目</h2>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<NuxtLink
|
||||
v-for="p in childCards"
|
||||
:key="p.navigationId"
|
||||
:to="`/page/${p.navigationId}`"
|
||||
class="block p-6 rounded-xl border border-[#3a3a3a] hover:shadow-lg hover:border-[#d4af37] transition"
|
||||
>
|
||||
<h3 class="text-lg font-semibold text-[#f5f0e6] mb-2">{{ p.title }}</h3>
|
||||
<p class="text-sm text-[#a89f8f] leading-relaxed line-clamp-3">{{ excerpt(p.content) }}</p>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-if="!pageData?.hasContent && !childCards.length" class="text-center py-20">
|
||||
<h1 class="text-2xl font-bold text-[#f5f0e6] mb-4">{{ pageTitle }}</h1>
|
||||
<p class="text-[#a89f8f] mb-2">{{ emptyState.title }}</p>
|
||||
<p class="text-[#8c8378] text-sm mb-6 leading-relaxed">
|
||||
{{ emptyState.desc }}<br />
|
||||
当前导航:{{ currentNav?.title || pageTitle }}(ID:{{ navigationId }})
|
||||
</p>
|
||||
<NuxtLink to="/" class="text-[#d4af37] hover:underline">返回首页</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 模板 4 - 通用 CMS 页面(暗金商务风)
|
||||
* 支持两种入口:
|
||||
* 1. /page/:navigationId → CMS 导航路径(优先)
|
||||
* 2. /:slug → 传统路径
|
||||
*
|
||||
* 父栏目聚合:当当前 page 栏目拥有子栏目时,递归收集其下所有子栏目的单页,
|
||||
* 以卡片列表形式聚合展示(每个子页卡片链接到 /page/{childNavId} 详情页)。
|
||||
*/
|
||||
import dayjs from 'dayjs'
|
||||
import type { CmsNavigation, PageDetail } from '~/types'
|
||||
import { collectDescendantNavIds, isParentNavigation } from '~/utils/nav-tree'
|
||||
|
||||
interface ChildPage {
|
||||
pageId?: number
|
||||
title?: string
|
||||
path?: string
|
||||
content?: string
|
||||
navigationId?: number
|
||||
image?: string | null
|
||||
}
|
||||
|
||||
const route = useRoute()
|
||||
const { allNavigations, fetchSiteInfo } = useSite()
|
||||
|
||||
await fetchSiteInfo()
|
||||
|
||||
/** 从路由获取 navigationId */
|
||||
const navigationId = computed(() => {
|
||||
const id = route.params.id as string
|
||||
if (id) {
|
||||
const num = Number(id)
|
||||
if (!Number.isNaN(num)) return num
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
|
||||
/** 当前栏目是否为父栏目(拥有子栏目) */
|
||||
const hasChildren = computed(() => isParentNavigation(navigationId.value, allNavigations.value || []))
|
||||
|
||||
/** 递归收集当前栏目自身 + 所有后代 navigationId */
|
||||
const descendantNavIds = computed(() =>
|
||||
collectDescendantNavIds(navigationId.value, allNavigations.value || [])
|
||||
)
|
||||
|
||||
/** 从导航中查找当前页面信息(使用 allNavigations,已做标题映射) */
|
||||
const currentNav = computed<CmsNavigation | undefined>(() => {
|
||||
if (!navigationId.value) return undefined
|
||||
const findNav = (items: CmsNavigation[]): CmsNavigation | undefined => {
|
||||
for (const item of items) {
|
||||
if (item.navigationId === navigationId.value) return item
|
||||
if (item.children?.length) {
|
||||
const found = findNav(item.children)
|
||||
if (found) return found
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
return findNav(allNavigations.value)
|
||||
})
|
||||
|
||||
/** 获取页面内容 */
|
||||
const navId = navigationId.value
|
||||
const pagePath = (() => {
|
||||
const num = Number(route.params.id)
|
||||
return Number.isNaN(num) ? (route.params.id as string) : undefined
|
||||
})()
|
||||
const { data: pageData } = await useFetch<PageDetail>('/api/page/detail', {
|
||||
key: `page-${navId ?? pagePath ?? 'default'}`,
|
||||
query: { navigationId: navId, path: pagePath }
|
||||
})
|
||||
|
||||
/** 父栏目聚合:取其下所有子栏目的单页(不含父栏目自身,避免与顶部内容重复) */
|
||||
const childPages = ref<ChildPage[]>([])
|
||||
if (hasChildren.value && descendantNavIds.value.length) {
|
||||
const { data: childrenData } = await useFetch<{ list: ChildPage[]; count: number }>('/api/page/children', {
|
||||
key: `page-children-${navId}`,
|
||||
query: { navigationIds: descendantNavIds.value.join(',') }
|
||||
})
|
||||
childPages.value = childrenData.value?.list || []
|
||||
}
|
||||
const childCards = computed(() => childPages.value.filter(p => p.navigationId !== navId))
|
||||
|
||||
const pageTitle = computed(() => {
|
||||
return pageData.value?.title || currentNav.value?.title || '页面'
|
||||
})
|
||||
|
||||
/** 空内容兜底文案,按状态区分「未录入」与「接口异常」 */
|
||||
const emptyState = computed(() => {
|
||||
const status = pageData.value?.status
|
||||
if (status === 'error') {
|
||||
return { title: '内容暂时无法加载', desc: '内容接口暂时不可用,请稍后再试。' }
|
||||
}
|
||||
return { title: '内容尚未录入', desc: '该页面正文尚未在 CMS 管理后台配置,请前往 CMS 后台为该导航补充内容。' }
|
||||
})
|
||||
|
||||
/** 富文本正文截取纯文本摘要 */
|
||||
function excerpt(html?: string, len = 80) {
|
||||
if (!html) return ''
|
||||
const text = (html || '')
|
||||
.replace(/<[^>]+>/g, '')
|
||||
.replace(/ /g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
return text.length > len ? text.slice(0, len) + '…' : text
|
||||
}
|
||||
|
||||
function formatDate(date?: string) {
|
||||
if (!date) return ''
|
||||
return dayjs(date).format('YYYY-MM-DD')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.cms-content :deep(h2) {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin: 1.2em 0 0.6em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(h3) {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin: 1em 0 0.5em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(h4) {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
margin: 0.8em 0 0.4em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(p) {
|
||||
margin-bottom: 1em;
|
||||
line-height: 1.8;
|
||||
color: #d8d2c4;
|
||||
}
|
||||
.cms-content :deep(a) {
|
||||
color: #d4af37;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.cms-content :deep(img) {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0.75rem;
|
||||
margin: 1em 0;
|
||||
}
|
||||
.cms-content :deep(ul),
|
||||
.cms-content :deep(ol) {
|
||||
padding-left: 1.5em;
|
||||
margin-bottom: 1em;
|
||||
color: #d8d2c4;
|
||||
}
|
||||
.cms-content :deep(li) {
|
||||
margin-bottom: 0.4em;
|
||||
}
|
||||
.cms-content :deep(strong) {
|
||||
color: #f5f0e6;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<div class="min-h-screen py-16 bg-[#1a1a1a]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div v-if="product" class="max-w-5xl mx-auto">
|
||||
<div class="mb-8">
|
||||
<NuxtLink :to="`/product${product?.navigationId ? '?navId=' + product.navigationId : ''}`" class="text-sm text-[#a89f8f] hover:text-[#d4af37]">← 返回产品列表</NuxtLink>
|
||||
</div>
|
||||
|
||||
<div class="grid lg:grid-cols-2 gap-10 mb-12">
|
||||
<div class="aspect-video bg-[#2e2e2e] rounded-3xl overflow-hidden">
|
||||
<img
|
||||
v-if="product.cover"
|
||||
:src="fileUrl(product.cover)"
|
||||
:alt="product.productName"
|
||||
class="w-full h-full object-cover"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-[#f5f0e6] mb-4">{{ product.productName }}</h1>
|
||||
<p v-if="product.subtitle" class="text-lg text-[#a89f8f] mb-6">{{ product.subtitle }}</p>
|
||||
<p class="text-[#a89f8f] leading-relaxed mb-6">{{ stripHtml(product.description) }}</p>
|
||||
<div v-if="product.price" class="text-2xl font-bold text-[#d4af37] mb-6">
|
||||
{{ product.price }}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center px-8 py-3 bg-[#d4af37] text-[#1a1a1a] font-semibold rounded-full hover:bg-[#c19b2e] transition-colors"
|
||||
@click="openConsult({ need: `咨询产品:${product.productName}`, source: 'product-detail' })"
|
||||
>
|
||||
立即咨询
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border-t border-[#333333] pt-10">
|
||||
<h2 class="text-2xl font-bold text-[#f5f0e6] mb-6">产品详情</h2>
|
||||
<div class="cms-content">
|
||||
<RichText :content="product.content" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="text-center py-20">
|
||||
<h1 class="text-2xl font-bold text-[#f5f0e6] mb-4">产品不存在或已下架</h1>
|
||||
<NuxtLink :to="`/product${product?.navigationId ? '?navId=' + product.navigationId : ''}`" class="text-[#d4af37] hover:underline">返回产品列表</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Product } from '~/types'
|
||||
|
||||
/**
|
||||
* 模板 4 - 产品详情页(暗金商务风)
|
||||
*/
|
||||
const route = useRoute()
|
||||
const id = route.params.id as string
|
||||
const { fileUrl } = useFileUrl()
|
||||
const { openConsult } = useConsult()
|
||||
|
||||
const { data: product } = await useFetch<Product | null>(`/api/product/detail?id=${id}`, {
|
||||
key: `product-${id}`
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.cms-content :deep(h2) {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin: 1.2em 0 0.6em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(h3) {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin: 1em 0 0.5em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(h4) {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
margin: 0.8em 0 0.4em;
|
||||
color: #f5f0e6;
|
||||
}
|
||||
.cms-content :deep(p) {
|
||||
margin-bottom: 1em;
|
||||
line-height: 1.8;
|
||||
color: #d8d2c4;
|
||||
}
|
||||
.cms-content :deep(a) {
|
||||
color: #d4af37;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.cms-content :deep(img) {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0.75rem;
|
||||
margin: 1em 0;
|
||||
}
|
||||
.cms-content :deep(ul),
|
||||
.cms-content :deep(ol) {
|
||||
padding-left: 1.5em;
|
||||
margin-bottom: 1em;
|
||||
color: #d8d2c4;
|
||||
}
|
||||
.cms-content :deep(li) {
|
||||
margin-bottom: 0.4em;
|
||||
}
|
||||
.cms-content :deep(strong) {
|
||||
color: #f5f0e6;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<div class="min-h-screen py-16 bg-[#1a1a1a]">
|
||||
<div class="container mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div class="text-center mb-12">
|
||||
<span class="inline-block px-3 py-1 rounded-full bg-[#2e2a1c] text-[#d4af37] text-sm font-semibold mb-4">产品系列</span>
|
||||
<h1 class="text-3xl font-bold text-[#f5f0e6] mb-4">产品中心</h1>
|
||||
<p class="text-[#a89f8f] max-w-2xl mx-auto">为您精选自然美味的好产品</p>
|
||||
</div>
|
||||
|
||||
<div v-if="pending" class="flex justify-center py-12">
|
||||
<SiteLoading />
|
||||
</div>
|
||||
<SiteError v-else-if="error" message="获取产品列表失败" />
|
||||
|
||||
<div v-else class="grid sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<article
|
||||
v-for="item in products"
|
||||
:key="item.id ?? item.productId"
|
||||
class="bg-[#242424] rounded-3xl overflow-hidden shadow-sm hover:shadow-md transition-shadow border border-[#333333]"
|
||||
>
|
||||
<div class="aspect-video bg-[#2e2e2e] flex items-center justify-center">
|
||||
<img
|
||||
v-if="item.cover"
|
||||
:src="fileUrl(item.cover)"
|
||||
:alt="item.productName"
|
||||
class="w-full h-full object-cover"
|
||||
>
|
||||
<span v-else class="text-[#6f6757]">暂无图片</span>
|
||||
</div>
|
||||
<div class="p-5">
|
||||
<h2 class="text-lg font-semibold text-[#f5f0e6] mb-2 hover:text-[#d4af37] transition-colors">
|
||||
<NuxtLink :to="`/product/${item.id ?? item.productId}`">{{ item.productName }}</NuxtLink>
|
||||
</h2>
|
||||
<p class="text-sm text-[#a89f8f] line-clamp-2 mb-4">{{ stripHtml(item.description || item.subtitle) }}</p>
|
||||
<div class="flex items-center justify-between">
|
||||
<span v-if="item.price" class="text-lg font-bold text-[#d4af37]">{{ item.price }}</span>
|
||||
<NuxtLink
|
||||
:to="`/product/${item.id ?? item.productId}`"
|
||||
class="text-sm text-[#d4af37] hover:text-[#c19b2e] font-medium"
|
||||
>
|
||||
了解详情 →
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-if="!pending && !error && products.length === 0" class="text-center py-20">
|
||||
<svg class="w-16 h-16 mx-auto text-[#3a3a3a] mb-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" />
|
||||
</svg>
|
||||
<p class="text-[#a89f8f]">暂无产品内容</p>
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div v-if="totalPages > 1" class="flex justify-center mt-12">
|
||||
<nav class="flex items-center gap-2">
|
||||
<button
|
||||
v-for="p in totalPages"
|
||||
:key="p"
|
||||
class="px-4 py-2 text-sm rounded-lg transition-colors"
|
||||
:class="p === currentPage ? 'bg-[#d4af37] text-[#1a1a1a]' : 'bg-[#242424] text-[#a89f8f] hover:bg-[#2e2a1c]'"
|
||||
@click="currentPage = p"
|
||||
>
|
||||
{{ p }}
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Product, PageResult, ApiEnvelope } from '~/types'
|
||||
import { collectDescendantNavIds } from '~/utils/nav-tree'
|
||||
|
||||
/**
|
||||
* 产品列表页
|
||||
*/
|
||||
const { fileUrl } = useFileUrl()
|
||||
const { allNavigations, fetchSiteInfo } = useSite()
|
||||
const route = useRoute()
|
||||
|
||||
await fetchSiteInfo()
|
||||
|
||||
/**
|
||||
* 栏目 navigationId:从查询参数或路由参数读取。
|
||||
* 优先级(2026-07-21 修正):route.query.navId > route.params.id
|
||||
* (子分类下拉切换通过 ?navId= 传入,必须优先于路径参数,否则切换不生效)
|
||||
*/
|
||||
const navigationId = computed<number | undefined>(() => {
|
||||
// 1. 查询参数优先(导航子分类下拉切换时传入)
|
||||
const qid = route.query.navId as string
|
||||
if (qid) {
|
||||
const n = Number(qid)
|
||||
if (!Number.isNaN(n)) return n
|
||||
}
|
||||
// 2. 路由参数(/product/:navigationId)
|
||||
const pid = route.params.id as string
|
||||
if (pid) {
|
||||
const n = Number(pid)
|
||||
if (!Number.isNaN(n)) return n
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
|
||||
// 聚合:父栏目访问时递归收集自身 + 所有后代栏目 navigationId,交给后端 IN 查询
|
||||
const categoryIds = computed<string | undefined>(() => {
|
||||
const ids = collectDescendantNavIds(navigationId.value, allNavigations.value || [])
|
||||
return ids.length ? ids.join(',') : undefined
|
||||
})
|
||||
|
||||
const currentPage = ref(1)
|
||||
const limit = 12
|
||||
|
||||
const { data, pending, error } = await useFetch<
|
||||
ApiEnvelope<PageResult<Product>> | PageResult<Product>
|
||||
>('/api/product/list', {
|
||||
key: `product-list-${categoryIds.value ?? navigationId.value ?? 'all'}-p${currentPage.value}`,
|
||||
query: {
|
||||
page: currentPage,
|
||||
limit,
|
||||
...(categoryIds.value
|
||||
? { categoryIds: categoryIds.value }
|
||||
: (navigationId.value ? { navigationId: navigationId.value } : {}))
|
||||
},
|
||||
watch: [currentPage, categoryIds, navigationId]
|
||||
})
|
||||
|
||||
const products = computed<Product[]>(() => {
|
||||
const envelope = data.value as ApiEnvelope<PageResult<Product>>
|
||||
const direct = data.value as PageResult<Product>
|
||||
return envelope?.data?.list || direct?.list || []
|
||||
})
|
||||
|
||||
const totalCount = computed(() => {
|
||||
const envelope = data.value as ApiEnvelope<PageResult<Product>>
|
||||
const direct = data.value as PageResult<Product>
|
||||
return envelope?.data?.count || envelope?.data?.total || direct?.count || direct?.total || 0
|
||||
})
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(totalCount.value / limit)))
|
||||
|
||||
// 切换栏目时回到第 1 页
|
||||
watch([categoryIds, navigationId], () => {
|
||||
currentPage.value = 1
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,14 @@
|
||||
/* 模板 4 主题变量 - 黑金高端工业风 */
|
||||
[data-template-id="template-04"] {
|
||||
--t4-primary: #d4af37;
|
||||
--t4-primary-light: #e6c35a;
|
||||
--t4-primary-dark: #b8962e;
|
||||
--t4-dark: #1a1a1a;
|
||||
--t4-dark-light: #222222;
|
||||
--t4-dark-lighter: #333333;
|
||||
--t4-text: #f5f5f5;
|
||||
--t4-text-secondary: #a0a0a0;
|
||||
--t4-bg: #0f0f0f;
|
||||
--t4-bg-gray: #161616;
|
||||
--t4-footer-bg: #111111;
|
||||
}
|
||||
Reference in New Issue
Block a user