This commit is contained in:
parent
9e57ea1b9f
commit
708d8afdd9
|
|
@ -1,16 +1,16 @@
|
||||||
.article {
|
.article {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 100vh;
|
/* min-height: 100vh; */
|
||||||
padding: 7.5rem 0;
|
padding: 7.5rem 0;
|
||||||
|
|
||||||
.articleHeaderLine, .articleHeader, .articleContent {
|
.articleHeaderLine, .articleHeader, .articleContent, .articleBottomLine {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.articleHeaderLine {
|
.articleHeaderLine {
|
||||||
height: 6.25rem;
|
height: 6.25rem;
|
||||||
border-bottom: .0625rem solid #222222;
|
border-bottom: 1px solid #222222;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
.articleHeaderLineBack {
|
.articleHeaderLineBack {
|
||||||
|
|
@ -51,5 +51,14 @@
|
||||||
|
|
||||||
.articleContent {
|
.articleContent {
|
||||||
font-size: 1.25rem;
|
font-size: 1.25rem;
|
||||||
|
min-height: 50vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.articleBottomLine {
|
||||||
|
border-top: 1px solid #222222;
|
||||||
|
margin-top: 9.375rem;
|
||||||
|
padding: 30px 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
import { dateFormat } from "@/utils";
|
||||||
|
|
||||||
type Data = {
|
type Data = {
|
||||||
title: string;
|
title: string;
|
||||||
|
|
@ -8,7 +8,16 @@ type Data = {
|
||||||
content: string;
|
content: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Article({ data }: { data: Data }) {
|
type Item = {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Article({ data, prevItem, nextItem, setDetailId }: {
|
||||||
|
data: Data,
|
||||||
|
prevItem?: Item, nextItem?: Item,
|
||||||
|
setDetailId: (id: number) => void,
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className={styles.article}>
|
<div className={styles.article}>
|
||||||
<div className={styles.articleHeaderLine}>
|
<div className={styles.articleHeaderLine}>
|
||||||
|
|
@ -20,13 +29,17 @@ export default function Article({ data }: { data: Data }) {
|
||||||
<div className={styles.articleHeader}>
|
<div className={styles.articleHeader}>
|
||||||
<div className={styles.articleHeaderTitle}>{data.title}</div>
|
<div className={styles.articleHeaderTitle}>{data.title}</div>
|
||||||
<div className={styles.articleHeaderTimeLine}>
|
<div className={styles.articleHeaderTimeLine}>
|
||||||
<span className={styles.articleHeaderTime}>发布时间:{data.createTime}</span>
|
<span className={styles.articleHeaderTime}>发布时间:{dateFormat(data.createTime, 'yyyy-MM-dd')}</span>
|
||||||
<span className={styles.articleHeaderReadTimes}>阅读次数:{data.readTimes}</span>
|
<span className={styles.articleHeaderReadTimes}>阅读次数:{data.readTimes}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.articleContent}>
|
<div className={styles.articleContent}>
|
||||||
<div className={styles.articleContentText} dangerouslySetInnerHTML={{ __html: data.content }}></div>
|
<div className={styles.articleContentText} dangerouslySetInnerHTML={{ __html: data.content }}></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className={styles.articleBottomLine}>
|
||||||
|
{prevItem && <div onClick={() => setDetailId(prevItem.id)}>上一篇:{prevItem.title}</div>}
|
||||||
|
{nextItem && <div onClick={() => setDetailId(nextItem.id)}>下一篇:{nextItem.title}</div>}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -209,6 +209,7 @@
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.searchBtn {
|
.searchBtn {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
import Article from "@/components/layout/Article";
|
import Article from "@/components/layout/Article";
|
||||||
import { useStore } from "@/store";
|
import { useStore } from "@/store";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import appApi from "@/api/app";
|
import appApi from "@/api/app";
|
||||||
|
|
||||||
type NewsDetail = {
|
type NewsDetail = {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
|
|
@ -23,8 +22,8 @@ export default function NewsDetail() {
|
||||||
return newsDetailList?.find((item) => item.lang.toLowerCase() === locale.split('-')[0]);
|
return newsDetailList?.find((item) => item.lang.toLowerCase() === locale.split('-')[0]);
|
||||||
}, [newsDetailList, locale]);
|
}, [newsDetailList, locale]);
|
||||||
|
|
||||||
useEffect(() => {
|
const getNewsDetail = useCallback((id: string | number) => {
|
||||||
appApi.getNewsDetail(id).then((res) => {
|
id && appApi.getNewsDetail(id).then((res) => {
|
||||||
const data = res.data.map((item: any) => {
|
const data = res.data.map((item: any) => {
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
|
|
@ -37,12 +36,15 @@ export default function NewsDetail() {
|
||||||
})
|
})
|
||||||
setNewsDetailList(data)
|
setNewsDetailList(data)
|
||||||
})
|
})
|
||||||
}, [id])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getNewsDetail(id)
|
||||||
|
}, [id])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{newsDetail && <Article data={newsDetail} />}
|
{newsDetail && <Article data={newsDetail} setDetailId={(id) => getNewsDetail(id)}/>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import { Link } from "react-router-dom";
|
||||||
import { useStore } from "@/store";
|
import { useStore } from "@/store";
|
||||||
import appApi from "@/api/app";
|
import appApi from "@/api/app";
|
||||||
import ScrollReveal from "@/components/ScrollReveal";
|
import ScrollReveal from "@/components/ScrollReveal";
|
||||||
|
|
||||||
type NewsItem = {
|
type NewsItem = {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ export default function Search() {
|
||||||
size,
|
size,
|
||||||
title: searchKeyword,
|
title: searchKeyword,
|
||||||
category_id: categoryId,
|
category_id: categoryId,
|
||||||
|
sort: "create_time DESC",
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
setSearched(true);
|
setSearched(true);
|
||||||
const data = res.data.items.map((item: any) => {
|
const data = res.data.items.map((item: any) => {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ console.log('isDev', isDev)
|
||||||
module.exports = {
|
module.exports = {
|
||||||
'/companyHome': {
|
'/companyHome': {
|
||||||
target: isDev === 'true' ? 'http://10.3.0.7:9999/' : 'http://yintai.batiao8.com/',
|
target: isDev === 'true' ? 'http://10.3.0.7:9999/' : 'http://yintai.batiao8.com/',
|
||||||
// target: "http://10.3.0.24:9211/",
|
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/companyHome/, '')
|
rewrite: (path) => path.replace(/^\/companyHome/, '')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
|
|
||||||
|
type Item = {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface AppStoreState {
|
interface AppStoreState {
|
||||||
screenOpened: boolean;
|
screenOpened: boolean;
|
||||||
setScreenOpened: (screenOpened: boolean) => void;
|
setScreenOpened: (screenOpened: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useAppStore = create<AppStoreState>()(
|
export const useAppStore = create<AppStoreState>()(set => ({
|
||||||
(set) => ({
|
screenOpened: false,
|
||||||
screenOpened: false,
|
setScreenOpened: (screenOpened) => set({ screenOpened }),
|
||||||
setScreenOpened: (screenOpened) => set({ screenOpened }),
|
}));
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ interface StoreState {
|
||||||
type: string;
|
type: string;
|
||||||
}[] | null;
|
}[] | null;
|
||||||
supportLocales: SupportLocale[];
|
supportLocales: SupportLocale[];
|
||||||
token: string | null;
|
token: string | null;
|
||||||
setLocale: (locale: LocaleKey) => void;
|
setLocale: (locale: LocaleKey) => void;
|
||||||
setAppConfig: (data: I18nData) => void;
|
setAppConfig: (data: I18nData) => void;
|
||||||
setCategoryList: (list: any[]) => void;
|
setCategoryList: (list: any[]) => void;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue