From 2c7b2f8c9d46c3602636d1b3c4a79d3190e3753c Mon Sep 17 00:00:00 2001 From: guoweijia Date: Wed, 4 Aug 2021 23:50:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96@=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../content/mixins/select-user-mixins.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/content/mixins/select-user-mixins.js b/src/components/content/mixins/select-user-mixins.js index 0bb5a6e..4be372a 100644 --- a/src/components/content/mixins/select-user-mixins.js +++ b/src/components/content/mixins/select-user-mixins.js @@ -1,5 +1,10 @@ import { getPosition, formatText } from "@/assets/js/utils"; export default { + data() { + return { + allUserList: [] + }; + }, methods: { handleSelectUser(user) { const originalText = this.textContent; @@ -27,7 +32,7 @@ export default { const startPosition = this.queryInfo.startPosition; const keyWord = this.textContent.slice(startPosition, endPosition); this.queryInfo.endPosition = endPosition; - console.log(e, e.data); + if (endPosition < startPosition || (e.returnValue && e.data === " ")) { // if (endPosition < startPosition || keyWord.slice(-1) === " ") { this.showSelectUser = false; @@ -41,8 +46,7 @@ export default { // // console.log('aaa'); // // console.log(e); // // alert(e.key) - - + // if (e.key === "@" || (e.key === "Process" && e.code === "Digit2")) { // this.createSelectUserDialog(); // } @@ -95,6 +99,9 @@ export default { this.$nextTick(() => { const userList = this.userList; if (userList === false) return; + if (this.queryInfo.keyWord === "") { + this.allUserList = userList; + } this.showSelectUser = true; this.$nextTick(() => { const list = textEl.parentNode.querySelector(".md_select_user"); @@ -107,9 +114,9 @@ export default { }); }, getUserByName(name) { - const userList = this.userList; + const userList = this.allUserList; if (!userList.length) return ""; - return userList.find(item => item.nickname === name); + return userList.find((item) => item.nickname === name); } } }; -- GitLab