heyujie
2021-03-03 0961ee5718e67c942937647cf4ee471e236e4edc
应用中心和更新的逻辑
1个文件已修改
418 ■■■■ 已修改文件
src/pages/ai/index/App.vue 418 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/ai/index/App.vue
@@ -97,7 +97,7 @@
                              </div>
                              <div
                                class="info-onmask"
                                @click="checkDetail(item)"
                                @click="checkDetail(item, 'active')"
                              >
                                查看详情
                              </div>
@@ -115,7 +115,7 @@
                                  type="warning"
                                  size="small"
                                  class="bot-btn"
                                  >升级</el-button
                                  >升级1</el-button
                                >
                              </div>
                            </div>
@@ -234,7 +234,8 @@
                              </div>
                              <div
                                class="info-onmask"
                                @click="checkDetail(item)"
                                @click="checkDetail(item,'active')"
                                  v-if="!item.isDefault"
                              >
                                查看详情
                              </div>
@@ -253,7 +254,7 @@
                                  type="warning"
                                  size="small"
                                  class="bot-btn"
                                  >升级</el-button
                                  >升级2</el-button
                                >
                              </div>
                            </div>
@@ -376,7 +377,7 @@
                      <div class="list-choose-item-left">
                        <div class="list-complete-item-handle">
                          <div class="alg-icon svg-wrap">
                            <div class="mask" @click="actSdkOrApp(item.id)">
                            <!-- <div class="mask" @click="actSdkOrApp(item.id)">
                              <span
                                class="iconfont iconyunxiazai"
                                style="
@@ -387,6 +388,33 @@
                                  left: 45%;
                                "
                              ></span>
                            </div> -->
                            <div
                              class="mask"
                              v-if="!item.isDefault || item.isUpgrade"
                            >
                              <div class="left-top">
                                <div>当前版本:{{ item.version }}</div>
                                <div v-if="item.remoteVersion">
                                  最新版本:{{ item.remoteVersion }}
                                </div>
                              </div>
                              <div
                                class="info-onmask"
                                @click="actSdkOrApp(item)"
                              >
                                查看详情
                              </div>
                              <div class="mask-btn">
                                <el-button
                                  @click="actSdkOrApp(item)"
                                  type="primary"
                                  size="small"
                                  class="bot-btn"
                                  >激活</el-button
                                >
                              </div>
                            </div>
                            <img
                              v-if="item.iconBlob"
@@ -429,9 +457,9 @@
                      <div class="list-choose-item-left">
                        <div class="list-complete-item-handle">
                          <div class="alg-icon svg-wrap">
                            <div
                            <!-- <div
                              class="mask"
                              @click="actSdkOrApp(item.id, 'app')"
                              @click="actSdkOrApp(item, 'app')"
                            >
                              <span
                                class="iconfont iconyunxiazai"
@@ -443,6 +471,33 @@
                                  left: 45%;
                                "
                              ></span>
                            </div> -->
                             <div
                              class="mask"
                              v-if="!item.isDefault || item.isUpgrade"
                            >
                              <div class="left-top">
                                <div>当前版本:{{ item.version }}</div>
                                <div v-if="item.remoteVersion">
                                  最新版本:{{ item.remoteVersion }}
                                </div>
                              </div>
                              <div
                                class="info-onmask"
                                @click="actSdkOrApp(item,'app')"
                              >
                                查看详情
                              </div>
                              <div class="mask-btn">
                                <el-button
                                  @click="actSdkOrApp(item,'app')"
                                  type="primary"
                                  size="small"
                                  class="bot-btn"
                                  >激活</el-button
                                >
                              </div>
                            </div>
                            <img
                              v-if="item.iconBlob"
@@ -593,7 +648,7 @@
                              </div>
                              <div
                                class="info-onmask"
                                @click="checkDetail(item)"
                                @click="checkDetail(item,'active')"
                              >
                                查看详情
                              </div>
@@ -611,7 +666,7 @@
                                  type="warning"
                                  size="small"
                                  class="bot-btn"
                                  >升级</el-button
                                  >升级3</el-button
                                >
                              </div>
                            </div>
@@ -680,7 +735,7 @@
                              </div>
                              <div
                                class="info-onmask"
                                @click="checkDetail(item)"
                                @click="checkDetail(item,'active')"
                              >
                                查看详情
                              </div>
@@ -699,7 +754,7 @@
                                  type="warning"
                                  size="small"
                                  class="bot-btn"
                                  >升级</el-button
                                  >升级4</el-button
                                >
                              </div>
                            </div>
@@ -800,7 +855,7 @@
      </div>
<!-- </el-button-group> -->
      <div class="dialog-title" slot="title">{{curCheckTarget.sdk_type===undefined?"应用详情":"算法详情"}}</div>
      <div class="dialog-title" slot="title">{{isSDKDialog?"算法详情":"应用详情"}}</div>
      <div class="dialog-content">
        <div class="box-top">
          <div class="top-left">
@@ -877,15 +932,28 @@
                >软件</span> -->
                </div>
                <div class="btns">
                  <el-button size="medium" type="warning" @click="upgrade">{{
                  <el-button size="medium" type="warning" v-if="needToUpgradeInWin" @click="upgradeSDKinWin" >{{
                    isUpgrading ? "升级中.." : "升级"
                  }}</el-button>
                  <el-button size="medium" type="primary" @click="unload"
                    >卸载</el-button
                  <el-button size="medium" type="primary" v-if="isActive" @click="unloadSDKinWin">卸载</el-button>
                  <el-button size="medium" type="primary" v-if="!isActive" @click="showInputCode=!showInputCode">下载激活</el-button>
                  <el-button size="medium" type="success" v-if="!isSDKDialog">打开</el-button>
                </div>
              </div>
            </div>
            <div class="jihuo-input" v-if="showInputCode">
                        <el-input size="small"
                          v-model="activeCode"
                          placeholder="00000-00000-00000-00000-00000"
                          @blur="getCodeDetail"
                        ></el-input>
                         <el-button type="primary" size="small" @click="actived"
                          >激活</el-button
                  >
                  <el-button size="medium" type="success">打开</el-button>
                </div>
              </div>
                           <el-button type="primary" size="small" @click="cancelActivate"
                          >取消</el-button
                        >
            </div>
            <div class="product-intruduction">
              <div class="part-title">简介</div>
@@ -905,7 +973,7 @@
                  <div>
                    {{
                      productDetail.description === ""
                        ? "暂无数据"
                        ? "暂无数据 索采用大数据架构,分布检索毫秒级返回"
                        : productDetail.description
                    }}
                  </div>
@@ -915,7 +983,7 @@
                  <div>
                    {{
                      productDetail.summary === ""
                        ? "暂无数据"
                        ? "暂无数据 可支持海量数据复杂检索毫秒级返回,设计有智能检索框可支持海量数据复杂检索毫检索毫秒级返回,设计有智能检索框可支持海量数据复杂检索毫秒级返回,设计有智"
                        : productDetail.summary
                    }}
                  </div>
@@ -980,6 +1048,43 @@
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
    <el-dialog
    title="激活成功!"
  :visible.sync="showActivateSuccess"
  width="30%"
  :before-close="handleClose"
    >
      <div class="dialog-active">
        <ul class="desc">
          <li>
            <label>激活码:</label>
            <span>{{ activedSdkOrApp.activateCode }}</span>
          </li>
          <li>
            <label>产品名称:</label>
            <span>{{ activedSdkOrApp.productName }}</span>
          </li>
          <li>
            <label>配置详情:</label>
            <span>{{ activedSdkOrApp.setting }}</span>
          </li>
          <li>
            <label>服务到期日:</label>
            <span>{{ activedSdkOrApp.expireTime }}</span>
          </li>
          <li>
            <label>许可证:</label>
            <span>{{ activedSdkOrApp.licence }}</span>
          </li>
        </ul>
        <div class="text-right">
          <el-button type="primary" @click="checkMyAlgorith"
            >确定</el-button
          >
          <p class="tip">提示:请在“我的算法”中查看并安装算法</p>
        </div>
      </div>
    </el-dialog>
@@ -1062,15 +1167,19 @@
      direction: "rtl",
      actDrawerShow: false,
      actStep: 0,
      showActivateSuccess:false,
      activeCode: "",
      isInstall: false,
      installDialogVisible: false,
      installPackage: {},
      installAppPackage: null,
      installSdkPackage: null,
      isActive:true,
      installPercentage: 0,
      unActivedSDKList: [],
      unActivedAppList: [],
      // dialogTitle: "",
      isSDKDialog:true,
      //actSdkId: '',
      actType: "",
      actId: "",
@@ -1100,6 +1209,8 @@
      forwardStack: [],
      backDisable:true,
      forwardDisable:true,
      showInputCode:false,
      needToUpgradeInWin:false,
    };
  },
  directives: {
@@ -1141,9 +1252,22 @@
      this.productDetail = {}
      this.otherProducts = []
    },
    checkDetail(item) {
    checkDetail(item,type) {
      if (type =='inactive') {
        this.isActive =false
        this.showInputCode = false
      }else{
        this.showInputCode = false
         this.isActive =true
      }
        this.needToUpgradeInWin = item.isUpgrade?true:false
      this.resetStack()
      this.curCheckTarget = item;
      if (item.sdk_type===undefined) {
       this.isSDKDialog=false
      }else{
       this.isSDKDialog=true
      }
      // debugger
      this.productDetailVisible = true;
      let _this = this;
@@ -1162,16 +1286,28 @@
    },
    checkInWindow(item){
      this.backStack.push(this.productDetail)
      console.log(this.backStack);
      // debugger
      this.backDisable = false
      this.curCheckTarget = item;
      // this.productDetailVisible = true;
      let _this = this;
      getAppDetail({ id: item.id }).then((res) => {
        _this.productDetail = res.data.detail;
        // debugger
        this.actId = _this.productDetail.productBaseId
        let flag=false
       const allNeedToNew = [...this.hasNewVersionSdk,...hasNewVersionApp]
        for (let i = 0; i < allNeedToNew.length; i++) {
          const item = allNeedToNew[i];
          if (item.id == _this.productDetail.productBaseId) {
            flag=true
          }
        }
        this.needToUpgradeInWin = true
        _this.otherProducts = res.data.randoms;
      });
    },
    backwards(){
      if (this.backStack.length ==0) {
        this.backDisable = true
@@ -1180,7 +1316,6 @@
      }
      console.log(this.backStack);
      // debugger
   this.forwardStack.push(this.productDetail)
   this.productDetail =  this.backStack.pop()
  this.forwardDisable=false
@@ -1194,7 +1329,6 @@
        this.forwardDisable=true
        return
      }
      // debugger
      console.log(this.backStack);
        this.backStack.push(this.productDetail)
@@ -1239,17 +1373,7 @@
          });
        });
    },
    upgrade() {
      this.isUpgrading = !this.isUpgrading;
      setTimeout(() => {
        this.$notify({
          title: "成功",
          message: "升级完成",
          type: "success",
        });
        this.isUpgrading = !this.isUpgrading;
      }, 1200);
    },
    downloadApp(app, action) {
      if (action == "upgrade") {
        app.upgradeLoading = true;
@@ -1324,34 +1448,7 @@
      this.storeApps = sArry;
      this.hasNewVersionApp = nArry;
    },
    //卸载算法
    unLoadSdk(sdk) {
      let _this = this;
      this.$confirm("确定要卸载该算法吗?", "提示")
        .then(() => {
          sdk.unloadLoading = true;
          removeSdk({ sdkId: sdk.id })
            .then((res) => {
              if (res && res.success) {
                sdk.unloadLoading = false;
                _this.getAllSdk();
                window.parent.postMessage(
                  {
                    msg: "AppUpdate",
                  },
                  "*"
                );
              }
            })
            .catch((e) => {
              console.log(e);
              sdk.unloadLoading = false;
            });
        })
        .catch((e) => {
          console.log(e);
        });
    },
    //卸载应用
    unLoad(app) {
      let _this = this;
@@ -1387,13 +1484,19 @@
    //   this.activeCode = '';
    //   this.activedSdkOrApp = this.newActInfo()
    // },
    actSdkOrApp(id, type = "sdk") {
    actSdkOrApp(item, type = "sdk") {
      this.checkDetail(item, 'inactive')
      this.actType = type;
      this.actId = id;
      this.actDrawerShow = true;
      // debugger
      this.actId = item.id;
      // this.actDrawerShow = true;
      this.actStep = 0;
      this.activeCode = "";
      this.activedSdkOrApp = this.newActInfo();
    },
    cancelActivate(){
      this.showInputCode= false
    },
    newActInfo() {
      return {
@@ -1426,7 +1529,9 @@
        actPageAlg(this.actId, this.activeCode)
          .then((res) => {
            if (res.data.isSuccess) {
              this.productDetailVisible = false
              _this.activedSdkOrApp = res.data.successMsg;
              this.showActivateSuccess=true
              _this.actStep++;
              _this.getUnActivedList();
              _this.getAllSdk();
@@ -1445,7 +1550,9 @@
        actApp(this.actId, this.activeCode)
          .then((res) => {
            if (res.data.isSuccess) {
              this.productDetailVisible = false
              _this.activedSdkOrApp = res.data.successMsg;
              this.showActivateSuccess=true
              _this.actStep++;
              _this.getUnActivedAppList();
              _this.getAllApps();
@@ -1463,7 +1570,7 @@
    },
    getCodeDetail() {},
    checkMyAlgorith() {
      this.actDrawerShow = false;
      this.showActivateSuccess = false;
      this.activeName = "myAlgorithm";
    },
    onFileUpload(file) {
@@ -1503,25 +1610,7 @@
          });
        });
    },
    unload() {
      this.$confirm("确定要卸载该算法么?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "卸载成功!",
          });
        })
        .catch(() => {
          // this.$message({
          //   type: 'info',
          //   message: '已取消卸载'
          // });
        });
    },
    onFileAdded(f) {
      this.patchUpdateStatus = "";
@@ -1548,11 +1637,80 @@
          //算法软件 已安装其中包含待升级 未安装
          item.installed ? installedList.push(obj) : unInstalledList.push(obj);
          item.isUpgrade ? hasNewVersionList.push(obj): null
        });
      }
      this.installedList = installedList;
      this.notInstalledList = unInstalledList;
      this.hasNewVersionSdk = hasNewVersionList;
    },
    unloadSDKinWin(){
      let _this = this;
      this.$confirm("确定要卸载该算法么?", "提示").then(()=>{
        _this.productDetailVisible = false
        removeSdk({sdkId:this.productDetail.productBaseId}).then((res)=>{
          _this.getAllSdk();
          window.parent.postMessage(
            {
              msg: "AppUpdate",
            },
            "*"
          );
        }).catch((err)=>{
           console.log(err);
        })
      }).catch(()=>{
      })
    },
    //卸载算法
    unLoadSdk(sdk) {
      let _this = this;
      this.$confirm("确定要卸载该算法吗?", "提示")
        .then(() => {
          sdk.unloadLoading = true;
          removeSdk({ sdkId: sdk.id })
            .then((res) => {
              if (res && res.success) {
                sdk.unloadLoading = false;
                _this.getAllSdk();
                window.parent.postMessage(
                  {
                    msg: "AppUpdate",
                  },
                  "*"
                );
              }
            })
            .catch((e) => {
              console.log(e);
              sdk.unloadLoading = false;
            });
        })
        .catch((e) => {
          console.log(e);
        });
    },
    upgradeSDKinWin(){
      this.isUpgrading = !this.isUpgrading;
      downloadSdk({path:this.productDetail.productBaseId}).then((res)=>{
        this.$notify({
          title: "成功",
          message: "升级完成",
          type: "success",
        });
        this.isUpgrading = !this.isUpgrading;
      }).catch((err)=>{
        this.$notify({
          title: "升级失败",
          message: err.data,
          type: "warning",
        });
        this.isUpgrading = !this.isUpgrading;
      })
      this.sdkUpgreading = true;
    },
    donwload(item) {
@@ -1675,22 +1833,31 @@
    .dialog-content {
      .box-top {
        height: 380px;
        height: 350px;
        .top-left {
          float: left;
          width: 55%;
          background-color: rgba(253, 253, 253, 1);
          margin: 0 0.5%;
          height: 380px;
          height: 350px;
          .banner {
        text-align: center;
        margin-top: 30px;
            margin-top: 11px;
        // margin-top: 15px;
           video {
            margin: 20px auto;
            margin: 0px auto;
                margin-top: 25px;
            width: 443px;
          height: 277px;
            // background: aquamarine;
          }
          img{
             max-width: 500px;
                 margin-top: 21px;
          }
          }
        }
@@ -1699,25 +1866,28 @@
          width: 43%;
          margin: 0 0.5%;
          // background-color: lightgoldenrodyellow;
          height: 380px;
          height: 350px;
          background-color: rgba(253, 253, 253, 1);
          position: relative;
          overflow: hidden;
          .summary {
            height: 140px;
            margin: 5px;
                margin: 5px 5px 0 5px;
            .icon {
              margin: 0 5px;
              margin-top: 5px;
              float: left;
              .baseImg{
                max-width: 128px;
                max-height: 128px;
                max-width: 120px;
                max-height: 120px;
              }
            }
            .right-desc {
              float: left;
              position: absolute;
              left: 150px;
             left: 145px;
              .name {
                font-size: 30px;
                // font-weight: bold;
@@ -1730,23 +1900,42 @@
                }
              }
            }
          }
           .jihuo-input{
             margin-left: 10px;
             margin-bottom: 10px;
              .el-input{
                float: left;
                width: 64%;
                margin-right: 10px;
              }
              el-button{
                float: left;
              }
          }
          .product-intruduction {
            height: 230px;
            height: 200px;
            // background-color: lightgrey;
            .part-title {
              display: block;
              line-height: 35px;
                  line-height: 20px;
              font-size: 16px;
              margin-left: 24px;
              // height: 30px;
              border-bottom: 3px solid #3d68e1;
              width: fit-content;
              margin-bottom: 8px;
              height: 35px;
              // margin-bottom: 8px;
                 height: 26px;
margin-bottom: 6px;
            }
            .text {
              padding: 10px 15px;
                 height: 156px;
    overflow: auto;
    padding: 0 15px 0px 15px;
              .single-desc {
                margin-bottom: 10px;
              }
@@ -2526,5 +2715,34 @@
    }
  }
}
.dialog-active{
          .desc {
          padding: 0 30px;
          margin-bottom: 30px;
          li {
            border-bottom: 1px solid #eee;
            height: 45px;
            line-height: 45px;
            font-size: 14px;
            &:last-child {
              border-bottom: none;
            }
            label {
              display: inline-block;
              width: 90px;
              padding-left: 14px;
              font-weight: bold;
            }
          }
        }
        .text-right {
          padding-right: 30px;
          text-align: right;
          .tip {
            color: #999;
            line-height: 38px;
          }
        }
}
</style>