From d5ce0b7e6d9ff8db84c03af0bef143024dd246ca Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期二, 03 十一月 2020 17:24:35 +0800
Subject: [PATCH] 调整应用中心定时器

---
 src/pages/ai/index/App.vue                     |   58 ++++++++++++-----------------
 vue.config.js                                  |    5 +-
 public/index.html                              |    5 +-
 src/pages/settings/components/BasicSetting.vue |    2 
 src/pages/desktop/index/App.vue                |    2 
 5 files changed, 32 insertions(+), 40 deletions(-)

diff --git a/public/index.html b/public/index.html
index 37db135..dfcc87a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -5,7 +5,7 @@
   <meta charset="utf-8" />
   <meta http-equiv="X-UA-Compatible" content="IE=edge" />
   <meta name="viewport" content="width=device-width,initial-scale=1.0" />
-  <link rel="icon" type="image/png" href="<%= BASE_URL %>favicon.png" sizes="32x32" />
+  <link rel="icon" type="image/png" href="<%= htmlWebpackPlugin.options.faviconPath%>" sizes="32x32" />
   <link rel="stylesheet" href="/fonts/alibaba/iconfont.css">
   <title><%= htmlWebpackPlugin.options.title %></title>
 
@@ -423,7 +423,8 @@
       color: #f90;
       font-size: 14px;
     }
-    .s-system-manage .el-tabs--border-card .el-tabs__header .el-tabs__item{
+
+    .s-system-manage .el-tabs--border-card .el-tabs__header .el-tabs__item {
       padding: 5px 50px;
       height: 50px;
       font-family: PingFangSC-Regular;
diff --git a/src/pages/ai/index/App.vue b/src/pages/ai/index/App.vue
index bbe69c6..08dae92 100644
--- a/src/pages/ai/index/App.vue
+++ b/src/pages/ai/index/App.vue
@@ -557,8 +557,9 @@
       storeApps: [],
       installFile: {},
       freshTimer: null,
-      appUpgreading: false,
-      sdkUpgreading: false
+      appUpgreading: true,
+      sdkUpgreading: true,
+      autoRefresh: true,
     }
   },
   directives: {
@@ -570,11 +571,13 @@
   },
   mounted() {
     // 鑾峰彇鎵�鏈夊簲鐢�
-    this.getAllSdk();
-    this.getAllApps();
+    this.autoRefreshAppAndSdkState();
 
     this.getUnActivedList();
     this.getUnActivedAppList();
+  },
+  beforeDestroy() {
+    this.autoRefresh = false;
   },
   methods: {
     isShow(authority) {
@@ -594,7 +597,6 @@
           });
           setTimeout(() => {
             this.getAllSdk();
-            this.getAllApps();
             window.parent.postMessage({
               msg: "AppUpdate"
             }, '*')
@@ -635,7 +637,7 @@
               //   message: '瀹夎鎴愬姛'
               // });
             }
-            _this.getAllApps();
+            // _this.getAllApps();
             window.parent.postMessage({
               msg: "AppUpdate"
             }, '*')
@@ -652,7 +654,6 @@
 
       // 寮�鍚嚜鍔ㄥ埛鏂�
       this.appUpgreading = true;
-      this.startAutoFresh();
     },
     async getAllApps() {
       let iArry = []
@@ -669,7 +670,6 @@
             obj.upgradeLoading = true;
 
             this.appUpgreading = true;
-            this.startAutoFresh();
           }
 
           item.installed ? iArry.push(obj) : sArry.push(obj)
@@ -850,32 +850,20 @@
       let unInstalledList = [];
       let res = await findAllSdk();
       if (res && res.success) {
+        this.sdkUpgreading = false;
 
         res.data.forEach(item => {
           let obj = Object.assign({ unloadLoading: false, upgradeLoading: false }, item)
           if (obj.progressMsg !== "" && obj.progressMsg !== "宸插畨瑁�") {
             obj.upgradeLoading = true;
 
-            this.appUpgreading = true;
-            this.startAutoFresh();
+            this.sdkUpgreading = true;
           }
 
           //绠楁硶杞欢 宸插畨瑁呭叾涓寘鍚緟鍗囩骇 鏈畨瑁�
           item.installed ? installedList.push(obj) : unInstalledList.push(obj)
 
         });
-
-
-        // this.sdkList = res.data.map((i, index) => {
-        //   if (i.progressMsg !== "" && i.progressMsg !== "宸插畨瑁�") {
-        //     i.upgradeLoading = true;
-
-        //     this.appUpgreading = true;
-        //     this.startAutoFresh();
-        //   }
-        //   this.$set(i, "isEdit", false);
-        //   return i;
-        // });
       }
       this.installedList = installedList;
       this.notInstalledList = unInstalledList;
@@ -895,7 +883,6 @@
           item.upgradeLoading = false;
           //this.downloading = false;
           this.downloadItem = "";
-          this.getAllSdk();
         })
         .catch(err => {
           this.$notify({
@@ -907,8 +894,7 @@
           this.downloadItem = "";
         });
       // 寮�鍚嚜鍔ㄥ埛鏂�
-      this.appUpgreading = true;
-      this.startAutoFresh();
+      this.sdkUpgreading = true;
     },
     inputBlur(item) {
       // console.log(item, '淇敼鍚嶇О')
@@ -917,20 +903,24 @@
     handleTabClick() {
 
     },
-    startAutoFresh() {
-      if (this.freshTimer) {
-        clearTimeout(this.freshTimer)
+    autoRefreshAppAndSdkState() {
+      // 鍏抽棴鍚庨��鍑�
+      if (!this.autoRefresh) {
+        return;
       }
 
-      if (!this.appUpgreading && !this.sdkUpgreading) {
-        this.freshTimer = -1
-        return
+      if (this.appUpgreading) {
+        this.getAllApps();
       }
 
-      this.getAllSdk()
-      this.getAllApps()
+      if (this.sdkUpgreading) {
+        this.getAllSdk();
+      }
 
-      this.freshTimer = setTimeout(this.startAutoFresh, 5 * 1000)
+      let _this = this
+      setTimeout(() => {
+        _this.autoRefreshAppAndSdkState();
+      }, 500)
     }
   }
 };
diff --git a/src/pages/desktop/index/App.vue b/src/pages/desktop/index/App.vue
index 9596368..4bbd122 100644
--- a/src/pages/desktop/index/App.vue
+++ b/src/pages/desktop/index/App.vue
@@ -68,7 +68,7 @@
         icon: '/images/desktop/message.png',
         tip: '娑堟伅',
         title: 'SmartAI',
-        body: config.version,
+        body: 'V' + config.version,
         time: new Date()
       }, true);
     }, 1000);
diff --git a/src/pages/settings/components/BasicSetting.vue b/src/pages/settings/components/BasicSetting.vue
index eab4d9a..8db1f78 100644
--- a/src/pages/settings/components/BasicSetting.vue
+++ b/src/pages/settings/components/BasicSetting.vue
@@ -543,7 +543,7 @@
 
           this.webPort = this.sysinfo.server_port;
 
-          this.sysinfo.webVersion = config.version;
+          this.sysinfo.webVersion = 'V' + config.version;
         }
 
         this.loading = false;
diff --git a/vue.config.js b/vue.config.js
index 47db11c..ee4c7aa 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -12,7 +12,8 @@
     entry: path,
     template: 'public/index.html',
     title: chunk == 'desktop/index' ? 'SmartAI' : chunk,
-    chunks: [chunk_vendor, 'chunk-common', chunk]
+    chunks: [chunk_vendor, 'chunk-common', chunk],
+    faviconPath: "favicon.png"
   }
   if (chunk != 'index') {
     pages[chunk].filename = 'view/' + chunk + '.html'
@@ -74,7 +75,7 @@
       },
       "/data/api-v/app/findAllApp": {
         target: '/',
-        target: 'http://localhost:8080/',
+        // target: 'http://localhost:8080/',
         changeOrigin: true,
         pathRewrite: {
           '^/data/api-v/app/findAllApp': 'apps.json'

--
Gitblit v1.8.0