From 6cf5b20cc9a774f13944c274813f8e3ec6d735c1 Mon Sep 17 00:00:00 2001
From: ysn <2126564605@qq.com>
Date: Thu, 18 Jun 2026 14:42:40 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=9C=80=E5=A4=9A=E8=83=BD?=
=?UTF-8?q?=E5=8F=91=E9=80=811000=E4=B8=AA=E6=96=87=E5=AD=97=20=E5=8F=91?=
=?UTF-8?q?=E8=B5=B7=E4=BC=9A=E8=AF=8A=E4=BC=A0=E5=8F=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../message/components/MessageEditor.vue | 40 +++++++++++++++++--
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/src/views/message/components/MessageEditor.vue b/src/views/message/components/MessageEditor.vue
index 13a7800..e1378db 100644
--- a/src/views/message/components/MessageEditor.vue
+++ b/src/views/message/components/MessageEditor.vue
@@ -90,14 +90,14 @@
@@ -180,6 +180,8 @@ export default {
// 存储编辑器中的文件信息
editorFiles: [],
maxQuillInitRetries: 20,
+ // 字数限制警告标记
+ wordLimitWarning: false,
};
},
@@ -418,6 +420,10 @@ export default {
// 处理文本变化,检测@符号输入
handleTextChange(delta) {
try {
+ // 字数限制检查(所有场景都需要)
+ this.checkWordLimit();
+
+ // @提醒逻辑(只有群聊场景)
if (
!this.currentChat ||
this.currentChat.scene !== ContactsScene.GROUP
@@ -441,6 +447,27 @@ export default {
}
},
+ // 检查字数限制
+ checkWordLimit() {
+ if (!this.quill) return;
+ const text = this.quill.getText().trim();
+ const maxLength = 1000;
+ const currentLength = text.length;
+
+ if (currentLength > maxLength) {
+ // 截断超出部分
+ this.quill.deleteText(maxLength, currentLength - maxLength);
+ // 显示提示
+ if (!this.wordLimitWarning) {
+ this.wordLimitWarning = true;
+ this.$message.warning(`消息字数不能超过${maxLength}字`);
+ setTimeout(() => {
+ this.wordLimitWarning = false;
+ }, 2000);
+ }
+ }
+ },
+
// 显示@成员下拉框
showAtDropdown() {
try {
@@ -542,13 +569,13 @@ export default {
const targetMode = this.meetingModes.find(
(item) => item.type === meetingType
);
- console.log(targetMode);
// 正常跳转
this.$router.push({
name: targetMode.routeName,
query: {
name: this.userInfo.group,
roomId_id: this.generateRoomId(targetMode.type, this.userInfo.id),
+ init_users: [this.currentChat.source_id],
},
});
},
@@ -586,6 +613,13 @@ export default {
return;
}
+ // 检查字数限制
+ const maxLength = 1000;
+ if (textContent.length > maxLength) {
+ this.$message.warning(`消息字数不能超过${maxLength}字`);
+ return;
+ }
+
this.sending = true;
try {