dygapp 4 роки тому
батько
коміт
1b49feeb22
3 змінених файлів з 20 додано та 6 видалено
  1. 8 1
      src/store/index.js
  2. 10 3
      src/views/systemctl/systemctl.vue
  3. 2 2
      vue.config.js

+ 8 - 1
src/store/index.js

@@ -44,7 +44,9 @@ const api = {
   secclient: '/api/secclient',
   secservice: '/api/secservice',
   secclientquery: '/api/secclientquery',
-  ipsecservicequery: '/api/ipsecservicequery'
+  ipsecservicequery: '/api/ipsecservicequery',
+  // 恢复默认配置
+  recover: '/api/recover'
 }
 export default new Vuex.Store({
   state: {
@@ -279,6 +281,11 @@ export default new Vuex.Store({
     async secservice ({ commit }, payload) {
       const res = await axios.post(`${api.secservice}`, payload)
       return res.data
+    },
+    // 恢复默认配置
+    async recover ({ commit }) {
+      const res = await axios.get(api.recover)
+      return res.data || res
     }
   },
   modules: {

+ 10 - 3
src/views/systemctl/systemctl.vue

@@ -5,8 +5,8 @@
     </el-header>
     <el-main class="main">
       <div>
-        <span>恢复出厂设置</span>
-        <el-button type="primary">执行恢复</el-button>
+        <span>恢复默认配置</span>
+        <el-button type="primary" @click="recoverClick">执行恢复</el-button>
       </div>
       <div>
         <span>设备重启</span>
@@ -27,9 +27,16 @@ export default {
   },
   mounted () {},
   methods: {
-    ...mapActions(['reboot']),
+    ...mapActions(['reboot', 'recover']),
     rebootClick () {
       this.reboot()
+    },
+    async recoverClick () {
+      const res = await this.recover()
+      console.log('recover:', res)
+      if (res && res.errcode === 0) {
+        this.$message.success('恢复默认配置成功,请重启设备!')
+      }
     }
   }
 }

+ 2 - 2
vue.config.js

@@ -12,8 +12,8 @@ module.exports = {
   devServer: {
     proxy: {
       '/api/': {
-        // target: 'http://localhost:7001'
-        target: 'http://192.168.100.100:36449'
+        target: process.env.VUE_APP_API_URL || 'http://localhost:7001'
+        // target: 'http://192.168.100.100:36449'
       }
     }
   }