-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,264 additions
and
2,351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { create } from 'zustand'; | ||
|
||
export const useStore = create(() => ({ | ||
user: null, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import styles from '../../index.module.scss'; | ||
import Layout from '../../../Layout'; | ||
import CommentList from '../CommentList'; | ||
import WriteComment from '../WriteComment'; | ||
import { useSWR } from '@/hooks'; | ||
import TopTip from '../../../home/components/TopTip'; | ||
import TopicItem from '../TopicItem'; | ||
import { useParams } from 'next/navigation'; | ||
|
||
export default function Post({ data }) { | ||
const { id } = useParams(); | ||
const _data = data?.data; | ||
const resPostData = useSWR({ | ||
url: '/api/v1/post-comments', | ||
params: { | ||
postId: id, | ||
}, | ||
}); | ||
return ( | ||
<Layout> | ||
<div className={styles.wrap}> | ||
<TopTip></TopTip> | ||
{_data && <TopicItem item={_data}></TopicItem>} | ||
<div className={styles.inner}> | ||
<WriteComment postId={Number(id)}></WriteComment> | ||
<CommentList postId={Number(id)} items={resPostData?.data?.data ?? []}></CommentList> | ||
</div> | ||
</div> | ||
</Layout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,15 @@ | ||
'use client'; | ||
// 'use client'; | ||
|
||
import React, { useState } from 'react'; | ||
import styles from './index.module.scss'; | ||
import Layout from '../Layout'; | ||
import { Button, Space, Image, Tag } from 'antd'; | ||
import CommentList from './components/CommentList'; | ||
import { useRouter } from 'next/navigation'; | ||
import WriteComment from './components/WriteComment'; | ||
import { useSWR } from '@/hooks'; | ||
import LikeButton from '../LikeButton'; | ||
import classNames from 'classnames'; | ||
import { CommentOutlined } from '@ant-design/icons'; | ||
import CollectButton from '../CollectButton'; | ||
import FollowButton from '../FollowButton'; | ||
import dynamic from 'next/dynamic'; | ||
import axios from '@/libs/axios'; | ||
import Link from 'next/link'; | ||
import { parseTime } from '@/libs/time'; | ||
import TopTip from '../home/components/TopTip'; | ||
import PinnedList from '../home/components/PinnedList'; | ||
import CategoryList from '../home/components/CategoryList'; | ||
import TopicItem from './components/TopicItem'; | ||
import { useParams } from 'next/navigation'; | ||
import Post from './components/Post'; | ||
|
||
const CImage: any = dynamic(() => import('../home/components/TopicItem/components/CImage') as any, { | ||
ssr: false, | ||
}); | ||
|
||
export default function Post(props) { | ||
const { id } = useParams(); | ||
const router = useRouter(); | ||
const url = '/api/v1/posts/' + id; | ||
const { data: newData = {} } = useSWR({ url }); | ||
const data = newData?.data ?? {}; | ||
const [open, setOpen] = useState(false); | ||
const resPostData = useSWR({ | ||
url: '/api/v1/post-comments', | ||
params: { | ||
postId: id, | ||
}, | ||
}); | ||
return ( | ||
<Layout> | ||
<div className={styles.wrap}> | ||
<TopTip></TopTip> | ||
{/* <PinnedList></PinnedList> */} | ||
{/* <CategoryList></CategoryList> */} | ||
<TopicItem item={data} key={data.id}></TopicItem> | ||
<div className={styles.inner}> | ||
<WriteComment postId={Number(id)}></WriteComment> | ||
<CommentList postId={Number(id)} items={resPostData?.data?.data ?? []}></CommentList> | ||
</div> | ||
</div> | ||
</Layout> | ||
); | ||
} | ||
|
||
export async function getServerSideProps(context) { | ||
const { query } = context; | ||
const { id } = query as any; | ||
const Index = async (props: { params: any }) => { | ||
const { id } = props.params; | ||
const url = '/api/v1/posts/' + id; | ||
const post = await axios.get(url).then((res) => res.data); | ||
return { | ||
props: { | ||
data: post, | ||
}, | ||
}; | ||
} | ||
const data = await axios | ||
.get(url) | ||
.then((res) => res.data) | ||
.catch((err) => {}); | ||
return <Post data={data}></Post>; | ||
}; | ||
export default Index; |
Oops, something went wrong.