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>
<div class="home-bottom-container"> <div class="home-bottom-container">
<lineEcharts <lineEcharts
:key="options.title" :key="options.title.text"
:options="options" :options="options"
style="width: 100%;height: 100%;background: unset" style="width: 100%;height: 100%;background: unset"
></lineEcharts> ></lineEcharts>
@@ -146,6 +146,18 @@ export default {
components: { components: {
lineEcharts lineEcharts
}, },
watch: {
'sidebar.opened': function(val) {
this.options.title.text = null
setTimeout(() => {
if (this.datasetList.length > 0) {
this.getEcharts()
} else {
this.getKnowledgeList()
}
}, 500)
}
},
created() {}, created() {},
mounted() { mounted() {
let userInfo = sessionStorage.getItem('userInfo') let userInfo = sessionStorage.getItem('userInfo')
@@ -154,6 +166,16 @@ export default {
} }
this.getKnowledgeList() this.getKnowledgeList()
this.getAgentList() this.getAgentList()
window.addEventListener('resize', () => {
this.options.title.text = null
setTimeout(() => {
if (this.datasetList.length > 0) {
this.getEcharts()
} else {
this.getKnowledgeList()
}
}, 300)
})
}, },
methods: { methods: {
getEcharts() { getEcharts() {
@@ -277,7 +299,7 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['name', 'sidebarLogo']) ...mapGetters(['sidebar', 'sidebarList'])
} }
} }
</script> </script>