diff --git a/src/components/Header/DropdownMessage.tsx b/src/components/Header/DropdownMessage.tsx index 9b34c7e..3e9a950 100644 --- a/src/components/Header/DropdownMessage.tsx +++ b/src/components/Header/DropdownMessage.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import ClickOutside from '../ClickOutside'; @@ -7,9 +7,23 @@ import UserTwo from '../../images/user/user-02.png'; import UserThree from '../../images/user/user-03.png'; import UserFour from '../../images/user/user-04.png'; +import { getCommentListAPI } from '@/api/Comment' +import { Comment } from '@/types/comment'; + const DropdownMessage = () => { const [dropdownOpen, setDropdownOpen] = useState(false); const [notifying, setNotifying] = useState(true); + const [commentList, setCommentList] = useState([]); + + // 获取评论列表 + const getCommentList = async () => { + const { data } = await getCommentListAPI() + setCommentList(data as Comment[]) + } + + useEffect(() => { + getCommentList() + }, []) return ( setDropdownOpen(false)} className="relative"> @@ -23,9 +37,8 @@ const DropdownMessage = () => { to="#" > @@ -57,110 +70,39 @@ const DropdownMessage = () => { - {/* */} {dropdownOpen && (
-
Messages
+
最新评论
    -
  • - -
    - User -
    + {commentList.map(item => ( +
  • + +
    + User +
    -
    -
    - Mariya Desoja -
    -

    I like your confidence 💪

    -

    2min ago

    -
    - -
  • -
  • - -
    - User -
    +
    +
    + {item.name} +
    -
    -
    - Robert Jhon -
    -

    Can you share your offer?

    -

    10min ago

    -
    - -
  • -
  • - -
    - User -
    - -
    -
    - Henry Dholi -
    -

    I cam across your profile and...

    -

    1day ago

    -
    - -
  • -
  • - -
    - User -
    - -
    -
    - Cody Fisher -
    -

    I’m waiting for you response!

    -

    5days ago

    -
    - -
  • -
  • - -
    - User -
    - -
    -
    - Mariya Desoja -
    -

    I like your confidence 💪

    -

    2min ago

    -
    - -
  • +

    {item.content}

    +

    {item.createTime}

    +
+ + + ))} )} - {/* */}
); diff --git a/src/pages/Comment/index.tsx b/src/pages/Comment/index.tsx index a3a8860..bb2e8dd 100644 --- a/src/pages/Comment/index.tsx +++ b/src/pages/Comment/index.tsx @@ -15,12 +15,6 @@ const CommentPage = () => { const [isModalOpen, setIsModalOpen] = useState(false); - // const loadingFn = async (callback: () => void) => { - // setLoading(true) - // await callback() - // setLoading(false) - // } - const getCommentList = async () => { const { data } = await getCommentListAPI(); setList(data as Comment[]) @@ -136,6 +130,7 @@ const CommentPage = () => { rowKey="id" dataSource={list} columns={columns} + expandable={{ defaultExpandAllRows: true }} scroll={{ x: 'max-content' }} pagination={{ position: ['bottomCenter'], diff --git a/src/types/Comment.d.ts b/src/types/Comment.d.ts index c81a481..12df27b 100644 --- a/src/types/Comment.d.ts +++ b/src/types/Comment.d.ts @@ -9,7 +9,7 @@ export interface Comment { articleTitle: number, commentId: number, auditStatus: number - createTime: Date, + createTime: string, } export interface Info {