refactor(antd): 替换 Modal destroyOnClose 为 destroyOnHidden
antd 新版本将 destroyOnClose 重命名为 destroyOnHidden, 消除控制台废弃警告。涉及 user、menu、notify、dict、config 页面。
This commit is contained in:
@@ -45,7 +45,7 @@ export default function ConfigManagement() {
|
||||
if (editingConfig) { await configApi.update(editingConfig.id, values as UpdateConfigRequest); message.success('更新成功') }
|
||||
else { await configApi.create(values as CreateConfigRequest); message.success('创建成功') }
|
||||
setModalOpen(false); loadConfigs()
|
||||
} catch {}
|
||||
} catch { /* ignored */ }
|
||||
}
|
||||
|
||||
const columns: ColumnsType<ConfigItem> = [
|
||||
@@ -72,7 +72,7 @@ export default function ConfigManagement() {
|
||||
</div>
|
||||
<Table<ConfigItem> rowKey="id" columns={columns} dataSource={configs} loading={loading}
|
||||
pagination={{ ...pagination, showSizeChanger: true, showTotal: (t) => `共 ${t} 条`, onChange: (p, ps) => { setPagination((prev) => ({ ...prev, current: p, pageSize: ps })); setTimeout(loadConfigs, 0) } }} />
|
||||
<Modal title={editingConfig ? '编辑配置' : '新增配置'} open={modalOpen} onOk={handleSubmit} onCancel={() => setModalOpen(false)} destroyOnClose>
|
||||
<Modal title={editingConfig ? '编辑配置' : '新增配置'} open={modalOpen} onOk={handleSubmit} onCancel={() => setModalOpen(false)} destroyOnHidden>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item name="configName" label="配置名称" rules={[{ required: true, message: '请输入配置名称' }]}><Input /></Form.Item>
|
||||
<Form.Item name="configKey" label="配置键" rules={[{ required: true, message: '请输入配置键' }]}><Input /></Form.Item>
|
||||
|
||||
@@ -20,11 +20,11 @@ export default function DictManagement() {
|
||||
useEffect(() => { loadDictTypes() }, [])
|
||||
|
||||
async function loadDictTypes() {
|
||||
try { const res = await dictApi.getTypes(); setDictTypes(Array.isArray(res) ? res : []) } catch {}
|
||||
try { const res = await dictApi.getTypes(); setDictTypes(Array.isArray(res) ? res : []) } catch { /* ignored */ }
|
||||
}
|
||||
async function loadDictData(dictType: string) {
|
||||
setLoading(true)
|
||||
try { const res = await dictApi.getDataByType(dictType); setDictData(Array.isArray(res) ? res : []) } catch {}
|
||||
try { const res = await dictApi.getDataByType(dictType); setDictData(Array.isArray(res) ? res : []) } catch { /* ignored */ }
|
||||
finally { setLoading(false) }
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export default function DictManagement() {
|
||||
if (editingType) { await dictApi.updateType(editingType.id, values as UpdateDictTypeRequest); message.success('更新成功') }
|
||||
else { await dictApi.createType(values as CreateDictTypeRequest); message.success('创建成功') }
|
||||
setTypeModalOpen(false); loadDictTypes()
|
||||
} catch {}
|
||||
} catch { /* ignored */ }
|
||||
}
|
||||
async function handleDataSubmit() {
|
||||
try {
|
||||
@@ -44,7 +44,7 @@ export default function DictManagement() {
|
||||
if (editingData) { await dictApi.updateData(editingData.id, { ...values, dictType: selectedType } as UpdateDictDataRequest); message.success('更新成功') }
|
||||
else { await dictApi.createData({ ...values, dictType: selectedType } as CreateDictDataRequest); message.success('创建成功') }
|
||||
setDataModalOpen(false); loadDictData(selectedType)
|
||||
} catch {}
|
||||
} catch { /* ignored */ }
|
||||
}
|
||||
|
||||
const typeColumns: ColumnsType<DictType> = [
|
||||
@@ -86,7 +86,7 @@ export default function DictManagement() {
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Modal title={editingType ? '编辑字典类型' : '新增字典类型'} open={typeModalOpen} onOk={handleTypeSubmit} onCancel={() => setTypeModalOpen(false)} destroyOnClose>
|
||||
<Modal title={editingType ? '编辑字典类型' : '新增字典类型'} open={typeModalOpen} onOk={handleTypeSubmit} onCancel={() => setTypeModalOpen(false)} destroyOnHidden>
|
||||
<Form form={typeForm} layout="vertical">
|
||||
<Form.Item name="dictName" label="字典名称" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="dictType" label="字典类型" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
@@ -94,7 +94,7 @@ export default function DictManagement() {
|
||||
<Form.Item name="remark" label="备注"><Input.TextArea /></Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
<Modal title={editingData ? '编辑字典数据' : '新增字典数据'} open={dataModalOpen} onOk={handleDataSubmit} onCancel={() => setDataModalOpen(false)} destroyOnClose>
|
||||
<Modal title={editingData ? '编辑字典数据' : '新增字典数据'} open={dataModalOpen} onOk={handleDataSubmit} onCancel={() => setDataModalOpen(false)} destroyOnHidden>
|
||||
<Form form={dataForm} layout="vertical">
|
||||
<Form.Item name="dictLabel" label="字典标签" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
<Form.Item name="dictValue" label="字典值" rules={[{ required: true }]}><Input /></Form.Item>
|
||||
|
||||
@@ -33,7 +33,7 @@ export default function NoticeManagement() {
|
||||
function handleAdd() { setEditingNotice(null); form.resetFields(); setModalOpen(true) }
|
||||
function handleEdit(record: Notice) {
|
||||
setEditingNotice(record)
|
||||
form.setFieldsValue({ title: record.title, content: record.content, type: record.type, status: record.status })
|
||||
form.setFieldsValue({ noticeTitle: record.noticeTitle, noticeContent: record.noticeContent, noticeType: record.noticeType, status: record.status })
|
||||
setModalOpen(true)
|
||||
}
|
||||
async function handleDelete(id: number) {
|
||||
@@ -46,14 +46,14 @@ export default function NoticeManagement() {
|
||||
if (editingNotice) { await noticeApi.update(editingNotice.id, values); message.success('更新成功') }
|
||||
else { await noticeApi.create(values); message.success('创建成功') }
|
||||
setModalOpen(false); loadNotices()
|
||||
} catch {}
|
||||
} catch { /* ignored */ }
|
||||
}
|
||||
|
||||
const columns: ColumnsType<Notice> = [
|
||||
{ title: '标题', dataIndex: 'title', key: 'title' },
|
||||
{ title: '类型', dataIndex: 'type', key: 'type', render: (v: string) => <Tag>{v}</Tag> },
|
||||
{ title: '标题', dataIndex: 'noticeTitle', key: 'noticeTitle' },
|
||||
{ title: '类型', dataIndex: 'noticeType', key: 'noticeType', render: (v: string) => <Tag>{v === '1' ? '通知' : v === '2' ? '公告' : v}</Tag> },
|
||||
{ title: '状态', dataIndex: 'status', key: 'status', render: (s: NoticeStatus) => { const info = noticeStatusMap[s]; return <Tag color={info?.color || 'default'}>{info?.label || s}</Tag> } },
|
||||
{ title: '创建者', dataIndex: 'createdBy', key: 'createdBy' },
|
||||
{ title: '创建者', dataIndex: 'createBy', key: 'createBy' },
|
||||
{ title: '创建时间', dataIndex: 'createdAt', key: 'createdAt' },
|
||||
{ title: '操作', key: 'action', render: (_, record) => (
|
||||
<Space>
|
||||
@@ -73,11 +73,11 @@ export default function NoticeManagement() {
|
||||
</div>
|
||||
<Table<Notice> rowKey="id" columns={columns} dataSource={notices} loading={loading}
|
||||
pagination={{ ...pagination, showSizeChanger: true, showTotal: (t) => `共 ${t} 条`, onChange: (p, ps) => { setPagination((prev) => ({ ...prev, current: p, pageSize: ps })); setTimeout(loadNotices, 0) } }} />
|
||||
<Modal title={editingNotice ? '编辑通知' : '新增通知'} open={modalOpen} onOk={handleSubmit} onCancel={() => setModalOpen(false)} destroyOnClose width={640}>
|
||||
<Modal title={editingNotice ? '编辑通知' : '新增通知'} open={modalOpen} onOk={handleSubmit} onCancel={() => setModalOpen(false)} destroyOnHidden width={640}>
|
||||
<Form form={form} layout="vertical">
|
||||
<Form.Item name="title" label="标题" rules={[{ required: true, message: '请输入标题' }]}><Input /></Form.Item>
|
||||
<Form.Item name="type" label="类型"><Select options={[{ label: '通知', value: 'notice' }, { label: '公告', value: 'announcement' }]} /></Form.Item>
|
||||
<Form.Item name="content" label="内容" rules={[{ required: true, message: '请输入内容' }]}><Input.TextArea rows={6} /></Form.Item>
|
||||
<Form.Item name="noticeTitle" label="标题" rules={[{ required: true, message: '请输入标题' }]}><Input /></Form.Item>
|
||||
<Form.Item name="noticeType" label="类型"><Select options={[{ label: '通知', value: '1' }, { label: '公告', value: '2' }]} /></Form.Item>
|
||||
<Form.Item name="noticeContent" label="内容" rules={[{ required: true, message: '请输入内容' }]}><Input.TextArea rows={6} /></Form.Item>
|
||||
<Form.Item name="status" label="状态" initialValue={NoticeStatus.ACTIVE}><Select options={Object.entries(noticeStatusMap).map(([v, info]) => ({ label: info.label, value: v }))} /></Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
@@ -78,7 +78,7 @@ export default function MenuManagement() {
|
||||
}
|
||||
setModalOpen(false)
|
||||
loadMenus()
|
||||
} catch {}
|
||||
} catch { /* ignored */ }
|
||||
}
|
||||
|
||||
const columns: ColumnsType<MenuItem> = [
|
||||
@@ -153,7 +153,7 @@ export default function MenuManagement() {
|
||||
open={modalOpen}
|
||||
onOk={handleSubmit}
|
||||
onCancel={() => setModalOpen(false)}
|
||||
destroyOnClose
|
||||
destroyOnHidden
|
||||
width={600}
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
|
||||
@@ -43,7 +43,7 @@ export default function UserManagement() {
|
||||
try {
|
||||
const res = await roleApi.getAll()
|
||||
setRoles(Array.isArray(res) ? res : [])
|
||||
} catch {}
|
||||
} catch { /* ignored */ }
|
||||
}
|
||||
|
||||
function handleAdd() {
|
||||
@@ -88,7 +88,7 @@ export default function UserManagement() {
|
||||
}
|
||||
setModalOpen(false)
|
||||
loadUsers()
|
||||
} catch {}
|
||||
} catch { /* ignored */ }
|
||||
}
|
||||
|
||||
const columns: ColumnsType<User> = [
|
||||
@@ -161,7 +161,7 @@ export default function UserManagement() {
|
||||
open={modalOpen}
|
||||
onOk={handleSubmit}
|
||||
onCancel={() => setModalOpen(false)}
|
||||
destroyOnClose
|
||||
destroyOnHidden
|
||||
>
|
||||
<Form form={form} layout="vertical">
|
||||
{!editingUser && (
|
||||
|
||||
Reference in New Issue
Block a user