diff --git a/空气质量预测/源码/用户端/iapip-web/.umirc.ts b/空气质量预测/源码/用户端/iapip-web/.umirc.ts index dab16d1..7ce46e1 100644 --- a/空气质量预测/源码/用户端/iapip-web/.umirc.ts +++ b/空气质量预测/源码/用户端/iapip-web/.umirc.ts @@ -57,6 +57,18 @@ export default defineConfig({ component: './forum/thread', layout: false }, + { + name: '科普文章', + path: '/articles', + component: './articles', + layout: false + }, + { + name: '文章详情', + path: '/article/:id', + component: './article', + layout: false + }, { path: '/', redirect: '/landing' diff --git a/空气质量预测/源码/用户端/iapip-web/src/pages/article/index.tsx b/空气质量预测/源码/用户端/iapip-web/src/pages/article/index.tsx new file mode 100644 index 0000000..9c5a8ae --- /dev/null +++ b/空气质量预测/源码/用户端/iapip-web/src/pages/article/index.tsx @@ -0,0 +1,43 @@ +import { history, useParams } from '@umijs/max' +import { getArticle } from '@/common/articles' + +export default function ArticleDetail() { + const { id } = useParams<{ id: string }>() + const article = id ? getArticle(id) : undefined + + if (!article) { + return ( +
+

文章不存在或已下线。

+ history.push('/landing')} style={{ color: '#B43533' }}>← 返回首页 +
+ ) + } + + return ( +
+ history.push('/landing')} style={{ color: '#888' }}>← 返回首页 +
+
{article.tag} · {article.date}
+

{article.title}

+

{article.summary}

+
+ {article.body.map((sec, i) => ( +
+ {sec.heading &&

{sec.heading}

} + {sec.paragraphs.map((p, j) => ( +

{p}

+ ))} +
+ ))} + {article.sources && article.sources.length > 0 && ( +
+
参考来源
+ +
+ )} +
+ ) +}