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

View File

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

View File

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