Skip to content

Commit 9beb4f8

Browse files
committed
refactor: resource delete
1 parent aa00222 commit 9beb4f8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

frontend/src/views/dashboard/common/ResourceTree.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const afterTreeInit = () => {
158158
}
159159
160160
const copyLoading = ref(false)
161-
const emit = defineEmits(['nodeClick'])
161+
const emit = defineEmits(['nodeClick', 'deleteCurResource'])
162162
163163
function createNewObject() {
164164
addOperation({ opt: 'newLeaf' })
@@ -230,7 +230,8 @@ const operation = (opt: string, data: SQTreeNode) => {
230230
dashboardApi.delete_resource({ id: data.id }).then(() => {
231231
ElMessage.success(t('dashboard.delete_success'))
232232
getTree()
233-
dashboardStore.setCurComponent(null)
233+
dashboardStore.canvasDataInit()
234+
emit('deleteCurResource')
234235
})
235236
})
236237
} else if (opt === 'rename') {

frontend/src/views/dashboard/preview/SQPreviewShow.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ const mounted = computed(() => {
4848
function createNew() {
4949
resourceTreeRef.value?.createNewObject()
5050
}
51+
52+
const stateInit = () => {
53+
state.canvasDataPreview = []
54+
state.canvasStylePreview = {}
55+
state.canvasViewInfoPreview = {}
56+
state.dashboardInfo = {}
57+
}
5158
const loadCanvasData = (params: any) => {
5259
dataInitState.value = false
5360
load_resource_prepare(
@@ -100,6 +107,7 @@ defineExpose({
100107
:cur-canvas-type="'dashboard'"
101108
:show-position="showPosition"
102109
@node-click="resourceNodeClick"
110+
@delete-cur-resource="stateInit"
103111
/>
104112
</el-aside>
105113
<el-container

0 commit comments

Comments
 (0)