Skip to content

Commit 9204566

Browse files
author
awesomeYG
committed
fix: 评论
1 parent 3041876 commit 9204566

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

ui/front/src/app/discusss/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const Page = async (props: { params: Promise<{ id: string }> }) => {
5858
gap={3}
5959
>
6060
<Content data={data}></Content>
61-
<InfoRelevance data={data} />
61+
{/* <InfoRelevance data={data} /> */}
6262
</Stack>
6363
</Box>
6464
);

ui/front/src/app/discusss/[id]/ui/content.tsx

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ const BaseDiscussCard = (props: {
242242
{formatNumber(data.dislike || 0)}
243243
</Typography>
244244
</Stack>
245-
{data.user_id === disData.current_user_id && (
245+
{[data.user_id, disData.user_id].includes(
246+
disData.current_user_id
247+
) && (
246248
<IconButton
247249
sx={{ display: { xs: "none", sm: "flex" } }}
248250
onClick={(e) => {
@@ -356,6 +358,7 @@ const Content = (props: { data: ModelDiscussionDetail }) => {
356358
const [commentIndex, setCommentIndex] = useState<
357359
ModelDiscussionComment | ModelDiscussionReply | null
358360
>(null);
361+
const [mdEditShow, setMdEditShow] = useState(false);
359362
const [historyComment, setHistoryComment] =
360363
useState<SvcCommentUpdateReq | null>(null);
361364
const [editCommentModalVisible, setEditCommentModalVisible] = useState(false);
@@ -374,6 +377,18 @@ const Content = (props: { data: ModelDiscussionDetail }) => {
374377
const handleClose = () => {
375378
setAnchorEl(null);
376379
};
380+
const onCommentSubmit = () => {
381+
postDiscussionDiscIdComment(
382+
{ discId: id },
383+
{
384+
content: comment,
385+
}
386+
).then(() => {
387+
setComment("");
388+
setMdEditShow(false);
389+
router.refresh();
390+
});
391+
};
377392
const onSubmit = (comment: string) => {
378393
// @ts-ignore
379394
return putDiscussionDiscIdCommentCommentId(
@@ -436,7 +451,7 @@ const Content = (props: { data: ModelDiscussionDetail }) => {
436451
{commentIndex?.user_id == data.current_user_id && (
437452
<MenuItem onClick={handleDelete}>删除</MenuItem>
438453
)}
439-
{commentIndex?.user_id == data.current_user_id && !data.accepted && (
454+
{data?.user_id == data.current_user_id && !data.accepted && (
440455
<MenuItem onClick={handleAccept}>采纳</MenuItem>
441456
)}
442457
</Menu>
@@ -458,6 +473,20 @@ const Content = (props: { data: ModelDiscussionDetail }) => {
458473
onOpt={handleClick}
459474
/>
460475
))}
476+
<Card>
477+
<MdEditor style={{ flex: 1 }} value={comment} onChange={setComment} />
478+
<Stack direction="row" justifyContent="flex-end" sx={{ mt: 2 }}>
479+
<LoadingBtn
480+
id="s-captcha-button"
481+
variant="contained"
482+
size="small"
483+
disabled={!comment.trim()}
484+
onClick={onCommentSubmit}
485+
>
486+
发布
487+
</LoadingBtn>
488+
</Stack>
489+
</Card>
461490
</Stack>
462491
);
463492
};

ui/front/src/app/discusss/[id]/ui/titleCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const TitleCard = ({ data }: { data: ModelDiscussionDetail }) => {
3838
},
3939
});
4040
};
41-
41+
console.log(data);
4242
return (
4343
<Card
4444
sx={{
@@ -128,7 +128,7 @@ const TitleCard = ({ data }: { data: ModelDiscussionDetail }) => {
128128
color: "rgba(0,0,0,0.5)",
129129
}}
130130
>
131-
发布于 {dayjs.unix(data.created_at!).fromNow()}
131+
{data.user_name} 发布于 {dayjs.unix(data.created_at!).fromNow()}
132132
</Typography>
133133
<Stack
134134
direction="row"
@@ -192,7 +192,7 @@ const TitleCard = ({ data }: { data: ModelDiscussionDetail }) => {
192192
variant="body2"
193193
sx={{ fontSize: 12, color: "rgba(0,0,0,0.5)" }}
194194
>
195-
发布于 {dayjs.unix(data.created_at!).fromNow()}
195+
{data.user_name} 发布于 {dayjs.unix(data.created_at!).fromNow()}
196196
</Typography>
197197
</Stack>
198198
</Stack>

0 commit comments

Comments
 (0)