From e055bbac4092d7f6a8292aa4c8e7621cb5c3bc7c Mon Sep 17 00:00:00 2001
From: 18796357645 <674126018@qq.com>
Date: Sun, 8 Jun 2025 11:53:45 +0800
Subject: [PATCH] bug
---
ui/src/pages/user/index.vue | 14 +++++++++++++-
ui/src/utils/utils.ts | 9 +++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
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;
+}