2b69686795
- 新增404页面,优化未找到页面体验,避免被搜索引擎索引 - 增加文件代理接口,隐藏真实文件服务器地址,支持文件请求代理 - 实现/article、/case、/product及/page动态路由兼容列表与详情展示 - 添加动态CMS页面兼容入口处理旧式路径,统一路由与SEO设置 - 新增模板1、模板7、模板2、模板3关于我们页面,实现多模板支持 - 模板增强支持CMS单页内容加载及SEO信息动态设置 - 配置环境变量及Git忽略文件规则辅助开发和构建环境管理
28 lines
888 B
TypeScript
28 lines
888 B
TypeScript
import { defineEventHandler } from 'h3'
|
||
import { useRuntimeConfig } from '#imports'
|
||
import { getTenantFromContext } from '../../utils/tenant'
|
||
import { getAppProductById } from '../../utils/app'
|
||
import type { TenantContext } from '~/app/types'
|
||
|
||
/**
|
||
* 获取当前应用信息
|
||
* GET /api/app/info
|
||
*
|
||
* 优先返回中间件已识别的 AppProduct(event.context.tenant.appProduct)
|
||
* 若中间件未查到(异常降级),则用 appId 实时补查
|
||
*/
|
||
export default defineEventHandler(async (event) => {
|
||
const config = useRuntimeConfig()
|
||
const ctx = getTenantFromContext(event, config)
|
||
const tenant = event.context?.tenant as TenantContext | undefined
|
||
|
||
// 中间件已查到直接返回
|
||
if (tenant?.appProduct) {
|
||
return tenant.appProduct
|
||
}
|
||
|
||
// 兜底:实时查询
|
||
const appProduct = await getAppProductById(ctx.appId, config)
|
||
return appProduct || null
|
||
})
|