用户管理页面优化

This commit is contained in:
sijinhui 2024-03-26 08:56:42 +08:00
parent aa8859b186
commit 532ace669e
2 changed files with 7 additions and 2 deletions

View File

@ -4,8 +4,11 @@ import { User } from "@prisma/client";
import UsersTable from "../../components/users-table"; import UsersTable from "../../components/users-table";
async function getData() { async function getData() {
const users = await prisma.user.findMany(); return await prisma.user.findMany({
return users; orderBy: {
createdAt: "desc",
},
});
} }
export default async function UsersPage() { export default async function UsersPage() {
const users: User[] = await getData(); const users: User[] = await getData();

View File

@ -118,11 +118,13 @@ function UsersTable({ users }: UserInterface) {
}, },
onFilterDropdownOpenChange: (visible) => { onFilterDropdownOpenChange: (visible) => {
if (visible) { if (visible) {
// @ts-ignore
setTimeout(() => searchInput.current?.select(), 100); setTimeout(() => searchInput.current?.select(), 100);
} }
}, },
render: (text) => render: (text) =>
searchedColumn === dataIndex ? ( searchedColumn === dataIndex ? (
// @ts-ignore
<Highlighter <Highlighter
highlightStyle={{ backgroundColor: "#ffc069", padding: 0 }} highlightStyle={{ backgroundColor: "#ffc069", padding: 0 }}
searchWords={[searchText]} searchWords={[searchText]}