diff --git a/src/components/YearPicker/index.tsx b/src/components/YearPicker/index.tsx
index dfb03fd..361da94 100644
--- a/src/components/YearPicker/index.tsx
+++ b/src/components/YearPicker/index.tsx
@@ -1,5 +1,6 @@
import { useState, useEffect, useRef } from "react";
import styles from "./YearPicker.module.css";
+import { useStore } from "@/store";
export type YearPickerProps = {
value?: number | null;
@@ -26,6 +27,7 @@ export default function YearPicker({
className,
disabled = false,
}: YearPickerProps) {
+ const locale = useStore((s) => s.locale);
const [open, setOpen] = useState(false);
const [decadeStart, setDecadeStart] = useState(() =>
getDecadeStart(value ?? currentYear)
@@ -91,7 +93,7 @@ export default function YearPicker({
}}
>
- {value != null ? `${value}年` : placeholder}
+ {value != null ? `${value}${locale === "zh-CN" ? "年" : ""}` : placeholder}

diff --git a/src/components/layout/Article/index.module.css b/src/components/layout/Article/index.module.css
index 6531980..80e9139 100644
--- a/src/components/layout/Article/index.module.css
+++ b/src/components/layout/Article/index.module.css
@@ -60,6 +60,14 @@
padding: 30px 0;
display: flex;
justify-content: space-between;
+
+ & > div {
+ cursor: pointer;
+ }
+ }
+
+ .articleBottomLineNone {
+ border: none;
}
}
diff --git a/src/components/layout/Article/index.tsx b/src/components/layout/Article/index.tsx
index b6570c4..0cf01ce 100644
--- a/src/components/layout/Article/index.tsx
+++ b/src/components/layout/Article/index.tsx
@@ -1,5 +1,6 @@
import styles from "./index.module.css";
import { dateFormat } from "@/utils";
+import { useStore } from "@/store";
type Data = {
title: string;
@@ -18,27 +19,39 @@ export default function Article({ data, prevItem, nextItem, setDetailId }: {
prevItem?: Item, nextItem?: Item,
setDetailId: (id: number) => void,
}) {
+ const appConfig = useStore((s) => s.appConfig);
+ const {
+ back = "返回",
+ publishTime = "发布时间",
+ readTimes = "阅读次数",
+ prevArticle = "上一篇",
+ nextArticle = "下一篇",
+ } = appConfig?.__global__?.others || {};
return (
window.history.back()}>

-
返回
+
{back}
{data.title}
- 发布时间:{dateFormat(data.createTime, 'yyyy-MM-dd')}
- 阅读次数:{data.readTimes}
+ {publishTime}:{dateFormat(data.createTime, 'yyyy-MM-dd')}
+ {readTimes}:{data.readTimes}
-
- {prevItem &&
setDetailId(prevItem.id)}>上一篇:{prevItem.title}
}
- {nextItem &&
setDetailId(nextItem.id)}>下一篇:{nextItem.title}
}
+
+
+ {prevItem &&
setDetailId(prevItem.id)}>{prevArticle}:{prevItem.title}
}
+
+
+ {nextItem &&
setDetailId(nextItem.id)}>{nextArticle}:{nextItem.title}
}
+
)
diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx
index 756ad9c..f0726ae 100644
--- a/src/pages/Home/index.tsx
+++ b/src/pages/Home/index.tsx
@@ -22,6 +22,7 @@ export default function Home() {
const banner = home?.banner;
const section1Data = home?.section1Data;
const section2Data = home?.section2Data ?? null;
+ const section3Data = home?.section3Data ?? null;
if (!home) return null;
@@ -75,13 +76,13 @@ export default function Home() {
-
+
);
}
-function News() {
+function News({data}: any) {
const locale = useStore((s) => s.locale);
const categoryList = useStore((s) => s.categoryList);
const [newsData, setNewsData] = useState([]);
@@ -130,7 +131,7 @@ function News() {
handleSearch(category_id)
}, [])
return (
-
+
diff --git a/src/pages/News/Detail.tsx b/src/pages/News/Detail.tsx
index c09d08e..ee8a32c 100644
--- a/src/pages/News/Detail.tsx
+++ b/src/pages/News/Detail.tsx
@@ -33,7 +33,8 @@ export default function NewsDetail() {
readTimes: item.count,
content: item.content,
lang: item.lang,
- category_id: item.category_id
+ category_id: item.category_id,
+ category_name: item.category_name
}
})
setNewsDetailList(data)
@@ -41,25 +42,54 @@ export default function NewsDetail() {
}
}, [])
+ const [preList, setPreList] = useState
([])
+ const [nextList, setNextList] = useState([])
+
+ const preItem = useMemo(() => {
+ return preList.find((item) => item.lang.toLowerCase() === locale.split('-')[0])
+ }, [preList, locale])
+ const nextItem = useMemo(() => {
+ return nextList.find((item) => item.lang.toLowerCase() === locale.split('-')[0])
+ }, [nextList, locale])
+
const getNewsSiblings = useCallback((id: string | number, category_id: string | number) => {
appApi.getNewsSiblings({ id, category_id }).then((res) => {
- console.log(res)
+ const pList: any[] = []
+ const nList: any[] = []
+ res.data.forEach((item: any) => {
+ if (item.id < id) {
+ pList.push(item)
+ } else if (item.id > id) {
+ nList.push(item)
+ }
+ })
+ setPreList(pList)
+ setNextList(nList)
})
}, [])
- useEffect(() => {
- getNewsDetail(id).then((data) => {
- if(data && data.length > 0) {
- const id = data[0].id
- const category_id = data[0].category_id
- getNewsSiblings(id, category_id)
+
+ const getAllData = useCallback(async (id: string | number) => {
+ const data = await getNewsDetail(id)
+ if (data && data.length > 0) {
+ const id = data[0].id
+ const category_id = data[0].category_id;
+ if(data[0].category_name !== "【集团发布】") {
+ return
}
- })
+ await getNewsSiblings(id, category_id)
+ }
+ }, [])
+
+ useEffect(() => {
+ getAllData(id)
}, [id])
return (
- {newsDetail &&
getNewsDetail(id)} />}
+ {newsDetail && getAllData(id)}
+ prevItem={preItem} nextItem={nextItem}
+ />}
);
}