Browse Source

feat(frontend): 添加删除设备配置功能并优化删除操作逻辑

- 新增 delDviceConfig 函数以实现删除设备配置
-优化删除操作的交互逻辑,使用 async/await 方式处理异步操作
- 移除冗余的事件监听器,简化代码结构
panqiuyao 3 tháng trước cách đây
mục cha
commit
9b9f5789d9

+ 6 - 0
frontend/src/apis/setting.ts

@@ -49,6 +49,12 @@ export async function setTabName(data){
 
 }
 
+//删除可执行命令
+export async function delDviceConfig(data){
+    return POST('/api/ai_image/camera_machine/remove_device_config',data)
+
+}
+
 
 
 

+ 11 - 15
frontend/src/views/Setting/components/action_config.vue

@@ -99,7 +99,7 @@ const clientStore = client();
 import socket from "@/stores/modules/socket";
 const socketStore = socket(); // WebSocket状态管理实例
 
-import  { getTopTabs, getDeviceConfigs,setLeftRightConfig,restConfig,setTabName } from '@/apis/setting'
+import  { getTopTabs, getDeviceConfigs,setLeftRightConfig,restConfig,setTabName,delDviceConfig } from '@/apis/setting'
 
 // 表格数据和对话框状态
 const tableData = ref([]); // 配置表格数据
@@ -247,21 +247,17 @@ const deleteRow = (row, index) => {
     confirmButtonText: '确定',
     cancelButtonText: '取消',
     type: 'warning'
-  }).then(() => {
-    clientStore.ipc.send(icpList.setting.removeDeviceConfig, {
+  }).then(async () => {
+
+
+    const result =  await delDviceConfig({
       id: row.id
-    });
-    clientStore.ipc.on(icpList.setting.removeDeviceConfig, (event, result) => {
-      if (result.code == 0) {
-        getList();
-        ElMessage.success('删除成功');
-      }  else if(result.mssg){
-        ElMessage.error(result.mssg);
-      }else {
-        ElMessage.error('删除失败');
-      }
-      clientStore.ipc.removeAllListeners(icpList.setting.removeDeviceConfig);
-    });
+    })
+
+    if (result.code == 0) {
+      getList();
+      ElMessage.success('删除成功');
+    }
   });
 };