From 7a6989d2e9d3356c1fe2db2da0a3abb0522cdb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=B1=E8=BE=BE?= Date: Mon, 12 May 2025 14:57:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(app):=20=E4=BF=AE=E5=A4=8D=20Home=20?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=9B=BE=E8=A1=A8=E4=B8=8D=E8=83=BD=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E6=B8=B2=E6=9F=93=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新 lineEcharts 组件的 key 属性,使用 options.title.text 替代 options.title - 添加监听 sidebar.opened 变化的 watch 函数,重新渲染图表 - 在 mounted钩子中添加窗口大小变化的事件监听,重新渲染图表- 更新 computed 属性,使用 sidebar 和 sidebarList 替代 sidebarLogo --- src/views/app/Home.vue | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/views/app/Home.vue b/src/views/app/Home.vue index d1ddf80..2b3262a 100644 --- a/src/views/app/Home.vue +++ b/src/views/app/Home.vue @@ -111,7 +111,7 @@
@@ -146,6 +146,18 @@ export default { components: { lineEcharts }, + watch: { + 'sidebar.opened': function(val) { + this.options.title.text = null + setTimeout(() => { + if (this.datasetList.length > 0) { + this.getEcharts() + } else { + this.getKnowledgeList() + } + }, 500) + } + }, created() {}, mounted() { let userInfo = sessionStorage.getItem('userInfo') @@ -154,6 +166,16 @@ export default { } this.getKnowledgeList() this.getAgentList() + window.addEventListener('resize', () => { + this.options.title.text = null + setTimeout(() => { + if (this.datasetList.length > 0) { + this.getEcharts() + } else { + this.getKnowledgeList() + } + }, 300) + }) }, methods: { getEcharts() { @@ -277,7 +299,7 @@ export default { } }, computed: { - ...mapGetters(['name', 'sidebarLogo']) + ...mapGetters(['sidebar', 'sidebarList']) } }