Add base settings management to Settings page
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
COLOR_BACKGROUND,
|
||||
DATABASE_DUPLICATE_KEY,
|
||||
PERMISSION_ACCOUNT_NEED_INIT,
|
||||
PERMISSION_FORGET_SUCCESS,
|
||||
PERMISSION_LOGIN_SUCCESS,
|
||||
PERMISSION_LOGIN_USERNAME_PASSWORD_ERROR,
|
||||
PERMISSION_NO_VERIFICATION_REQUIRED,
|
||||
@@ -13,6 +14,7 @@ import {
|
||||
PERMISSION_RETRIEVE_CODE_ERROR_OR_EXPIRED,
|
||||
PERMISSION_RETRIEVE_SUCCESS,
|
||||
PERMISSION_USER_DISABLE,
|
||||
PERMISSION_USER_NOT_FOUND,
|
||||
PERMISSION_USERNAME_NOT_FOUND
|
||||
} from '@/constants/common.constants.ts'
|
||||
import { getLoginStatus, getUserInfo, requestUserInfo, setToken } from '@/util/auth'
|
||||
@@ -457,11 +459,16 @@ const Forget: React.FC = () => {
|
||||
void r_auth_forget(forgetParam)
|
||||
.then((res) => {
|
||||
const response = res.data
|
||||
if (response.success) {
|
||||
void message.success('已发送验证邮件,请查收')
|
||||
setIsSent(true)
|
||||
} else {
|
||||
void message.error('出错了,请稍后重试')
|
||||
switch (response.code) {
|
||||
case PERMISSION_FORGET_SUCCESS:
|
||||
void message.success('已发送验证邮件,请查收')
|
||||
setIsSent(true)
|
||||
break
|
||||
case PERMISSION_USER_NOT_FOUND:
|
||||
void message.error('用户不存在')
|
||||
break
|
||||
default:
|
||||
void message.error('出错了,请稍后重试')
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
|
||||
@@ -22,7 +22,7 @@ const ToolsFramework: React.FC = () => {
|
||||
<>
|
||||
<FitFullscreen data-component={'tools-framework'} className={'flex-horizontal'}>
|
||||
<div className={'left-panel'}>
|
||||
<Sidebar title={'氮工具'} onSidebarSwitch={handleOnSidebarSwitch}>
|
||||
<Sidebar title={'氧工具'} onSidebarSwitch={handleOnSidebarSwitch}>
|
||||
<SidebarItemList>
|
||||
<SidebarItem end path={''} icon={tools[0].icon} text={tools[0].name} />
|
||||
<SidebarItem
|
||||
|
||||
@@ -27,7 +27,7 @@ const ToolsFramework: React.FC = () => {
|
||||
<SidebarItem
|
||||
path={'/tools'}
|
||||
icon={IconFatwebBack}
|
||||
text={'回到氮工具'}
|
||||
text={'回到氧工具'}
|
||||
/>
|
||||
</SidebarItemList>
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import '@/assets/css/pages/system/settings.scss'
|
||||
import { useUpdatedEffect } from '@/util/hooks'
|
||||
import { hasPermission } from '@/util/auth'
|
||||
import {
|
||||
r_sys_settings_base_get,
|
||||
r_sys_settings_base_update,
|
||||
r_sys_settings_mail_get,
|
||||
r_sys_settings_mail_send,
|
||||
r_sys_settings_mail_update
|
||||
@@ -192,6 +194,80 @@ const MailSettings: React.FC = () => {
|
||||
)
|
||||
}
|
||||
|
||||
const BaseSettings: React.FC = () => {
|
||||
const [baseForm] = AntdForm.useForm<BaseSettingsParam>()
|
||||
const baseFormValues = AntdForm.useWatch([], baseForm)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const handleOnReset = () => {
|
||||
getBaseSettings()
|
||||
}
|
||||
|
||||
const handleOnSave = () => {
|
||||
void r_sys_settings_base_update(baseFormValues).then((res) => {
|
||||
const response = res.data
|
||||
if (response.success) {
|
||||
void message.success('保存设置成功')
|
||||
getBaseSettings()
|
||||
} else {
|
||||
void message.error('保存设置失败,请稍后重试')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getBaseSettings = () => {
|
||||
if (loading) {
|
||||
return
|
||||
}
|
||||
|
||||
setLoading(true)
|
||||
void r_sys_settings_base_get().then((res) => {
|
||||
const response = res.data
|
||||
if (response.success) {
|
||||
const data = response.data
|
||||
data && baseForm.setFieldsValue(data)
|
||||
setLoading(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
useUpdatedEffect(() => {
|
||||
getBaseSettings()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsCard
|
||||
icon={IconFatwebEmail}
|
||||
title={'基础'}
|
||||
loading={loading}
|
||||
onReset={handleOnReset}
|
||||
onSave={handleOnSave}
|
||||
modifyOperationCode={'system:settings:modify:base'}
|
||||
>
|
||||
<AntdForm
|
||||
form={baseForm}
|
||||
labelCol={{ flex: '7em' }}
|
||||
disabled={!hasPermission('system:settings:modify:base')}
|
||||
>
|
||||
<AntdForm.Item label={'应用名称'} name={'appName'}>
|
||||
<AntdInput />
|
||||
</AntdForm.Item>
|
||||
<AntdForm.Item label={'应用 URL'} name={'appUrl'}>
|
||||
<AntdInput />
|
||||
</AntdForm.Item>
|
||||
<AntdForm.Item label={'验证邮箱 URL'} name={'verifyUrl'}>
|
||||
<AntdInput placeholder={'验证码使用 ${verifyCode} 代替'} />
|
||||
</AntdForm.Item>
|
||||
<AntdForm.Item label={'找回密码 URL'} name={'retrieveUrl'}>
|
||||
<AntdInput placeholder={'验证码使用 ${retrieveCode} 代替'} />
|
||||
</AntdForm.Item>
|
||||
</AntdForm>
|
||||
</SettingsCard>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
const Settings: React.FC = () => {
|
||||
return (
|
||||
<>
|
||||
@@ -199,10 +275,12 @@ const Settings: React.FC = () => {
|
||||
<HideScrollbar isShowVerticalScrollbar autoHideWaitingTime={500}>
|
||||
<FlexBox className={'root-content'}>
|
||||
<FlexBox direction={'horizontal'} className={'root-row'}>
|
||||
<Permission operationCode={'system:settings:query:base'}>
|
||||
<BaseSettings />
|
||||
</Permission>
|
||||
<Permission operationCode={'system:settings:query:mail'}>
|
||||
<MailSettings />
|
||||
</Permission>
|
||||
<div />
|
||||
</FlexBox>
|
||||
</FlexBox>
|
||||
</HideScrollbar>
|
||||
|
||||
@@ -976,8 +976,8 @@ const Statistics: React.FC = () => {
|
||||
<ActiveInfo />
|
||||
</Permission>
|
||||
<Permission operationCode={'system:statistics:query:base'}>
|
||||
<SoftwareInfo />
|
||||
<HardwareInfo />
|
||||
<SoftwareInfo />
|
||||
</Permission>
|
||||
<Permission operationCode={'system:statistics:query:real'}>
|
||||
<CPUInfo />
|
||||
|
||||
Reference in New Issue
Block a user