diff --git a/ui/src/pages/user/index.vue b/ui/src/pages/user/index.vue index d94cbeb..e9a02b2 100644 --- a/ui/src/pages/user/index.vue +++ b/ui/src/pages/user/index.vue @@ -16,7 +16,7 @@
充值 - +
@@ -154,6 +154,7 @@ import type { FormInstance } from 'element-plus' import { reactive, ref } from 'vue' import { useRouter } from 'vue-router' import { ElMessage, ElMessageBox } from 'element-plus' +import { hasSensitiveWords } from '~/utils/utils' const router = useRouter() const formRef = ref() const state = reactive({ @@ -193,6 +194,17 @@ const submitForm = (formEl: FormInstance | undefined) => { if (!formEl) return formEl.validate((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 => { ElMessage.success("修改成功") router.push("/login") diff --git a/ui/src/utils/utils.ts b/ui/src/utils/utils.ts index 21ec40b..adf4092 100644 --- a/ui/src/utils/utils.ts +++ b/ui/src/utils/utils.ts @@ -86,3 +86,12 @@ export const getFrontList = () => { ] return routes; } +export const hasSensitiveWords = () => { + const sensitivePatterns = [ + '暴力', + '政治', + '共产党', + '反共', + ] + return sensitivePatterns; +}