Browse Source

修改构建页面

Prevalence 7 years ago
parent
commit
8554258877

+ 6 - 5
mock/serializers/dlwork/DLProjectSerializer.js

@@ -1,6 +1,6 @@
 const makeId = require("../../util/makeId");
 const buildSerializer = require("../codehw/BuildSerializer");
-const deploySerializer = require("../codehw/DeploySerializer");
+const unitTestSerializer = require("../codehw/UnitTestSerializer");
 
 /**
  * @description 代码作业项目的基本信息
@@ -30,10 +30,11 @@ module.exports = ({ id = makeId(), codeId = makeId() }) => {
       buildSerializer({ buildState: 1 }),
       buildSerializer({ buildState: -1 })
     ],
-    deployList: [
-      deploySerializer({ deployState: 0 }),
-      deploySerializer({ deployState: 1 }),
-      deploySerializer({ deployState: -1 })
+    dlTestList: [
+      unitTestSerializer({}),
+      unitTestSerializer({}),
+      unitTestSerializer({}),
+      unitTestSerializer({})
     ],
     config: {},
     pageUrl: "www.pageUrl.com/xiaobai/handsome/smart/dl"

+ 2 - 3
src/router/routes.js

@@ -223,9 +223,8 @@ export default [
               import("@/views/student/Code/ProjectDetail/BuildDetail")
           },
           {
-            path: "deploy",
-            component: () =>
-              import("@/views/student/Code/ProjectDetail/DeployDetail")
+            path: "test",
+            component: () => import("@/views/student/DlWork/DLTestDetail.vue")
           }
         ]
       },

+ 155 - 0
src/views/student/DlWork/DLTestDetail.vue

@@ -0,0 +1,155 @@
+<template>
+  <div class="columns is-desktop">
+    <div class="column">
+      <div v-if="detailLoading"><page-section-loading show /></div>
+      <div v-else class="page-section">
+        <h5 class="title is-5">机器学习测试:</h5>
+        <router-link
+          class="test-item"
+          :key="item.id"
+          :to="`${$route.path}/unit/${item.id}`"
+          v-for="item in dlTestList"
+          tag="div"
+        >
+          <div><strong>准确率测试 : #</strong> {{ item.id }}</div>
+          <span>准确率 : </span>
+          <div class="tag is-success" style="width: 40px;height:1.5em">
+            <strong style="color: white;">{{
+              item.accuracy ? item.accuracy : "100%"
+            }}</strong>
+          </div>
+          <br />
+          <span>得分 : </span>
+          <strong>{{ item.score ? item.score : "100" }}</strong
+          ><br />
+          <span>{{ displayUnixTime(item.time) }}</span>
+        </router-link>
+      </div>
+    </div>
+    <!--<div class="column">-->
+    <!--<div v-if="detailLoading"><page-section-loading show /></div>-->
+    <!--<div v-else class="page-section">-->
+    <!--<h5 class="test-title title is-5">-->
+    <!--页面测试:-->
+    <!--<div-->
+    <!--v-if="functionTestList && functionTestList.length > 0"-->
+    <!--:class="{ 'is-loading': testing }"-->
+    <!--@click="makeTest"-->
+    <!--class="button is-primary test-title__action"-->
+    <!--&gt;-->
+    <!--触发测试-->
+    <!--</div>-->
+    <!--</h5>-->
+    <!--<router-link-->
+    <!--class="test-item"-->
+    <!--:key="item.id"-->
+    <!--:to="`${$route.path}/functional/${item.id}`"-->
+    <!--v-for="item in functionTestList"-->
+    <!--tag="div"-->
+    <!--&gt;-->
+    <!--<div><strong>FUNCTIONAL TEST : #</strong> {{ item.id }}</div>-->
+    <!--<pass-tag :pass="item.isPassAll" />-->
+    <!--<span style="padding-left: 10px">{{-->
+    <!--displayUnixTime(item.time)-->
+    <!--}}</span>-->
+    <!--</router-link>-->
+    <!--</div>-->
+    <!--</div>-->
+  </div>
+</template>
+
+<script>
+import timeMixins from "@/mixins/time";
+// import { makeFunctionalTest } from "@/api/codehw";
+import PageSectionLoading from "@/components/PageBody/PageSectionLoading/index";
+
+export default {
+  components: { PageSectionLoading },
+  props: {
+    projectDetail: {
+      type: Object,
+      default: () => ({
+        dlTestList: []
+      })
+    },
+    detailLoading: {
+      type: Boolean,
+      default: false
+    }
+  },
+  computed: {
+    dlTestList() {
+      return this.sortTestList(this.projectDetail.dlTestList);
+    }
+  },
+  data() {
+    return {
+      testing: false
+    };
+  },
+  mixins: [timeMixins],
+  methods: {
+    // async makeTest() {
+    //   const { functionTestList } = this;
+    //   if (functionTestList && functionTestList.length > 0) {
+    //     this.testing = true;
+    //     const { deployId } = functionTestList[0];
+    //     const { homeworkId, projectId } = this.$route.params;
+    //     const { data } = await makeFunctionalTest({
+    //       homeworkId,
+    //       projectId,
+    //       deployId
+    //     });
+    //     this.testing = false;
+    //     if (data.success) {
+    //       this.$toast.open({
+    //         message: `测试触发成功`,
+    //         type: "is-success"
+    //       });
+    //     } else {
+    //       this.$toast.open({
+    //         message: `测试触发失败`,
+    //         type: "is-danger"
+    //       });
+    //     }
+    //   }
+    // },
+    sortTestList(list) {
+      console.log(list);
+      if (!list) return [];
+      const copyList = list.slice(0);
+      copyList.sort((a, b) => b.time - a.time);
+      return copyList;
+    }
+  }
+};
+</script>
+
+<style lang="scss" scoped>
+@import "../../../assets/scss/app";
+
+.test-item {
+  padding: $default-margin $default-margin-between;
+  margin: 0 -#{$default-margin-between};
+  cursor: pointer;
+}
+
+.test-title {
+  position: relative;
+
+  &__action {
+    position: absolute;
+    right: 0;
+    transform: translateY(-20%);
+  }
+}
+
+.test-item:hover,
+.test-item:nth-child(even):hover {
+  background-color: #dde3ef;
+}
+
+.test-item:nth-child(even) {
+  background-color: rgba(244, 247, 252, 0.6);
+}
+</style>

+ 8 - 7
src/views/student/DlWork/detail.vue

@@ -9,22 +9,22 @@
           path: `dlwork/${$route.params.homeworkId}`
         },
         {
-          name: '部署',
-          path: `dlwork/${$route.params.homeworkId}/deploy`
+          name: '测试',
+          path: `dlwork/${$route.params.homeworkId}/test`
         }
       ]"
     >
       <template slot="title">
-        {{ projectDetail.name }}
+        {{ dlTestDetail.name }}
       </template>
       <template slot="content">
         <strong>git 地址 : </strong>
-        <a :href="projectDetail.url">{{ projectDetail.url }}</a>
+        <a :href="dlTestDetail.url">{{ dlTestDetail.url }}</a>
       </template>
     </page-header>
     <page-body>
       <router-view
-        :project-detail="projectDetail"
+        :project-detail="dlTestDetail"
         :detail-loading="detailLoading"
       />
     </page-body>
@@ -42,7 +42,7 @@ export default {
   },
   data() {
     return {
-      projectDetail: {},
+      dlTestDetail: {},
       detailLoading: false
     };
   },
@@ -50,7 +50,8 @@ export default {
     const { dlworkId } = this.$route.params.homeworkId;
     this.detailLoading = true;
     const detail = await getDLProjectDetail(dlworkId);
-    this.projectDetail = detail.data;
+    this.dlTestDetail = detail.data;
+    console.log(this.dlTestDetail);
     this.detailLoading = false;
   }
 };