From dc94d43538e1aebd0b3b917d01319e5f19653f41 Mon Sep 17 00:00:00 2001 From: pfqgauxfb <3521106529@qq.com> Date: Mon, 2 Jun 2025 22:28:12 +0800 Subject: [PATCH] feng --- src/components/Comments/index.js | 89 ++++++++++++---- src/components/Comments/styles.module.css | 124 +++++++++++++++++++++- 2 files changed, 189 insertions(+), 24 deletions(-) diff --git a/src/components/Comments/index.js b/src/components/Comments/index.js index 62cba95..fce6a87 100644 --- a/src/components/Comments/index.js +++ b/src/components/Comments/index.js @@ -1,36 +1,79 @@ -import React from 'react'; -import Giscus from '@giscus/react'; -import Rating from '../Rating'; +import React, { useState } from 'react'; import styles from './styles.module.css'; const Comments = () => { - const handleRating = (rating) => { - // 这里可以添加评分提交逻辑 - console.log('Rating submitted:', rating); + const [rating, setRating] = useState(0); + const [comment, setComment] = useState(''); + const [comments, setComments] = useState([]); + + const handleSubmit = (e) => { + e.preventDefault(); + if (comment.trim()) { + setComments([ + ...comments, + { + rating, + text: comment, + date: new Date().toLocaleString(), + }, + ]); + setComment(''); + setRating(0); + } }; return (
+

文档评分与评论

+
-

文档评分

- +
+ {[1, 2, 3, 4, 5].map((star) => ( + setRating(star)} + > + ★ + + ))} +
+
+ {rating ? `您给了 ${rating} 星评价` : '请为本文档评分'} +
- -
-

评论区

- +