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 {