From 80bec52fcdbcf18cbe52c0b77b5e9e714191dd1d Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Wed, 1 May 2024 16:12:57 +0800 Subject: [PATCH] Refactor(Modal): Optimize modal code --- src/pages/Sign/SignIn.tsx | 2 +- src/pages/System/Settings/Mail.tsx | 2 +- src/pages/Tools/index.tsx | 11 +++++++---- src/pages/User/index.tsx | 10 +++++----- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/pages/Sign/SignIn.tsx b/src/pages/Sign/SignIn.tsx index 1812be6..a81563a 100644 --- a/src/pages/Sign/SignIn.tsx +++ b/src/pages/Sign/SignIn.tsx @@ -112,8 +112,8 @@ const SignIn = () => { case PERMISSION_NEED_TWO_FACTOR: twoFactorForm.resetFields() void modal.confirm({ - title: '双因素验证', centered: true, + title: '双因素验证', footer: (_, { OkBtn, CancelBtn }) => ( <> diff --git a/src/pages/System/Settings/Mail.tsx b/src/pages/System/Settings/Mail.tsx index 205474b..68224ba 100644 --- a/src/pages/System/Settings/Mail.tsx +++ b/src/pages/System/Settings/Mail.tsx @@ -16,9 +16,9 @@ const Mail = () => { const handleOnTest = () => { void modal.confirm({ - title: '发送测试邮件', centered: true, maskClosable: true, + title: '发送测试邮件', footer: (_, { OkBtn, CancelBtn }) => ( <> diff --git a/src/pages/Tools/index.tsx b/src/pages/Tools/index.tsx index 1a3d848..78aef88 100644 --- a/src/pages/Tools/index.tsx +++ b/src/pages/Tools/index.tsx @@ -219,8 +219,9 @@ const Tools = () => { const handleOnDeleteTool = (tool: ToolVo) => { modal .confirm({ - title: '删除', + centered: true, maskClosable: true, + title: '删除', content: `确定删除工具 ${tool.toolId}:${tool.platform.slice(0, 1)}${tool.platform.slice(1).toLowerCase()}:${tool.ver} 吗?` }) .then( @@ -249,9 +250,9 @@ const Tools = () => { const handleOnUpgradeTool = (tool: ToolVo) => { void modal.confirm({ - title: '更新工具', centered: true, maskClosable: true, + title: '更新工具', footer: (_, { OkBtn, CancelBtn }) => ( <> @@ -361,8 +362,9 @@ const Tools = () => { const handleOnSubmitTool = (tool: ToolVo) => { modal .confirm({ - title: '提交审核', + centered: true, maskClosable: true, + title: '提交审核', content: `确定提交审核工具 ${tool.name}:${tool.ver} 吗?` }) .then( @@ -400,8 +402,9 @@ const Tools = () => { const handleOnCancelTool = (tool: ToolVo) => { modal .confirm({ - title: '取消审核', + centered: true, maskClosable: true, + title: '取消审核', content: `确定取消审核工具 ${tool.name}:${tool.ver} 吗?` }) .then( diff --git a/src/pages/User/index.tsx b/src/pages/User/index.tsx index 7cf28a2..b4415be 100644 --- a/src/pages/User/index.tsx +++ b/src/pages/User/index.tsx @@ -89,6 +89,8 @@ const User = () => { changePasswordForm.resetFields() void modal.confirm({ + centered: true, + maskClosable: true, icon: <>, title: ( <> @@ -99,8 +101,6 @@ const User = () => { 修改密码 ), - centered: true, - maskClosable: true, footer: (_, { OkBtn, CancelBtn }) => ( <> @@ -220,10 +220,10 @@ const User = () => { twoFactorForm.resetFields() if (enable) { void modal.confirm({ - title: '双因素', centered: true, maskClosable: true, focusTriggerAfterClose: false, + title: '双因素', footer: (_, { OkBtn, CancelBtn }) => ( <> @@ -233,9 +233,9 @@ const User = () => { content: '确定解除双因素?', onOk: () => { void modal.confirm({ - title: '解除双因素', centered: true, maskClosable: true, + title: '解除双因素', footer: (_, { OkBtn, CancelBtn }) => ( <> @@ -313,9 +313,9 @@ const User = () => { const response = res.data if (response.success) { void modal.confirm({ - title: '绑定双因素', centered: true, maskClosable: true, + title: '绑定双因素', footer: (_, { OkBtn, CancelBtn }) => ( <>