@@ -28,7 +28,7 @@ import {
28
28
import { Operation } from '../../../models/operation'
29
29
import { authAtom } from '../../../store/auth'
30
30
import { formatError } from '../../../utils/error'
31
- import { formatDateTime } from '../../../utils/times'
31
+ import { formatDateTime , formatRelativeTime } from '../../../utils/times'
32
32
import { wrapErrorMessage } from '../../../utils/wrapErrorMessage'
33
33
import { Markdown } from '../../Markdown'
34
34
import { OutlinedIcon } from '../../OutlinedIcon'
@@ -104,9 +104,9 @@ export const CommentArea = withSuspensable(function ViewerComments({
104
104
) ) }
105
105
{ isReachingEnd && comments . length === 0 && (
106
106
< NonIdealState
107
- icon = "slash "
108
- title = "没有找到任何作业 "
109
- description = "(つД`)・゚・ "
107
+ icon = "comment "
108
+ title = "还没有评论,发一条评论鼓励作者吧! "
109
+ description = "(。・ω・。)ノ♡ "
110
110
/>
111
111
) }
112
112
@@ -141,15 +141,10 @@ const MainComment = ({
141
141
comment : MainCommentInfo
142
142
children ?: ReactNode
143
143
} ) => {
144
- const { uploader, uploadTime } = comment
145
-
146
144
return (
147
145
< Card className = { clsx ( className ) } >
148
- < div className = "" >
149
- < div className = "mb-2 flex text-slate-500" >
150
- < div className = "font-bold mr-2" > { uploader } </ div >
151
- < div > { formatDateTime ( uploadTime ) } </ div >
152
- </ div >
146
+ < div >
147
+ < CommentHeader comment = { comment } />
153
148
< CommentContent comment = { comment } />
154
149
< CommentActions comment = { comment } />
155
150
</ div >
@@ -167,14 +162,9 @@ const SubComment = ({
167
162
comment : SubCommentInfo
168
163
fromComment ?: SubCommentInfo
169
164
} ) => {
170
- const { uploader, uploadTime } = comment
171
-
172
165
return (
173
166
< div className = { clsx ( className , 'pl-8' ) } >
174
- < div className = "mb-2 flex text-slate-500" >
175
- < div className = "font-bold mr-2" > { uploader } </ div >
176
- < div > { formatDateTime ( uploadTime ) } </ div >
177
- </ div >
167
+ < CommentHeader comment = { comment } />
178
168
{ comment . deleted ? (
179
169
< div className = "italic text-gray-500" > (已删除)</ div >
180
170
) : (
@@ -197,6 +187,27 @@ const SubComment = ({
197
187
)
198
188
}
199
189
190
+ const CommentHeader = ( {
191
+ className,
192
+ comment : { uploader, uploaderId, uploadTime } ,
193
+ } : {
194
+ className ?: string
195
+ comment : CommentInfo
196
+ } ) => {
197
+ const [ { userId } ] = useAtom ( authAtom )
198
+
199
+ return (
200
+ < div className = { clsx ( className , 'mb-2 flex items-center text-xs' ) } >
201
+ < div className = { clsx ( 'mr-2' , userId === uploaderId && 'font-bold' ) } >
202
+ { uploader }
203
+ </ div >
204
+ < div className = "text-slate-500" title = { formatDateTime ( uploadTime ) } >
205
+ { formatRelativeTime ( uploadTime ) }
206
+ </ div >
207
+ </ div >
208
+ )
209
+ }
210
+
200
211
const CommentContent = ( {
201
212
className,
202
213
comment : { message } ,
0 commit comments