refactor: resource delete

This commit is contained in:
wangjiahao
2025-07-23 15:27:28 +08:00
parent aa00222247
commit 9beb4f8089
2 changed files with 11 additions and 2 deletions
@@ -158,7 +158,7 @@ const afterTreeInit = () => {
}
const copyLoading = ref(false)
const emit = defineEmits(['nodeClick'])
const emit = defineEmits(['nodeClick', 'deleteCurResource'])
function createNewObject() {
addOperation({ opt: 'newLeaf' })
@@ -230,7 +230,8 @@ const operation = (opt: string, data: SQTreeNode) => {
dashboardApi.delete_resource({ id: data.id }).then(() => {
ElMessage.success(t('dashboard.delete_success'))
getTree()
dashboardStore.setCurComponent(null)
dashboardStore.canvasDataInit()
emit('deleteCurResource')
})
})
} else if (opt === 'rename') {
@@ -48,6 +48,13 @@ const mounted = computed(() => {
function createNew() {
resourceTreeRef.value?.createNewObject()
}
const stateInit = () => {
state.canvasDataPreview = []
state.canvasStylePreview = {}
state.canvasViewInfoPreview = {}
state.dashboardInfo = {}
}
const loadCanvasData = (params: any) => {
dataInitState.value = false
load_resource_prepare(
@@ -100,6 +107,7 @@ defineExpose({
:cur-canvas-type="'dashboard'"
:show-position="showPosition"
@node-click="resourceNodeClick"
@delete-cur-resource="stateInit"
/>
</el-aside>
<el-container