mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-22 00:10:28 +00:00
perf: 优化聊天输入框计算样式
This commit is contained in:
parent
663661c73c
commit
c0fadde527
@ -106,26 +106,59 @@ export default {
|
|||||||
_options: {},
|
_options: {},
|
||||||
|
|
||||||
modeClass: '',
|
modeClass: '',
|
||||||
editorStyle: {},
|
|
||||||
|
|
||||||
userList: null,
|
userList: null,
|
||||||
taskList: null,
|
taskList: null,
|
||||||
|
|
||||||
showMore: false,
|
showMore: false,
|
||||||
showEmoji: false,
|
showEmoji: false,
|
||||||
|
|
||||||
|
observer: null,
|
||||||
|
wrapperWidth: 0,
|
||||||
|
editorHeight: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.init();
|
this.init();
|
||||||
|
//
|
||||||
|
this.observer = new ResizeObserver(entries => {
|
||||||
|
entries.some(({target, contentRect}) => {
|
||||||
|
if (target === this.$el) {
|
||||||
|
this.wrapperWidth = contentRect.width;
|
||||||
|
} else if (target === this.$refs.editor) {
|
||||||
|
this.editorHeight = contentRect.height;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
this.observer.observe(this.$el);
|
||||||
|
this.observer.observe(this.$refs.editor);
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
if (this.quill) {
|
||||||
this.quill = null
|
this.quill = null
|
||||||
delete this.quill
|
}
|
||||||
|
if (this.observer) {
|
||||||
|
this.observer.disconnect()
|
||||||
|
this.observer = null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['cacheProjects', 'cacheTasks', 'cacheUserBasic', 'userId']),
|
...mapState(['cacheProjects', 'cacheTasks', 'cacheUserBasic', 'userId']),
|
||||||
|
|
||||||
...mapGetters(['dashboardTask', 'transforTasks']),
|
...mapGetters(['dashboardTask', 'transforTasks']),
|
||||||
|
|
||||||
|
editorStyle() {
|
||||||
|
const {wrapperWidth, editorHeight} = this;
|
||||||
|
if (wrapperWidth > 0
|
||||||
|
&& editorHeight > 0
|
||||||
|
&& (wrapperWidth < 300 || editorHeight > 40)) {
|
||||||
|
return {
|
||||||
|
width: '100%'
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
// Watch content change
|
// Watch content change
|
||||||
@ -167,7 +200,7 @@ export default {
|
|||||||
if (!val && this.$refs.moreTip) {
|
if (!val && this.$refs.moreTip) {
|
||||||
this.$refs.moreTip.updatePopper()
|
this.$refs.moreTip.updatePopper()
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
@ -281,12 +314,10 @@ export default {
|
|||||||
this._content = html
|
this._content = html
|
||||||
this.$emit('input', this._content)
|
this.$emit('input', this._content)
|
||||||
this.$emit('on-change', { html, text, quill })
|
this.$emit('on-change', { html, text, quill })
|
||||||
this.calcEditStyle();
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Emit ready event
|
// Emit ready event
|
||||||
this.$emit('on-ready', this.quill)
|
this.$emit('on-ready', this.quill)
|
||||||
this.calcEditStyle();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
focus() {
|
focus() {
|
||||||
@ -305,16 +336,6 @@ export default {
|
|||||||
this.$emit('on-send')
|
this.$emit('on-send')
|
||||||
},
|
},
|
||||||
|
|
||||||
calcEditStyle() {
|
|
||||||
if (this.$refs.editor.clientWidth < 120 || this.$refs.editor.clientHeight > 40) {
|
|
||||||
this.editorStyle = {
|
|
||||||
width: '100%'
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
this.editorStyle = {};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onSelectEmoji(item) {
|
onSelectEmoji(item) {
|
||||||
if (!this.quill) {
|
if (!this.quill) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user