This commit is contained in:
18796357645 2025-06-08 11:53:45 +08:00
parent 8513b981c9
commit e055bbac40
2 changed files with 22 additions and 1 deletions

View File

@ -154,6 +154,7 @@ import type { FormInstance } from 'element-plus'
import { reactive, ref } from 'vue' import { reactive, ref } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { hasSensitiveWords } from '~/utils/utils'
const router = useRouter() const router = useRouter()
const formRef = ref<FormInstance>() const formRef = ref<FormInstance>()
const state = reactive({ const state = reactive({
@ -193,6 +194,17 @@ const submitForm = (formEl: FormInstance | undefined) => {
if (!formEl) return if (!formEl) return
formEl.validate((valid) => { formEl.validate((valid) => {
if (valid) { if (valid) {
//
const foundSensitiveWords = hasSensitiveWords().filter(word =>
state.userInfo.nickName.includes(word)
);
if (foundSensitiveWords.length > 0) {
ElMessage.error(`内容包含敏感词:${foundSensitiveWords.join('、')}`);
return;
}
frontRequest.put("/api/user/update", state.userInfo).then(res => { frontRequest.put("/api/user/update", state.userInfo).then(res => {
ElMessage.success("修改成功") ElMessage.success("修改成功")
router.push("/login") router.push("/login")

View File

@ -86,3 +86,12 @@ export const getFrontList = () => {
] ]
return routes; return routes;
} }
export const hasSensitiveWords = () => {
const sensitivePatterns = [
'暴力',
'政治',
'共产党',
'反共',
]
return sensitivePatterns;
}