This commit is contained in:
Your Name 2025-06-21 21:57:20 +08:00
parent ab4ba55721
commit fe542c59e4
5 changed files with 27 additions and 49 deletions

View File

@ -24,6 +24,7 @@ export const CommentModal: React.FC<CommentModalProps> = ({
const [commentType, setCommentType] = useState<'book' | 'library'>('book');
const [selectedLibraryId, setSelectedLibraryId] = useState<string>('');
const [selectedReaderId, setSelectedReaderId] = useState<string>('');
console.log(editingRecord);
// 查询所有图书馆
const { data: libraryList } = api.library.findMany.useQuery({

View File

@ -1,10 +1,9 @@
import { Button, Space, Table, Popconfirm, Typography, Avatar, Rate, Tag } from 'antd';
import { Button, Space, Table, Popconfirm, Avatar, Rate, Tag } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import { Comment } from './types';
import React from 'react';
import { UserOutlined, BookOutlined, HomeOutlined } from '@ant-design/icons';
const { Text, Paragraph } = Typography;
interface CommentTableProps {
data: Comment[];
@ -19,15 +18,18 @@ export const CommentTable: React.FC<CommentTableProps> = ({
onEdit,
onDelete,
}) => {
console.log(data);
const columns: ColumnsType<Comment> = [
{
title: '评论内容',
dataIndex: 'content',
key: 'content',
ellipsis:true,
render: (content: string) => (
<Paragraph ellipsis={{ rows: 2, expandable: true, symbol: '更多' }}>
<Space>
{content}
</Paragraph>
</Space>
),
width: '30%',
},
@ -106,7 +108,7 @@ export const CommentTable: React.FC<CommentTableProps> = ({
expandable={{
expandedRowRender: (record) => (
<div className="p-4 bg-gray-50">
<Paragraph>{record.content}</Paragraph>
{record.content}
<div className="text-gray-500 text-sm mt-2">
: {new Date(record.createdAt).toLocaleString('zh-CN')}
</div>

View File

@ -51,41 +51,17 @@ const items = [
null,
null,
),
getItem(
"图书",
getItem(
"图书管理系统",
"/library",
<i className="iconfont icon-icon-category" />,
null,
null,
),
getItem(
"读者",
"/reader",
<i className="iconfont icon-icon-category" />,
null,
null,
),
getItem(
"图书",
"/book",
<i className="iconfont icon-icon-category" />,
null,
null,
),
getItem(
"借阅记录",
"/borrowRecord",
<i className="iconfont icon-icon-category" />,
null,
null,
),
getItem(
"评论",
"/comment",
<i className="iconfont icon-icon-category" />,
null,
[
getItem("图书馆", "/li/library", null, null, null),
getItem("读者", "/li/reader", null, null, null),
getItem("图书", "/li/book", null, null, null),
getItem("借阅记录", "/li/borrowRecord", null, null, null),
getItem("评论", "/li/comment", null, null, null),
],
null,
),
getItem(

View File

@ -86,24 +86,24 @@ export const routes: CustomRouteObject[] = [
},
{
path: "/library",
path: "/li/library",
element: <LibraryPage></LibraryPage>,
},
{
path: "/reader",
path: "/li/reader",
element: <ReaderPage></ReaderPage>,
},
{
path: "/book",
path: "/li/book",
element: <BookPage></BookPage>,
},
{
path: "/borrowRecord",
path: "/li/borrowRecord",
element: <BorrowRecordPage></BorrowRecordPage>,
},
{
path: "/comment",
path: "/li/comment",
element: <CommentPage></CommentPage>,
},
],

View File

@ -12,9 +12,8 @@ datasource db {
enum Character {
ADMIN
CLUB_ADMIN
DRIVER
GUEST
LIB_ADMIN
READER
}
@ -23,7 +22,7 @@ model User {
id String @id @default(cuid())
username String @unique
password String
role Character @default(GUEST)
role Character @default(READER)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
@ -120,8 +119,8 @@ model Comment {
library Library? @relation(fields: [libraryId], references: [id])
readerId String @map("read_id")
reader Reader @relation(fields: [readerId], references: [id])
bookId String @map("book_id")
book Book @relation(fields: [bookId], references: [id])
bookId String? @map("book_id")
book Book? @relation(fields: [bookId], references: [id])
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
deletedAt DateTime? @map("deleted_at")