diff --git a/app/components/RichText.vue b/app/components/RichText.vue new file mode 100644 index 0000000..f98388d --- /dev/null +++ b/app/components/RichText.vue @@ -0,0 +1,134 @@ + + + + {{ text }} + + + + + + diff --git a/app/pages/article/[id].vue b/app/pages/article/[id].vue new file mode 100644 index 0000000..791bc71 --- /dev/null +++ b/app/pages/article/[id].vue @@ -0,0 +1,193 @@ + + + + + + 首页 + + 栏目 + {{ navTitle }} + + + + + + {{ navTitle }} + {{ navDescription }} + + + + + + + + 搜索 + 刷新 + + + + + + + + + + + {{ item.title }} + + {{ item?.title }} + + + + 发布时间:{{ item.createTime }} + 作者:{{ item.author }} + 来源:{{ item.source }} + 阅读:{{ item.actualViews }} + + + + + + + + {{ item.overview }} + + + + + + + + + + + + + + + + + + + + diff --git a/app/pages/item/[id].vue b/app/pages/item/[id].vue new file mode 100644 index 0000000..9c417c8 --- /dev/null +++ b/app/pages/item/[id].vue @@ -0,0 +1,125 @@ + + + + + + 首页 + + + 文章 + + + + {{ article.categoryName || '栏目' }} + + + {{ articleTitle }} + + + + + + + + + + + + {{ articleTitle }} + + + 栏目:{{ article.categoryName }} + 作者:{{ article.author }} + 发布时间:{{ article.createTime }} + 来源:{{ article.source }} + + + + + + + + + + + + + + + + + diff --git a/app/pages/page/[id].vue b/app/pages/page/[id].vue new file mode 100644 index 0000000..d838f36 --- /dev/null +++ b/app/pages/page/[id].vue @@ -0,0 +1,243 @@ + + + + + + + + + + + + + {{ parentTitle }} + + + {{ parentDescription }} + + + + + + + + + + + {{ n.title || n.label || `栏目 ${n.navigationId}` }} + + + + + + + + + + + + + {{ contentTitle }} + + + 发布时间:{{ articleMeta.createTime }} + 作者:{{ articleMeta.author }} + 来源:{{ articleMeta.source }} + + + + + + + + + + + + + + + + + + diff --git a/server/api/cms-navigation.get.ts b/server/api/cms-navigation.get.ts new file mode 100644 index 0000000..d8a4a80 --- /dev/null +++ b/server/api/cms-navigation.get.ts @@ -0,0 +1,42 @@ +import { $fetch } from 'ofetch' +import { createError, defineEventHandler, getHeader, getQuery } from 'h3' +import { useRuntimeConfig } from '#imports' + +// Frontend-friendly endpoint: +// GET /api/cms-navigation?parentId=xxxx +// Proxies to CMS modules API. Some deployments expose "/cms-navigation", others "/cms/cms-navigation". +export default defineEventHandler(async (event) => { + const config = useRuntimeConfig() + const query = getQuery(event) + const modulesApiBase = + config.public.modulesApiBase || config.public.ApiBase || 'https://cms-api.websoft.top/api' + + const tenantId = + getHeader(event, 'tenantid') || + config.public.tenantId || + config.public.TenantId || + '10586' + const authorization = getHeader(event, 'authorization') + + const headers = { + TenantId: String(tenantId), + ...(authorization ? { Authorization: String(authorization) } : {}) + } + + const upstreamCandidates = ['/cms-navigation', '/cms/cms-navigation'] + let lastError: any + + for (const path of upstreamCandidates) { + try { + return await $fetch(path, { baseURL: modulesApiBase, headers, query }) + } catch (error: any) { + lastError = error + } + } + + throw createError({ + statusCode: lastError?.statusCode || lastError?.response?.status || 502, + statusMessage: lastError?.statusMessage || 'Failed to fetch cms navigation' + }) +}) + diff --git a/server/api/cms/cms-navigation.get.ts b/server/api/cms/cms-navigation.get.ts new file mode 100644 index 0000000..eba9a45 --- /dev/null +++ b/server/api/cms/cms-navigation.get.ts @@ -0,0 +1,2 @@ +export { default } from '../cms-navigation.get' +