diff --git a/src/assets/svg/sensitive.svg b/src/assets/svg/sensitive.svg
new file mode 100644
index 0000000..6ad88d5
--- /dev/null
+++ b/src/assets/svg/sensitive.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/constants/common.constants.ts b/src/constants/common.constants.ts
index 035c5ef..be6a3e7 100644
--- a/src/constants/common.constants.ts
+++ b/src/constants/common.constants.ts
@@ -31,6 +31,7 @@ export const SYSTEM_REQUEST_ILLEGAL = 10052
export const SYSTEM_ARGUMENT_NOT_VALID = 10053
export const SYSTEM_INVALID_CAPTCHA_CODE = 10054
export const SYSTEM_REQUEST_TOO_FREQUENT = 10055
+export const SYSTEM_MATCH_SENSITIVE_WORD = 10056
export const PERMISSION_LOGIN_SUCCESS = 20000
export const PERMISSION_PASSWORD_CHANGE_SUCCESS = 20001
diff --git a/src/constants/urls.constants.ts b/src/constants/urls.constants.ts
index d35f715..260c1d7 100644
--- a/src/constants/urls.constants.ts
+++ b/src/constants/urls.constants.ts
@@ -17,6 +17,7 @@ export const URL_SYS_GROUP_LIST = '/system/group/list'
export const URL_SYS_SETTINGS = '/system/settings'
export const URL_SYS_SETTINGS_BASE = `${URL_SYS_SETTINGS}/base`
export const URL_SYS_SETTINGS_MAIL = `${URL_SYS_SETTINGS}/mail`
+export const URL_SYS_SETTINGS_SENSITIVE = `${URL_SYS_SETTINGS}/sensitive`
export const URL_SYS_STATISTICS = '/system/statistics'
export const URL_SYS_STATISTICS_SOFTWARE = `${URL_SYS_STATISTICS}/software`
export const URL_SYS_STATISTICS_HARDWARE = `${URL_SYS_STATISTICS}/hardware`
diff --git a/src/global.d.ts b/src/global.d.ts
index 3d56975..deec261 100644
--- a/src/global.d.ts
+++ b/src/global.d.ts
@@ -357,6 +357,23 @@ interface MailSendParam {
to: string
}
+interface SensitiveWordVo {
+ id: string
+ word: string
+ useFor: string[]
+ enable: boolean
+}
+
+interface SensitiveWordAddParam {
+ word: string
+ useFor?: string[]
+ enable?: boolean
+}
+
+interface SensitiveWordUpdateParam {
+ ids: string[]
+}
+
interface SoftwareInfoVo {
os: string
bitness: number
diff --git a/src/main.tsx b/src/main.tsx
index 6a0a008..4cbf761 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -10,7 +10,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
{
void message.error('验证码有误,请重试')
setIsSigningUp(false)
break
+ case SYSTEM_MATCH_SENSITIVE_WORD:
+ void message.error('用户名包含敏感词,请重试')
+ setIsSigningUp(false)
+ break
default:
void message.error('服务器出错了,请稍后重试')
setIsSigningUp(false)
diff --git a/src/pages/sign/Verify.tsx b/src/pages/sign/Verify.tsx
index 17c0618..8edb23c 100644
--- a/src/pages/sign/Verify.tsx
+++ b/src/pages/sign/Verify.tsx
@@ -2,7 +2,9 @@ import React from 'react'
import {
COLOR_BACKGROUND,
PERMISSION_ACCOUNT_NEED_INIT,
- PERMISSION_NO_VERIFICATION_REQUIRED
+ PERMISSION_NO_VERIFICATION_REQUIRED,
+ PERMISSION_VERIFY_SUCCESS,
+ SYSTEM_MATCH_SENSITIVE_WORD
} from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import { getLoginStatus, getUserInfo, requestUserInfo } from '@/util/auth'
@@ -115,21 +117,27 @@ const Verify: React.FC = () => {
nickname: verifyParam.nickname
}).then((res) => {
const response = res.data
- if (response.success) {
- void message.success('恭喜你,完成了')
- setTimeout(() => {
- void requestUserInfo().then(() => {
- refreshRouter()
- if (searchParams.has('redirect')) {
- navigate(searchParams.get('redirect') ?? '/')
- } else {
- navigate('/')
- }
- })
- }, 1500)
- } else {
- void message.error('出错了,请稍后重试')
- setIsVerifying(false)
+ switch (response.code) {
+ case PERMISSION_VERIFY_SUCCESS:
+ void message.success('恭喜你,完成了')
+ setTimeout(() => {
+ void requestUserInfo().then(() => {
+ refreshRouter()
+ if (searchParams.has('redirect')) {
+ navigate(searchParams.get('redirect') ?? '/')
+ } else {
+ navigate('/')
+ }
+ })
+ }, 1500)
+ break
+ case SYSTEM_MATCH_SENSITIVE_WORD:
+ void message.error('昵称包含敏感词,请重试')
+ setIsVerifying(false)
+ break
+ default:
+ void message.error('出错了,请稍后重试')
+ setIsVerifying(false)
}
})
}
diff --git a/src/pages/system/settings/BaseSettings.tsx b/src/pages/system/settings/BaseSettings.tsx
index 62402f6..19a1304 100644
--- a/src/pages/system/settings/BaseSettings.tsx
+++ b/src/pages/system/settings/BaseSettings.tsx
@@ -29,8 +29,8 @@ const BaseSettings: React.FC = () => {
if (loading) {
return
}
-
setLoading(true)
+
void r_sys_settings_base_get().then((res) => {
const response = res.data
if (response.success) {
diff --git a/src/pages/system/settings/SensitiveWordSettings.tsx b/src/pages/system/settings/SensitiveWordSettings.tsx
new file mode 100644
index 0000000..ceea0e1
--- /dev/null
+++ b/src/pages/system/settings/SensitiveWordSettings.tsx
@@ -0,0 +1,163 @@
+import React, { useState } from 'react'
+import Icon from '@ant-design/icons'
+import { DATABASE_DUPLICATE_KEY, DATABASE_INSERT_SUCCESS } from '@/constants/common.constants'
+import { useUpdatedEffect } from '@/util/hooks'
+import {
+ r_sys_settings_sensitive_add,
+ r_sys_settings_sensitive_delete,
+ r_sys_settings_sensitive_get,
+ r_sys_settings_sensitive_update
+} from '@/services/system'
+import { SettingsCard } from '@/pages/system/settings'
+
+const SensitiveWordSettings: React.FC = () => {
+ const [dataSource, setDataSource] = useState()
+ const [targetKeys, setTargetKeys] = useState([])
+ const [selectedKeys, setSelectedKeys] = useState([])
+ const [loading, setLoading] = useState(false)
+ const [isAdding, setIsAdding] = useState(false)
+ const [newWord, setNewWord] = useState('')
+
+ const handleOnReset = () => {
+ getSensitiveWordSettings()
+ }
+
+ const handleOnSave = () => {
+ targetKeys &&
+ void r_sys_settings_sensitive_update({ ids: targetKeys }).then((res) => {
+ const response = res.data
+ if (response.success) {
+ void message.success('保存成功')
+ getSensitiveWordSettings()
+ } else {
+ void message.error('保存失败,请稍后重试')
+ }
+ })
+ }
+
+ const handleOnDelete = () => {
+ void r_sys_settings_sensitive_delete(selectedKeys[0]).then((res) => {
+ const response = res.data
+ if (response.success) {
+ void message.success('删除成功')
+ getSensitiveWordSettings()
+ } else {
+ void message.error('删除失败,请稍后重试')
+ }
+ })
+ }
+
+ const getSensitiveWordSettings = () => {
+ if (loading) {
+ return
+ }
+ setLoading(true)
+
+ void r_sys_settings_sensitive_get().then((res) => {
+ const response = res.data
+ if (response.success) {
+ const data = response.data
+ data && setDataSource(data)
+ data && setTargetKeys(data.filter((value) => value.enable).map((value) => value.id))
+ setLoading(false)
+ }
+ })
+ }
+
+ const handleOnChange = (e: React.ChangeEvent) => {
+ setNewWord(e.target.value)
+ }
+
+ const handleOnAdd = () => {
+ if (isAdding) {
+ return
+ }
+ setIsAdding(true)
+
+ void r_sys_settings_sensitive_add({ word: newWord, enable: false })
+ .then((res) => {
+ const response = res.data
+ switch (response.code) {
+ case DATABASE_INSERT_SUCCESS:
+ void message.success('添加成功')
+ setNewWord('')
+ getSensitiveWordSettings()
+ break
+ case DATABASE_DUPLICATE_KEY:
+ void message.error('该词已存在')
+ break
+ default:
+ void message.error('出错了,请稍后重试')
+ }
+ })
+ .finally(() => {
+ setIsAdding(false)
+ })
+ }
+
+ useUpdatedEffect(() => {
+ getSensitiveWordSettings()
+ }, [])
+
+ return (
+ <>
+
+
+ {selectedKeys?.length === 1 ? (
+
+
+
+ ) : undefined}
+ 备选
+ ,
+ '拦截'
+ ]}
+ dataSource={dataSource}
+ targetKeys={targetKeys}
+ selectedKeys={selectedKeys}
+ onChange={setTargetKeys}
+ onSelectChange={setSelectedKeys}
+ rowKey={(item) => item.id}
+ render={(item) => item.word}
+ />
+
+
+
+ }
+ >
+
+ >
+ )
+}
+
+export default SensitiveWordSettings
diff --git a/src/pages/system/settings/index.tsx b/src/pages/system/settings/index.tsx
index 7da663d..cf05b94 100644
--- a/src/pages/system/settings/index.tsx
+++ b/src/pages/system/settings/index.tsx
@@ -9,6 +9,7 @@ import LoadingMask from '@/components/common/LoadingMask'
import Permission from '@/components/common/Permission'
import BaseSettings from '@/pages/system/settings/BaseSettings'
import MailSettings from '@/pages/system/settings/MailSettings'
+import SensitiveWordSettings from '@/pages/system/settings/SensitiveWordSettings'
interface SettingsCardProps extends React.PropsWithChildren {
icon: IconComponent
@@ -38,7 +39,12 @@ export const SettingsCard: React.FC = (props) => {
) : undefined}
- {props.children}
+ }
+ hidden={!props.loading}
+ >
+ {props.children}
+
)
@@ -54,6 +60,9 @@ const Settings: React.FC = () => {
+
+
+
diff --git a/src/services/system.tsx b/src/services/system.tsx
index d995a84..4c6d321 100644
--- a/src/services/system.tsx
+++ b/src/services/system.tsx
@@ -15,7 +15,8 @@ import {
URL_SYS_STATISTICS_STORAGE,
URL_SYS_STATISTICS_ONLINE,
URL_SYS_STATISTICS_ACTIVE,
- URL_SYS_SETTINGS_BASE
+ URL_SYS_SETTINGS_BASE,
+ URL_SYS_SETTINGS_SENSITIVE
} from '@/constants/urls.constants'
import request from '@/services/index'
@@ -85,6 +86,18 @@ export const r_sys_settings_mail_update = (param: MailSettingsParam) =>
export const r_sys_settings_mail_send = (param: MailSendParam) =>
request.post(URL_SYS_SETTINGS_MAIL, param)
+export const r_sys_settings_sensitive_get = () =>
+ request.get(URL_SYS_SETTINGS_SENSITIVE)
+
+export const r_sys_settings_sensitive_add = (param: SensitiveWordAddParam) =>
+ request.post(URL_SYS_SETTINGS_SENSITIVE, param)
+
+export const r_sys_settings_sensitive_update = (param: SensitiveWordUpdateParam) =>
+ request.put(URL_SYS_SETTINGS_SENSITIVE, param)
+
+export const r_sys_settings_sensitive_delete = (id: string) =>
+ request.delete(`${URL_SYS_SETTINGS_SENSITIVE}/${id}`)
+
export const r_sys_statistics_software = () =>
request.get(URL_SYS_STATISTICS_SOFTWARE)