2b69686795
- 新增404页面,优化未找到页面体验,避免被搜索引擎索引 - 增加文件代理接口,隐藏真实文件服务器地址,支持文件请求代理 - 实现/article、/case、/product及/page动态路由兼容列表与详情展示 - 添加动态CMS页面兼容入口处理旧式路径,统一路由与SEO设置 - 新增模板1、模板7、模板2、模板3关于我们页面,实现多模板支持 - 模板增强支持CMS单页内容加载及SEO信息动态设置 - 配置环境变量及Git忽略文件规则辅助开发和构建环境管理
54 lines
1.3 KiB
Vue
54 lines
1.3 KiB
Vue
<template>
|
||
<div>
|
||
<Component :is="templatePage" v-if="templatePage" />
|
||
<SiteLoading v-else />
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
/**
|
||
* 动态 CMS 页面路由(兼容入口)
|
||
* CMS 导航主要使用 /page/:id, /article/:id, /product/:id 格式
|
||
* 此路由作为兼容入口,处理旧式路径如 /about, /services 等
|
||
*/
|
||
const route = useRoute()
|
||
const slug = route.params.slug as string
|
||
|
||
const { loadTemplate } = useTemplate()
|
||
const { siteInfo, siteName, navigations, fetchSiteInfo } = useSite()
|
||
|
||
await fetchSiteInfo()
|
||
|
||
const templatePage = shallowRef<Component | null>(null)
|
||
|
||
|
||
// 同步加载当前模板(SSR/客户端路由切换均直接 await,避免先闪 SiteLoading)
|
||
const components = await loadTemplate()
|
||
templatePage.value = components?.Page || null
|
||
|
||
|
||
// 尝试从导航中匹配 slug
|
||
const matchedNav = computed(() => {
|
||
const navs = navigations.value || []
|
||
const findNav = (items: any[]): any => {
|
||
for (const item of items) {
|
||
if (item.path === `/${slug}` || item.code === slug) return item
|
||
if (item.children?.length) {
|
||
const found = findNav(item.children)
|
||
if (found) return found
|
||
}
|
||
}
|
||
return null
|
||
}
|
||
return findNav(navs)
|
||
})
|
||
|
||
usePageSeo(
|
||
{
|
||
title: matchedNav.value?.title || slug,
|
||
path: `/${slug}`
|
||
},
|
||
siteInfo.value
|
||
)
|
||
</script>
|