fix(app): 修复 Home 页面图表不能正确渲染的问题

- 更新 lineEcharts 组件的 key 属性,使用 options.title.text 替代 options.title
- 添加监听 sidebar.opened 变化的 watch 函数,重新渲染图表
- 在 mounted钩子中添加窗口大小变化的事件监听,重新渲染图表- 更新 computed 属性,使用 sidebar 和 sidebarList 替代 sidebarLogo
This commit is contained in:
陈昱达
2025-05-12 14:57:02 +08:00
parent d4d7fb2351
commit 7a6989d2e9

View File

@@ -111,7 +111,7 @@
</div>
<div class="home-bottom-container">
<lineEcharts
:key="options.title"
:key="options.title.text"
:options="options"
style="width: 100%;height: 100%;background: unset"
></lineEcharts>
@@ -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'])
}
}
</script>