perf: 优化数据结构

This commit is contained in:
kuaifan 2025-04-07 08:30:06 +08:00
parent 83f58eae68
commit 7a275bd802
3 changed files with 24 additions and 24 deletions

View File

@ -496,7 +496,7 @@ export default {
}; };
}, },
created() { created() {
inputLoadAdd(this.dialogId, this._uid) inputLoadAdd(this._uid)
}, },
mounted() { mounted() {
this.init(); this.init();
@ -530,7 +530,7 @@ export default {
$A.loadScript('js/emoticon.all.js') $A.loadScript('js/emoticon.all.js')
}, },
beforeDestroy() { beforeDestroy() {
inputLoadRemove(this.dialogId, this._uid) inputLoadRemove(this._uid)
if (this.quill) { if (this.quill) {
this.quill.getModule("mention")?.hideMentionList(); this.quill.getModule("mention")?.hideMentionList();
this.quill = null this.quill = null
@ -749,15 +749,13 @@ export default {
}, },
// Reset lists // Reset lists
dialogId(id1, id2) { dialogId() {
this.userList = null; this.userList = null;
this.userCache = null; this.userCache = null;
this.taskList = null; this.taskList = null;
this.fileList = {}; this.fileList = {};
this.reportList = {}; this.reportList = {};
this.loadInputDraft() this.loadInputDraft()
inputLoadAdd(id1, this._uid)
inputLoadRemove(id2, this._uid)
}, },
taskId() { taskId() {
this.userList = null; this.userList = null;
@ -990,6 +988,9 @@ export default {
// Mark model as touched if editor lost focus // Mark model as touched if editor lost focus
this.quill.on('selection-change', range => { this.quill.on('selection-change', range => {
if (!inputLoadIsLast(this._uid)) {
return;
}
if (range) { if (range) {
this.selectRange = range this.selectRange = range
} else if (this.selectRange && document.activeElement && /(ql-editor|ql-clipboard)/.test(document.activeElement.className)) { } else if (this.selectRange && document.activeElement && /(ql-editor|ql-clipboard)/.test(document.activeElement.className)) {
@ -1878,7 +1879,7 @@ export default {
if (!this.quill) { if (!this.quill) {
return; return;
} }
if (!inputLoadIsLast(this.dialogId, this._uid)) { if (!inputLoadIsLast(this._uid)) {
return; return;
} }
const {index} = this.quill.getSelection(true); const {index} = this.quill.getSelection(true);

View File

@ -2,29 +2,30 @@ import Vue from 'vue';
import Emoji from "./emoji.vue"; import Emoji from "./emoji.vue";
import {Modal} from "view-design-hi"; import {Modal} from "view-design-hi";
const inputLoadUid = {} // 加载中的输入框的uid主要用于判断是否最后一个输入框
const inputLoadUid = []
function inputLoadAdd(dialogId, uid) { function inputLoadIsLast(uid) {
if (!dialogId || typeof inputLoadUid[dialogId] === "undefined") { if (inputLoadUid.length === 0) {
inputLoadUid[dialogId] = []; return true
} else {
inputLoadUid[dialogId] = inputLoadUid[dialogId].filter(v => v !== uid)
} }
inputLoadUid[dialogId].push(uid) const index = inputLoadUid.indexOf(uid)
if (index === -1) {
return false
}
return index === inputLoadUid.length - 1
} }
function inputLoadRemove(dialogId, uid) { const inputLoadRemove = (uid) => {
if (!dialogId || typeof inputLoadUid[dialogId] === "undefined") { const index = inputLoadUid.indexOf(uid)
return; if (index !== -1) {
inputLoadUid.splice(index, 1)
} }
inputLoadUid[dialogId] = inputLoadUid[dialogId].filter(v => v !== uid)
} }
function inputLoadIsLast(dialogId, uid) { const inputLoadAdd = (uid) => {
if (typeof inputLoadUid[dialogId] === "undefined") { inputLoadRemove(uid)
return false; inputLoadUid.push(uid)
}
return inputLoadUid[dialogId][inputLoadUid[dialogId].length - 1] === uid
} }
function choiceEmojiOne() { function choiceEmojiOne() {

View File

@ -745,8 +745,6 @@ export default {
'taskFiles', 'taskFiles',
'taskPriority', 'taskPriority',
'dialogId',
'formOptions' 'formOptions'
]), ]),