帖子详情页面正常显示时间
Change-Id: I09c71ee2ae69313a1049ea888b9a9336cfc719ff
diff --git a/Merge/front/src/components/PostDetailJWLLL.jsx b/Merge/front/src/components/PostDetailJWLLL.jsx
index cc5eb96..adc2a0c 100644
--- a/Merge/front/src/components/PostDetailJWLLL.jsx
+++ b/Merge/front/src/components/PostDetailJWLLL.jsx
@@ -6,6 +6,7 @@
import FollowButton from './FollowButton'
import postsAPI from '../api/posts_api'
import '../style/PostDetail.css'
+import dayjs from 'dayjs'
export default function PostDetail() {
const { id } = useParams()
@@ -239,7 +240,7 @@
<div className="author-details">
<span className="author-name">{authorInfo?.username || authorInfo?.nickname || post.author || '匿名用户'}</span>
<span className="post-date">
- {post.create_time ? new Date(post.create_time).toLocaleDateString('zh-CN') : '未知时间'}
+ {post.created_at ? dayjs(post.created_at).format('YYYY-MM-DD HH:mm:ss') : '未知时间'}
</span>
{/* 关注按钮 */}
{post.user_id && (
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..8155ec5
--- /dev/null
+++ b/package.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "dayjs": "^1.11.13"
+ }
+}