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 [commentType, setCommentType] = useState<'book' | 'library'>('book');
const [selectedLibraryId, setSelectedLibraryId] = useState<string>(''); const [selectedLibraryId, setSelectedLibraryId] = useState<string>('');
const [selectedReaderId, setSelectedReaderId] = useState<string>(''); const [selectedReaderId, setSelectedReaderId] = useState<string>('');
console.log(editingRecord);
// 查询所有图书馆 // 查询所有图书馆
const { data: libraryList } = api.library.findMany.useQuery({ 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 type { ColumnsType } from 'antd/es/table';
import { Comment } from './types'; import { Comment } from './types';
import React from 'react'; import React from 'react';
import { UserOutlined, BookOutlined, HomeOutlined } from '@ant-design/icons'; import { UserOutlined, BookOutlined, HomeOutlined } from '@ant-design/icons';
const { Text, Paragraph } = Typography;
interface CommentTableProps { interface CommentTableProps {
data: Comment[]; data: Comment[];
@ -19,15 +18,18 @@ export const CommentTable: React.FC<CommentTableProps> = ({
onEdit, onEdit,
onDelete, onDelete,
}) => { }) => {
console.log(data);
const columns: ColumnsType<Comment> = [ const columns: ColumnsType<Comment> = [
{ {
title: '评论内容', title: '评论内容',
dataIndex: 'content', dataIndex: 'content',
key: 'content', key: 'content',
ellipsis:true,
render: (content: string) => ( render: (content: string) => (
<Paragraph ellipsis={{ rows: 2, expandable: true, symbol: '更多' }}> <Space>
{content} {content}
</Paragraph> </Space>
), ),
width: '30%', width: '30%',
}, },
@ -106,7 +108,7 @@ export const CommentTable: React.FC<CommentTableProps> = ({
expandable={{ expandable={{
expandedRowRender: (record) => ( expandedRowRender: (record) => (
<div className="p-4 bg-gray-50"> <div className="p-4 bg-gray-50">
<Paragraph>{record.content}</Paragraph> {record.content}
<div className="text-gray-500 text-sm mt-2"> <div className="text-gray-500 text-sm mt-2">
: {new Date(record.createdAt).toLocaleString('zh-CN')} : {new Date(record.createdAt).toLocaleString('zh-CN')}
</div> </div>

View File

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

View File

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

View File

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