11import React from 'react'
2- import { forEach , clone , pluck } from 'ramda '
2+ import TimeAgo from 'timeago-react '
33
44import type { TComment } from '@/spec'
55
66import ImgFallback from '@/components/ImgFallback'
7- import AvatarsRow from '@/components/AvatarsRow'
87import DotDivider from '@/components/DotDivider'
98
109import {
1110 Wrapper ,
1211 FloorNum ,
12+ CreateDate ,
1313 Avatar ,
1414 HeaderBaseInfo ,
15- CommentUserName ,
16- CommentHeaderFirst ,
17- ReplyUsers ,
18- ReplyTitle ,
15+ BaseInfo ,
16+ UserName ,
17+ AuthorTag ,
18+ ShortIntro ,
1919} from '../styles/comment/header'
2020
21- import { previewReply } from '../logic'
22-
23- const getAuthors = ( comment ) => {
24- /* eslint-disable no-return-assign */
25- const replies = forEach ( ( reply ) => {
26- /* @ts -ignore */
27- return ( reply . author . extraId = reply . id )
28- } , clone ( comment . replies ) )
29- /* eslint-enable */
30-
31- /* @ts -ignore */
32- return pluck ( 'author' , replies )
33- }
34-
3521type TProps = {
3622 data : TComment
3723}
@@ -44,23 +30,18 @@ const CommentHeader: React.FC<TProps> = ({ data }) => {
4430 fallback = { < ImgFallback user = { data . author } size = { 22 } right = { 10 } /> }
4531 />
4632 < HeaderBaseInfo >
47- < CommentHeaderFirst >
48- < CommentUserName >
49- { data . author . nickname }
50- < DotDivider radius = { 3 } space = { 10 } />
51- < FloorNum > #{ data . floor } </ FloorNum >
52- </ CommentUserName >
53- { data . repliesCount !== 0 && (
54- < ReplyUsers >
55- < ReplyTitle > 收到回复:</ ReplyTitle >
56- < AvatarsRow
57- users = { getAuthors ( data ) }
58- onUserSelect = { previewReply }
59- total = { data . repliesCount }
60- />
61- </ ReplyUsers >
62- ) }
63- </ CommentHeaderFirst >
33+ < BaseInfo >
34+ < UserName >
35+ < div > { data . author . nickname } </ div >
36+ < AuthorTag > 作者</ AuthorTag >
37+ </ UserName >
38+ < FloorNum > #{ data . floor } </ FloorNum >
39+ < DotDivider radius = { 3 } space = { 10 } />
40+ < CreateDate >
41+ < TimeAgo datetime = { data . insertedAt } locale = "zh_CN" />
42+ </ CreateDate >
43+ </ BaseInfo >
44+ < ShortIntro > 1 号员工 / CEO at coderplanets</ ShortIntro >
6445 </ HeaderBaseInfo >
6546 </ Wrapper >
6647 )
0 commit comments