Ver Fonte

Merge remote-tracking branch 'origin/dev-frontend' into dev-frontend

panqiuyao há 8 meses atrás
pai
commit
69a624710b

+ 1 - 1
electron/api/request.js

@@ -5,7 +5,7 @@ const axios = require('axios')
 
 // create an axios instance
 const service = axios.create()
-const baseUrl = 'http://127.0.0.1:7074/'
+const baseUrl = 'http://10.56.42.176:7074/'
 const basePrefixUrl = 'api'
 const timeout = 600000
 const uploadTimeout = 600000

+ 46 - 0
electron/api/setting.js

@@ -0,0 +1,46 @@
+const { post } = require('./request')
+
+module.exports = {
+  getDeviceConfigs(data){
+    return post({
+      url: '/get_device_configs'
+    })
+  },
+
+  getDeviceConfigDetail(data){
+    return post({
+      url: '/device_config_detail',
+      data: data,
+      headers:{
+        'Content-Type':"application/json",
+      }
+    })
+  },
+
+
+  //��̨ͼ
+  removeConfig(data){
+    return post({
+      url: '/remove_config',
+      data: data,
+      headers:{
+        'Content-Type':"application/json",
+      }
+    })
+  },
+
+ // �����
+  saveDeviceConfig(data){
+    return post({
+      url: '/save_device_config',
+      data: data,
+      headers:{
+        'Content-Type':"application/json",
+      }
+    })
+  },
+
+
+
+
+}

+ 82 - 0
electron/controller/setting.js

@@ -0,0 +1,82 @@
+'use strict';
+
+const { Controller } = require('ee-core');
+const Log = require('ee-core/log');
+const Services = require('ee-core/services');
+const path = require('path');
+const fs = require('fs');
+const { getDeviceConfigs, getDeviceConfigDetail, removeConfig, saveDeviceConfig } = require('../api/setting');
+
+
+/**
+ * 设置控制器
+ * @class
+ */
+class SettingController extends Controller {
+
+  constructor(ctx) {
+    super(ctx);
+    this.configPath = path.join(__dirname, '..', 'config', 'app.config.json');
+  }
+
+  /**
+   * 获取设备配置列表
+   */
+  async getDeviceConfigList(args) {
+    try {
+      console.log(2)
+      const result = await getDeviceConfigs(args);
+      console.log(result)
+      return result;
+    } catch (error) {
+      Log.error('获取设备配置列表失败:', error);
+      return [];
+    }
+  }
+
+  /**
+   * 获取设备配置详情
+   * @param {Object} args - 配置ID
+   */
+  async getDeviceConfigDetail(args) {
+    try {
+      const result = await getDeviceConfigDetail(args);
+      return result;
+    } catch (error) {
+      Log.error('获取设备配置详情失败:', error);
+      return null;
+    }
+  }
+
+  /**
+   * 删除设备配置
+   * @param {Object} args - 配置ID
+   */
+  async removeDeviceConfig(args) {
+    try {
+      const result = await removeConfig(args);
+      return result;
+    } catch (error) {
+      Log.error('删除设备配置失败:', error);
+      return false;
+    }
+  }
+
+  /**
+   * 保存设备配置
+   * @param {Object} args - 配置内容
+   */
+  async saveDeviceConfig(args) {
+    try {
+      const result = await saveDeviceConfig(args);
+      return result;
+    } catch (error) {
+      Log.error('保存设备配置失败:', error);
+      return false;
+    }
+  }
+
+}
+
+SettingController.toString = () => '[class SettingController]';
+module.exports = SettingController;

+ 6 - 0
frontend/src/utils/ipc.ts

@@ -20,6 +20,12 @@ const icpList = {
         openImage:"controller.utils.openImage",
         openFile:"controller.utils.openFile"
     },
+    setting:{
+        getDeviceConfigDetail: 'controller.setting.getDeviceConfigDetail',
+        removeConfig: 'controller.setting.removeConfig',
+        saveDeviceConfig: 'controller.setting.saveDeviceConfig',
+        getDeviceConfigList: 'controller.setting.getDeviceConfigList',
+    }
 }
 
 

+ 9 - 0
frontend/src/views/Setting/index.vue

@@ -442,6 +442,15 @@ watch(() => route.query.type, (newType) => {
     if (!isNaN(typeValue) && typeValue >= 0 && typeValue <= 3) {
       activeIndex.value = typeValue;
     }
+    if(newType === '4'){
+      console.log(1)
+      clientStore.ipc.removeAllListeners(icpList.setting.getDeviceConfigList);
+      clientStore.ipc.send(icpList.setting.getDeviceConfigList);
+      clientStore.ipc.on(icpList.setting.getDeviceConfigList, (event, result) => {
+        console.log(result);
+        clientStore.ipc.removeAllListeners(icpList.setting.getDeviceConfigList);
+      });
+    }
   }
 }, { immediate: true });