This commit is contained in:
sijinhui 2024-04-29 18:32:05 +08:00
parent 7611c58527
commit 209f23f2f0
2 changed files with 50 additions and 29 deletions

View File

@ -20,13 +20,13 @@ function SettingForm() {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [setting, setSetting] = useState<Setting[]>([]); const [setting, setSetting] = useState<Setting[]>([]);
const [isModalVisible, setIsModalVisible] = useState(false); // const [isModalVisible, setIsModalVisible] = useState(false);
const openModal = () => setIsModalVisible(true); // const openModal = () => setIsModalVisible(true);
const closeModal = () => setIsModalVisible(false); // const closeModal = () => setIsModalVisible(false);
//
const handleFormSubmit = async (record: Setting) => { // const handleFormSubmit = async (record: Setting) => {
console.log("-------", record); // console.log("-------", record);
}; // };
const handelDel = (record: Setting) => { const handelDel = (record: Setting) => {
fetch(`/api/admin/setting/${record.key}`, { fetch(`/api/admin/setting/${record.key}`, {

View File

@ -8,17 +8,19 @@ import {
Tag, Tag,
Input, Input,
Button, Button,
notification, notification as notificationModule,
Popconfirm, Popconfirm,
Checkbox, Checkbox,
Modal,
Form,
} from "antd"; } from "antd";
import type { GetRef, TableColumnsType } from "antd"; import type { GetRef, TableColumnsType } from "antd";
// import { headers } from 'next/headers' // import { headers } from 'next/headers'
import type { NotificationArgsProps } from "antd"; import type { NotificationArgsProps } from "antd";
import Highlighter from "react-highlight-words"; // import Highlighter from "react-highlight-words";
// 后期考虑删除该依赖 // 后期考虑删除该依赖
type NotificationPlacement = NotificationArgsProps["placement"]; // type NotificationPlacement = NotificationArgsProps["placement"];
import type { SearchProps } from "antd/es/input/Search"; import type { SearchProps } from "antd/es/input/Search";
@ -82,8 +84,10 @@ function UserTableSearchInput({ users, setUsers, setLoading }: UserInterface) {
} }
function UsersTable({ users, setUsers, loading }: UserInterface) { function UsersTable({ users, setUsers, loading }: UserInterface) {
const [api, contextHolder] = notification.useNotification(); const [notification, notificationContextHolder] =
notificationModule.useNotification();
const [editUserModal, editUserModalContextHolder] = Modal.useModal();
const [editUserForm] = Form.useForm();
const [newPassword, setNewPassword] = useState(""); const [newPassword, setNewPassword] = useState("");
const newPasswordChange = (e: React.ChangeEvent<HTMLInputElement>) => { const newPasswordChange = (e: React.ChangeEvent<HTMLInputElement>) => {
@ -133,12 +137,12 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
const openNotification = (level: string, arms: NotificationArgsProps) => { const openNotification = (level: string, arms: NotificationArgsProps) => {
if (level === "error") { if (level === "error") {
api.error({ notification.error({
...arms, ...arms,
placement: "topRight", placement: "topRight",
}); });
} else { } else {
api.info({ notification.info({
...arms, ...arms,
placement: "topRight", placement: "topRight",
}); });
@ -189,7 +193,7 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
render: (value) => getCurrentTime(new Date(value)), render: (value) => getCurrentTime(new Date(value)),
}, },
{ {
title: "isAdmin", title: "管理员",
dataIndex: "isAdmin", dataIndex: "isAdmin",
width: 80, width: 80,
render: (value) => { render: (value) => {
@ -201,9 +205,9 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
}, },
}, },
{ {
title: "allowToLogin", title: "允许登录",
dataIndex: "allowToLogin", dataIndex: "allowToLogin",
width: 120, width: 80,
render: (value) => { render: (value) => {
return ( return (
<div> <div>
@ -212,13 +216,26 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
); );
}, },
}, },
// {
// title: "编辑",
// dataIndex: "",
// key: "id",
// width: 80,
// render: (value) => {
// return (
// <div>
// <a >编辑</a>
// </div>
// );
// },
// },
{ {
title: "Action", title: "Action",
dataIndex: "", dataIndex: "",
key: "id", key: "id",
render: (_, record) => ( render: (_, record) => (
<Space size="middle"> <Space size="small">
{contextHolder} <a></a>
<Popconfirm <Popconfirm
id="user-admin-table-pop_confirm" id="user-admin-table-pop_confirm"
title="设置密码" title="设置密码"
@ -247,16 +264,20 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
// console.log(users, "users2"); // console.log(users, "users2");
return ( return (
<Table <>
dataSource={users} {notificationContextHolder}
rowKey="id" {editUserModalContextHolder}
columns={columns} <Table
loading={loading as boolean} dataSource={users}
scroll={{ rowKey="id"
scrollToFirstRowOnChange: true, columns={columns}
y: 1080, loading={loading as boolean}
}} scroll={{
/> scrollToFirstRowOnChange: true,
y: 1080,
}}
/>
</>
); );
} }