分布打包中途离开,如何重新获取进度

本地缓存相关策略:

1.sessionStorage或localStorage:setItem()、getItem()

2.store:

对比2种方式动态更新问题:

1.本地缓存初始化可以获取,但无法动态监听变化更新;

2.store,通过定义计算属性可以通过监听变化实时更新数据。

computed: {
      jarPackSessionLog() { // 打包日志1
        return sessionStorage.getItem('session_log_' + this.nodeId) ? JSON.parse(sessionStorage.getItem('log_' + this.nodeId)) : null
      },
      jarPackStoreLog() { // 打包日志2
        return this.$store.state.flowchartSearch.tensortflowLog || ''
      },
}

created() {// 初始化赋值+获取集群
this.packLogMsg = this.jarPackStoreLog || this.jarPackSessionLog || ''// 日志
}
// 存储方法:设置id区分不同日志
this.$store.commit('setTensortflowLog',{id:_this.nodeId,data:_this.packLogMsg})
sessionStorage.setItem('session_log_' + _this.nodeId, JSON.stringify(_this.packLogMsg) || null)
    watch: {
      jarPackStoreLog(val) {
        console.log(val,666);
        if(val){
          this.packLogMsg = val
        }
      }
    },

-end-

原文地址:https://www.cnblogs.com/wheatCatcher/p/12809188.html