Ver Fonte

fix 学生代码作业部署因null产生的页面异常

靳炳淑 há 6 anos atrás
pai
commit
d3d1ba17c8
1 ficheiros alterados com 18 adições e 8 exclusões
  1. 18 8
      src/views/student/Code/ProjectDetail/DeployDetail.vue

+ 18 - 8
src/views/student/Code/ProjectDetail/DeployDetail.vue

@@ -296,14 +296,20 @@ export default {
     //获取最新一次部署信息
     getLatestDeployInfo() {
       this.test.deployInfo = this.projectDetail.deploy.latestTestDeploy;
-      this.test.latestDeployId = this.projectDetail.deploy.latestTestDeploy.id;
-      this.test.deployStatus = this.projectDetail.deploy.latestTestDeploy.status;
-      this.test.isRunning = this.test.deployStatus == "RUNNING" ? true : false;
+      if (this.projectDetail.deploy.latestTestDeploy) {
+        this.test.latestDeployId = this.projectDetail.deploy.latestTestDeploy.id;
+        this.test.deployStatus = this.projectDetail.deploy.latestTestDeploy.status;
+        this.test.isRunning =
+          this.test.deployStatus == "RUNNING" ? true : false;
+      }
 
       this.prod.deployInfo = this.projectDetail.deploy.latestProdDeploy;
-      this.prod.latestDeployId = this.projectDetail.deploy.latestProdDeploy.id;
-      this.prod.deployStatus = this.projectDetail.deploy.latestProdDeploy.status;
-      this.prod.isRunning = this.prod.deployStatus == "RUNNING" ? true : false;
+      if (this.projectDetail.deploy.latestProdDeploy) {
+        this.prod.latestDeployId = this.projectDetail.deploy.latestProdDeploy.id;
+        this.prod.deployStatus = this.projectDetail.deploy.latestProdDeploy.status;
+        this.prod.isRunning =
+          this.prod.deployStatus == "RUNNING" ? true : false;
+      }
     },
     //处理时间格式
     handleTime(time) {
@@ -396,8 +402,12 @@ export default {
       getBuildImage(projectId)
         .then(res => {
           console.log("getBuildImage", res);
-          this.test.latestBuildList = [res.data.testBuildRecord];
-          this.prod.latestBuildList = [res.data.prodBuildRecord];
+          this.test.latestBuildList = res.data.testBuildRecord
+            ? [res.data.testBuildRecord]
+            : [];
+          this.prod.latestBuildList = res.data.prodBuildRecord
+            ? [res.data.prodBuildRecord]
+            : [];
         })
         .catch(e => {
           this.$toast.open({