zhangzengfei
2020-11-03 d5ce0b7e6d9ff8db84c03af0bef143024dd246ca
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)
    }
  }
};