From fe542c59e411cb5c3d2a4010a519edd164fbf91c Mon Sep 17 00:00:00 2001 From: Your Name <2499342078@qq.com> Date: Sat, 21 Jun 2025 21:57:20 +0800 Subject: [PATCH] add --- .../main/comment/components/CommentModal.tsx | 1 + .../main/comment/components/CommentTable.tsx | 12 +++--- .../src/app/main/layout/NavigationMenu.tsx | 42 ++++--------------- apps/web/src/routes/index.tsx | 10 ++--- packages/common/prisma/schema.prisma | 11 +++-- 5 files changed, 27 insertions(+), 49 deletions(-) diff --git a/apps/web/src/app/main/comment/components/CommentModal.tsx b/apps/web/src/app/main/comment/components/CommentModal.tsx index b713152..a38f7a8 100644 --- a/apps/web/src/app/main/comment/components/CommentModal.tsx +++ b/apps/web/src/app/main/comment/components/CommentModal.tsx @@ -24,6 +24,7 @@ export const CommentModal: React.FC = ({ const [commentType, setCommentType] = useState<'book' | 'library'>('book'); const [selectedLibraryId, setSelectedLibraryId] = useState(''); const [selectedReaderId, setSelectedReaderId] = useState(''); +console.log(editingRecord); // 查询所有图书馆 const { data: libraryList } = api.library.findMany.useQuery({ diff --git a/apps/web/src/app/main/comment/components/CommentTable.tsx b/apps/web/src/app/main/comment/components/CommentTable.tsx index 5c115fa..a1afbfb 100644 --- a/apps/web/src/app/main/comment/components/CommentTable.tsx +++ b/apps/web/src/app/main/comment/components/CommentTable.tsx @@ -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 = ({ onEdit, onDelete, }) => { + console.log(data); + const columns: ColumnsType = [ { title: '评论内容', dataIndex: 'content', key: 'content', + ellipsis:true, render: (content: string) => ( - + {content} - + ), width: '30%', }, @@ -106,7 +108,7 @@ export const CommentTable: React.FC = ({ expandable={{ expandedRowRender: (record) => (
- {record.content} + {record.content}
评论时间: {new Date(record.createdAt).toLocaleString('zh-CN')}
diff --git a/apps/web/src/app/main/layout/NavigationMenu.tsx b/apps/web/src/app/main/layout/NavigationMenu.tsx index 17e3e52..9d81a26 100755 --- a/apps/web/src/app/main/layout/NavigationMenu.tsx +++ b/apps/web/src/app/main/layout/NavigationMenu.tsx @@ -51,41 +51,17 @@ const items = [ null, null, ), - getItem( - "图书馆", + getItem( + "图书管理系统", "/library", , - null, - null, - ), - getItem( - "读者", - "/reader", - , - null, - null, - ), - - getItem( - "图书", - "/book", - , - null, - null, - ), - - getItem( - "借阅记录", - "/borrowRecord", - , - null, - null, - ), - getItem( - "评论", - "/comment", - , - 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( diff --git a/apps/web/src/routes/index.tsx b/apps/web/src/routes/index.tsx index a77433d..297eaad 100755 --- a/apps/web/src/routes/index.tsx +++ b/apps/web/src/routes/index.tsx @@ -86,24 +86,24 @@ export const routes: CustomRouteObject[] = [ }, { - path: "/library", + path: "/li/library", element: , }, { - path: "/reader", + path: "/li/reader", element: , }, { - path: "/book", + path: "/li/book", element: , }, { - path: "/borrowRecord", + path: "/li/borrowRecord", element: , }, { - path: "/comment", + path: "/li/comment", element: , }, ], diff --git a/packages/common/prisma/schema.prisma b/packages/common/prisma/schema.prisma index e3c863e..4f46d23 100755 --- a/packages/common/prisma/schema.prisma +++ b/packages/common/prisma/schema.prisma @@ -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")