mjh 3 éve
szülő
commit
3dda09b7e8

+ 1 - 1
src/App.vue

@@ -38,6 +38,6 @@ export default {
 <style lang="scss" scoped>
 /*Zhurui修改,消除底部对主体元素的覆盖*/
 .main-body {
-  margin-bottom: 250px;
+  //margin-bottom: 250px;
 }
 </style>

+ 63 - 25
src/components/ProjectCard.vue

@@ -1,33 +1,33 @@
 <template>
   <el-card class="project" shadow="hover" @click="toProjectInfo">
-
-    <div :style="{borderBottom: type==='courseProject' ? '30px solid #f5b86e' : '30px solid #8dc9e2'}"
-         style="float: right; width: 0; height: 0; position: absolute;right: 0;bottom: 0;border-left: 30px solid transparent;">
-      <div v-if="type==='courseProject'" style="padding: 0 4px 0 4px; position: absolute; right: 0; bottom: -30px; color: white">
-        D
+    <template #header>
+      <div class="project-header">
+        <span :title="this.projectVO['name']">
+          {{ this.projectVO["name"] }}
+        </span>
       </div>
-      <div v-else style="padding: 0 3px 0 3px; position: absolute; right: 0; bottom: -30px; color: white">
-        P
+    </template>
+    <div class="project-logo">
+      <div class="project-logo-text">
+        D
       </div>
     </div>
     <el-row class="projectId">
       {{ projectId }}
     </el-row>
-    <el-row>
-      {{ name }}
+    <el-row class="project-description">
+      {{ description }}
     </el-row>
-    <el-row>
-      {{description}}
-    </el-row>
-    <el-row>
-      {{ link }}
+    <el-row class="project-link">
+      <el-button type="text" style="padding: 0" @click.stop="copyLink(projectVO['gitRemoteUrl'])">复制链接</el-button>
     </el-row>
   </el-card>
 </template>
 
 <script>
-import {ElMessage, ElMessageBox} from "element-plus";
+import {ElMessage} from "element-plus";
 import store from "@/store";
+import colorUtil from "@/utils/color";
 
 export default {
   name: "ProjectCard",
@@ -38,6 +38,7 @@ export default {
   data() {
     return {
       teacher: Object,
+      color: colorUtil.SYSTEM_THEME.developerColor,
     };
   },
   computed: {
@@ -51,17 +52,11 @@ export default {
       return this.$store.getters.isStudent;
     },
     projectId() {
-      return "Id: " + this.projectVO.id;
-    },
-    name() {
-      return "名称: " + this.projectVO.name;
+      return "项目ID: " + this.projectVO.id;
     },
     description() {
       return "描述: " + this.projectVO.description;
     },
-    link() {
-      return "链接: " + this.projectVO.gitRemoteUrl;
-    },
   },
 
   methods: {
@@ -74,13 +69,16 @@ export default {
           duration: 1000,
         });
         await this.$router.push({name: "Auth", params: {login_to: "/portal"}});
-        return;
       } else {
         if (this.projectVO.name) {
           window.open("https://devcloud.seec.seecoder.cn/project/" + this.projectVO.id + "/schedule?id_token=" + this.$store.state.user.token);
         }
-        return;
       }
+    },
+
+    async copyLink(link) {
+      await navigator.clipboard.writeText(link);
+      this.$message.success("复制成功!");
     }
   }
 };
@@ -101,9 +99,49 @@ export default {
 }
 
 .projectId {
-  font-weight: bold;
+  /*font-weight: bold;*/
+  font-size: medium;
+  color: #777777;
+}
+
+.project-header {
+  width: 100%;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+
+.project-description {
+  width: 100%;
+  display: -webkit-box; /*必须结合的属性,将对象作为弹性伸缩盒子模型显示*/
+  -webkit-line-clamp: 2; /*设置多少行*/
+  -webkit-box-orient: vertical; /*必须结合的属性,设置或检索伸缩盒对象的子元素的排列方式*/
+  overflow: hidden; /*文本会被修剪,并且剩余的部分不可见*/
+  text-overflow: ellipsis;
   font-size: medium;
+  color: #777777;
 }
 
+.project-link {
+  font-size: medium;
+}
+
+.project-logo {
+  float: right;
+  width: 0;
+  height: 0;
+  position: absolute;
+  right: 0;
+  bottom: 0;
+  border-left: 30px solid transparent;
+  border-bottom: 30px solid v-bind(color)
+}
 
+.project-logo-text {
+  padding: 0 3px 0 0;
+  position: absolute;
+  right: 0;
+  bottom: -32px;
+  color: white
+}
 </style>

+ 49 - 32
src/components/TestCard.vue

@@ -34,11 +34,14 @@
     </el-row>
 
     <el-row class="time">
-      {{ timePeriod.replace(/-/g,".") }}
+      {{ startTime }}
+    </el-row>
+    <el-row class="time">
+      {{ endTime }}
     </el-row>
 
-    <el-row v-if="type==='eval'" class="comment">
-      {{ testVO.comment }}
+    <el-row v-if="type==='eval'&&testVO['comment']!==''" class="comment">
+      {{ testVO["comment"] }}
     </el-row>
   </el-card>
 </template>
@@ -46,6 +49,7 @@
 <script>
 import {ElMessage, ElMessageBox} from "element-plus";
 import store from "@/store";
+import timeUtil from "@/utils/time";
 
 export default {
   name: "TestCard",
@@ -68,7 +72,7 @@ export default {
     isCreator() {
       if (this.testVO.examId) {
         return Number(this.testVO.course.teacherId) === Number(this.$store.state.user.id);
-      }else{
+      } else {
         return this.testVO.creator.username === this.$store.state.user.username;
       }
     },
@@ -94,24 +98,41 @@ export default {
     },
     course() {
       if (this.type === "eval") {
-        return "";
+        return "课程: " + this.testVO.course.name;
       } else {
-        return "所属课程: " + this.testVO.course;
+        return "课程: " + this.testVO.course;
       }
     },
     teacherName() {
-      if (this.type === "eval") {
-        return "教师: " + this.teacher.name;
-      } else {
-        return "教师: " + this.teacher;
+      return "教师: " + this.teacher;
+    },
+    startTime() {
+      let start = "开始: ";
+      switch (this.type) {
+        case "eval":
+          start += this.testVO.startTime.substring(0, 16);
+          break;
+        case "coder":
+          start += timeUtil.timestampToTime(this.testVO.startAt);
+          break;
+        default:
+          break;
       }
+      return start;
     },
-    timePeriod() {
-      if (this.type === "eval") {
-        return "时间: " + this.testVO.startTime.substring(0, 16) + "至" + this.testVO.endTime.substring(0, 16);
-      } else {
-        return "时间: " + this.timestampToTime(this.testVO.startAt) + "至" + this.timestampToTime(this.testVO.endAt);
+    endTime() {
+      let end = "结束: ";
+      switch (this.type) {
+        case "eval":
+          end += this.testVO.endTime.substring(0, 16);
+          break;
+        case "coder":
+          end += timeUtil.timestampToTime(this.testVO.endAt);
+          break;
+        default:
+          break;
       }
+      return end;
     },
     state() {
       const now = new Date();
@@ -140,23 +161,19 @@ export default {
       }
     },
   },
-  async created() {
-    if (this.type === "eval") {
-      this.teacher = (await this.$apis.getUserAPI(this.testVO.course["teacherId"])).data.data;
-    } else {
-      this.teacher = (await this.$apis.getNameByUsernameAPI(this.testVO.creator.username)).data.data;
+  async mounted() {
+    switch (this.type) {
+      case "eval":
+        this.teacher = (await this.$apis.getUserAPI(this.testVO.course["teacherId"])).data.data.name;
+        break;
+      case "coder":
+        this.teacher = (await this.$apis.getNameByUsernameAPI(this.testVO.creator.username)).data.data;
+        break;
+      default:
+        break;
     }
   },
   methods: {
-    timestampToTime(timestamp) {
-      const date = new Date(timestamp * 1000);
-      const Y = date.getFullYear() + "-";
-      const M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
-      const D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
-      const h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
-      const m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes());
-      return Y + M + D + h + m;
-    },
     // TODO 分情况处理跳转
     async toTestInfo() {
       if (!this.isLogin) {
@@ -226,7 +243,7 @@ export default {
               if (isCourseSelected) {
                 messageBoxContent = "是否立即查看测试详情";
                 confirmButtonText = "立即查看";
-                this.$router.push("/exam/"+this.testVO.id);
+                this.$router.push("/exam/" + this.testVO.id);
                 // nextURL = "https://coder.seec.seecoder.cn/exam?id_token=" + this.$store.state.user.token;
               } else {
                 messageBoxContent = "尚未选择课程,是否立即参加?";
@@ -288,14 +305,14 @@ export default {
 
 .teacher {
   font-size: 10px;
-  margin-top: 10px;
+  margin-top: 4px;
   color: #999999;
 }
 
 .time {
   margin-top: 4px;
   font-size: 10px;
-  margin-bottom: 16px;
+  /*margin-bottom: 16px;*/
   color: #999999;
 }
 

+ 1 - 19
src/requests/axios.config.js

@@ -1,32 +1,18 @@
 import axios from "axios";
 import store from "@/store";
-import userAPIs from "@/api/user";
 
 const httpPrefix = "http";
 
 const instance = axios.create({
   baseURL: "/api"
 });
-//
-// const specialUrls = [
-//   "/eval",
-// ];
 
 instance.interceptors.request.use(
   async (config) => {
-    if(config.url.startsWith(httpPrefix)){
+    if (config.url.startsWith(httpPrefix)) {
       config.baseURL = "";
     }
 
-    // if(specialUrls.indexOf(config.url) !== -1){
-    //   const res = await userAPIs.loginAPI({
-    //     phone: "17301585267",
-    //     password: "SEEC2020",
-    //   });
-    //   config.headers.authorization = res.data.data.token;
-    //   return config;
-    // }
-
     if (store.state.user.token) {
       config.headers.authorization = store.state.user.token;
     } else {
@@ -39,10 +25,6 @@ instance.interceptors.request.use(
   }
 );
 
-// instance.interceptors.response.use((response) => {
-//
-// });
-
 export {
   instance as axios
 };

+ 13 - 0
src/utils/color.js

@@ -0,0 +1,13 @@
+const coderColor = "#8dc9e2";
+const evalColor = "#f5b86e";
+const developerColor = "#3a85bb";
+
+const colorUtil = {
+  SYSTEM_THEME: {
+    coderColor,
+    evalColor,
+    developerColor,
+  }
+};
+
+export default colorUtil;

+ 15 - 0
src/utils/time.js

@@ -0,0 +1,15 @@
+function timestampToTime(timestamp, delimiter = "-") {
+  const date = new Date(timestamp * 1000);
+  const Y = date.getFullYear() + delimiter;
+  const M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + delimiter;
+  const D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
+  const h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
+  const m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes());
+  return Y + M + D + h + m;
+}
+
+const timeUtil = {
+  timestampToTime,
+};
+
+export default timeUtil;

+ 1 - 0
src/views/PortalPage/components/CarouselCard.vue

@@ -22,6 +22,7 @@ export default {
   },
   async created() {
     const rootPoint = (await this.$apis.queryCarouselChart()).data.data;
+    console.log(rootPoint);
     for (let i = 0; i < rootPoint.length; i++) {
       this.contents[i] = rootPoint[i].imageUrl;
       this.link[i] = rootPoint[i].id;

+ 4 - 3
src/views/PortalPage/components/MyTestCard.vue

@@ -70,9 +70,9 @@ export default {
     },
     course() {
       if (this.type === "eval") {
-        return "";
+        return "课程: " + this.testVO.course.name;
       } else {
-        return "所属课程: " + this.testVO.course;
+        return "课程: " + this.testVO.course;
       }
     },
     teacherName() {
@@ -200,11 +200,12 @@ export default {
 
 .course {
   font-size: x-small;
+  color: #999999;
 }
 
 .teacher {
   font-size: x-small;
-  color: #888888;
+  color: #999999;
 }
 
 .test-period {

+ 3 - 11
src/views/ProjectPage/ProjectPage.vue

@@ -49,6 +49,9 @@
           </span>
         </template>
         <div v-if="this.activeIndex === '1'">
+        </div>
+
+        <div v-if="this.activeIndex === '2' && isStudent">
           <el-tabs v-model="activeProjectPaneName" style="width: 100%">
             <el-tab-pane label="课程下项目" name="courseProject">
               <div v-for="(item, key) in courseProjectList" :key="key">
@@ -70,17 +73,6 @@
           </el-tabs>
         </div>
 
-        <div v-if="this.activeIndex === '2' && isStudent">
-              <div v-for="(item, key) in ProjectList_my" :key="key">
-                <div>
-                  <el-divider style="margin: 10px 0 20px 0" content-position="left">{{ key }}</el-divider>
-                </div>
-                <div class="project-page-main">
-                  <ProjectCard v-for="project in item" :key="project.id" :projectVO="project" type="myProject"/>
-                </div>
-              </div>
-        </div>
-
         <div v-if="this.activeIndex === '2' && isTeacher">
           教师请前往
           <span style="cursor: pointer;color: #409eff"

+ 10 - 10
vue.config.js

@@ -5,12 +5,12 @@ module.exports = {
   publicPath: process.env.BASE_URL,
   chainWebpack: config => {
     config
-        .plugin("html")
-        .tap(args => {
-          // NOTE 确定系统正式名称
-          args[0].title = "SEEC门户系统";
-          return args;
-        });
+      .plugin("html")
+      .tap(args => {
+        // NOTE 确定系统正式名称
+        args[0].title = "SEEC门户系统";
+        return args;
+      });
   },
   css: {
     loaderOptions: {
@@ -27,14 +27,14 @@ module.exports = {
           target: "http://localhost:8080/api",
           pathRewrite: {
             "^/api": ""
-          }
+          },
         }
       },
       port: 8000,
     },
     plugins: process.env.NODE_ENV === "development" ?
-        [
-          new WebpackBar(),
-        ] : []
+      [
+        new WebpackBar(),
+      ] : []
   },
 };