From e9d3f200892d2f3f44d8301a607d4d076956b2d4 Mon Sep 17 00:00:00 2001
From: wangjiahao <1522128093@qq.com>
Date: Tue, 2 Sep 2025 22:48:23 +0800
Subject: [PATCH] refactor: Optimize the logic for adding charts to the
dashboard
---
frontend/src/views/chat/chat-block/ChartBlock.vue | 2 +-
.../views/dashboard/common/AddViewDashboard.vue | 14 ++++++--------
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/frontend/src/views/chat/chat-block/ChartBlock.vue b/frontend/src/views/chat/chat-block/ChartBlock.vue
index 6cb35b75..f589fc41 100644
--- a/frontend/src/views/chat/chat-block/ChartBlock.vue
+++ b/frontend/src/views/chat/chat-block/ChartBlock.vue
@@ -395,7 +395,7 @@ watch(
-
+
diff --git a/frontend/src/views/dashboard/common/AddViewDashboard.vue b/frontend/src/views/dashboard/common/AddViewDashboard.vue
index 3ae3c349..2070de5f 100644
--- a/frontend/src/views/dashboard/common/AddViewDashboard.vue
+++ b/frontend/src/views/dashboard/common/AddViewDashboard.vue
@@ -20,7 +20,6 @@ const optInit = (viewInfo: any) => {
resourceDialogShow.value = true
state.viewInfo = viewInfo
}
-const curOptDashboardId = ref(null)
const state = reactive({
dashboardList: [] as SQTreeNode[],
viewInfo: null,
@@ -127,20 +126,19 @@ const saveResourcePrepare = () => {
const saveResource = (params: any, commonParams: any) => {
saveDashboardResourceTarget(params, commonParams, (res: any) => {
const messageTips = t('dashboard.add_success')
- curOptDashboardId.value = res?.id
- openMessageLoading(messageTips, 'success', callbackExportSuc)
+ openMessageLoading(messageTips, 'success', res?.id, callbackExportSuc)
resetForm()
})
}
-const callbackExportSuc = () => {
+const callbackExportSuc = (curOptDashboardIdValue: any) => {
// do open dashboard
- const url = `#/canvas?resourceId=${curOptDashboardId.value}`
+ const url = `#/canvas?resourceId=${curOptDashboardIdValue}`
window.open(url, '_self')
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
-const openMessageLoading = (text: string, type = 'success', cb: Function) => {
+const openMessageLoading = (text: string, type = 'success', dvId: any, cb: Function) => {
// success error loading
const customClass = `sq-message-${type || 'success'} sq-message-export`
ElMessage({
@@ -161,7 +159,7 @@ const openMessageLoading = (text: string, type = 'success', cb: Function) => {
size: 'small',
class: 'btn-text',
onClick: () => {
- cb()
+ cb(dvId)
},
},
t('dashboard.open_dashboard')
@@ -169,7 +167,7 @@ const openMessageLoading = (text: string, type = 'success', cb: Function) => {
]),
type,
showClose: true,
- duration: 0,
+ duration: 2000,
customClass,
})
}