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
+132
View File
@@ -0,0 +1,132 @@
import type { Article, Product, CaseItem, ApiEnvelope, PageResult } from '~/types'
/**
* CMS 数据请求
* 封装文章、产品、案例等数据的获取逻辑
* 代理接口统一在 server/api/ 下
*/
export function useCms() {
/**
* 文章列表
* @param params.navigationId 导航栏目ID(从 getSiteInfo 的 topNavs 获取)
* @param params.page 页码
* @param params.limit 每页条数
* @param params.keywords 搜索关键词
*/
async function fetchArticles(params?: {
navigationId?: number
categoryId?: number
page?: number
limit?: number
keywords?: string
}) {
const res = await $fetch<ApiEnvelope<PageResult<Article>> | PageResult<Article>>(
'/api/article/list',
{ query: params }
)
const envelope = res as ApiEnvelope<PageResult<Article>>
if (envelope?.data) {
return envelope.data
}
return res as PageResult<Article>
}
/** 文章详情 */
async function fetchArticleDetail(id: string | number) {
const res = await $fetch<ApiEnvelope<Article> | Article>('/api/article/detail', {
query: { id }
})
const envelope = res as ApiEnvelope<Article>
return envelope?.data || (res as Article)
}
/**
* 根据导航模型获取文章列表
* model=article 的导航直接用 navigationId 查询
*/
async function fetchArticlesByNav(navigationId: number, page = 1, limit = 10) {
return fetchArticles({ navigationId, page, limit })
}
/** 产品列表 */
async function fetchProducts(params?: {
categoryId?: number
navigationId?: number
page?: number
limit?: number
keywords?: string
}) {
const res = await $fetch<ApiEnvelope<PageResult<Product>> | PageResult<Product>>(
'/api/product/list',
{ query: params }
)
const envelope = res as ApiEnvelope<PageResult<Product>>
if (envelope?.data) {
return envelope.data
}
return res as PageResult<Product>
}
/** 产品详情 */
async function fetchProductDetail(id: string | number) {
const res = await $fetch<ApiEnvelope<Product> | Product>('/api/product/detail', {
query: { id }
})
const envelope = res as ApiEnvelope<Product>
return envelope?.data || (res as Product)
}
/** 案例列表 */
async function fetchCases(params?: {
categoryId?: number
navigationId?: number
page?: number
limit?: number
}) {
const res = await $fetch<ApiEnvelope<PageResult<CaseItem>> | PageResult<CaseItem>>(
'/api/case/list',
{ query: params }
)
const envelope = res as ApiEnvelope<PageResult<CaseItem>>
if (envelope?.data) {
return envelope.data
}
return res as PageResult<CaseItem>
}
/** 案例详情 */
async function fetchCaseDetail(id: string | number) {
const res = await $fetch<ApiEnvelope<CaseItem> | CaseItem>('/api/case/detail', {
query: { id }
})
const envelope = res as ApiEnvelope<CaseItem>
return envelope?.data || (res as CaseItem)
}
/** 提交表单/留言 */
async function submitForm(data: Record<string, unknown>) {
const res = await $fetch<ApiEnvelope>('/api/form/submit', {
method: 'POST',
body: data
})
return res
}
return {
fetchArticles,
fetchArticleDetail,
fetchArticlesByNav,
fetchProducts,
fetchProductDetail,
fetchCases,
fetchCaseDetail,
submitForm
}
}