Prechádzať zdrojové kódy

Merge branch 'refactor-admin' of http://gogs.seec.seecoder.cn/FanYanPeng/EAIFrontend into refactor-admin

chenjiayao 1 rok pred
rodič
commit
49702cd809

+ 4 - 4
src/apis/course.ts

@@ -9,16 +9,16 @@ const courseApis = {
     createCourse(courseDTO: CourseDTO){
       return axiosInstance.post(`${COURSE_PREFIX}`, courseDTO)
     },
-    getCourseByStudentId(studentId: number, page: number=0, size: number=10){
-        return axiosInstance.get(`${COURSE_PREFIX}/byStudent/${studentId}`, {
+    getCourseByStudentId(page: number=0, size: number=10){
+        return axiosInstance.get(`${COURSE_PREFIX}/byStudent`, {
             params: {
                 page,
                 size
             }
         })
     },
-    getCourseByTeacherId(teacherId: number, page: number=0, size: number=10){
-        return axiosInstance.get(`${COURSE_PREFIX}/byTeacher/${teacherId}`, {
+    getCourseByTeacherId(page: number=0, size: number=10){
+        return axiosInstance.get(`${COURSE_PREFIX}/byTeacher`, {
             params: {
                 page,
                 size

+ 3 - 0
src/types/vo.ts

@@ -38,6 +38,8 @@ export interface IAssignment {
 
     teacherId: number; // 发布作业的老师的Id
 
+    teacherName: string; // 发布作业的老师的姓名
+
     courseId: number; // 哪个课程下的assignment
 
     startTime: string;
@@ -105,6 +107,7 @@ export interface CourseVO {
     courseId: number;
     courseName: string;
     teacherIds: number[];
+    teacherNames: string[];
     courseImages: string[];
     targetGrade: string;
     startTime: string;

+ 61 - 11
src/utils/convertUtil.ts

@@ -1,14 +1,64 @@
-import type {UserUpdateDTO} from "@/types/dto";
-import type {IUser} from "@/types/user";
+import type { UserUpdateDTO } from "@/types/dto";
+import type { IUser } from "@/types/user";
 
 export function convertIUserToUserUpdateDTO(user: IUser): UserUpdateDTO {
-    const userUpdateDTO: UserUpdateDTO = {};
-    // 遍历IUser对象的属性
-    for (const key in user) {
-        // 只选取UserUpdateDTO中定义的属性进行赋值
-        if (key === "userAvatar" || key === "lastLoginTime" || key === "englishName" || key === "gender" || key === "birthday" || key === "phone" || key === "contentEmail") {
-            userUpdateDTO[key] = user[key];
-        }
+  const userUpdateDTO: UserUpdateDTO = {};
+  // 遍历IUser对象的属性
+  for (const key in user) {
+    // 只选取UserUpdateDTO中定义的属性进行赋值
+    if (
+      key === "userAvatar" ||
+      key === "lastLoginTime" ||
+      key === "englishName" ||
+      key === "gender" ||
+      key === "birthday" ||
+      key === "phone" ||
+      key === "contentEmail"
+    ) {
+      userUpdateDTO[key] = user[key];
     }
-    return userUpdateDTO;
-}
+  }
+  return userUpdateDTO;
+}
+
+/**
+ * 处理图片url
+ * @param url
+ * @returns
+ */
+export function convertImageUrl(url: string, altText: string): string {
+  // 如果url为空,生成一个课程名图片
+  if (url === null || url === "") {
+    // 创建画布
+    const canvas = document.createElement("canvas");
+    // 绘制文字环境
+    const context = canvas.getContext("2d");
+    // 画布宽度
+    canvas.width = 400;
+    // 画布高度
+    canvas.height = 240;
+    // 绘制文字之前填充
+    context.fillStyle = "#000000";
+    context.fillRect(0, 0, canvas.width, canvas.height);
+    // 设置水平对齐方式
+    context.textAlign = "center";
+    // 设置垂直对齐方式
+    context.textBaseline = "middle";
+    // 设置字体颜色
+    context.fillStyle = "#ffffff";
+    // 设置字体大小和字体类型
+    context.font = "40px Arial";
+    // 绘制文字
+    context.fillText(altText, canvas.width / 2, canvas.height / 2);
+    // 生成图片信息
+    return canvas.toDataURL("image/png");
+  }
+
+  const index = url.indexOf("?");
+  // 截取?之前的字符串
+  if (index !== -1) {
+    return url.substring(0, index);
+  }
+  // 否则返回原url
+  return url;
+}

+ 23 - 17
src/views/CorrectPage/AssignmentPage.vue

@@ -42,7 +42,13 @@
       <el-table-column prop="assignmentName" label="作业名称" width="400"/>
       <!-- <el-table-column prop="description" label="描述" width="500"/> -->
       <el-table-column prop="endTime" label="截止时间" sortable/>
-      <el-table-column prop="status" label="状态" sortable/>
+      <el-table-column prop="status" label="状态" sortable>
+        <template #default="{row}">
+          <el-tag v-if="row.status === AssignmentStatus.NOT_STARTED" type="info">未发布</el-tag>
+          <el-tag v-else-if="row.status === AssignmentStatus.PROCEEDING" type="success">进行中</el-tag>
+          <el-tag v-else-if="row.status === AssignmentStatus.FINISHED" type="danger">已截止</el-tag>
+        </template>
+      </el-table-column>
       <el-table-column label="操作">
         <template #default="scope">
           <el-button @click="handleCorrect(scope.row.assignmentId)" style="margin-right: 0; margin-left: 0;padding-left: 10px; padding-right: 10px" color="#597D3B">
@@ -159,7 +165,7 @@
   const processData = () => {
     for (let i = 0; i < pageInfo.tableData.length; i++) {
       pageInfo.tableData[i].endTime = formatDate(pageInfo.tableData[i].endTime)
-    }
+    }    
   }
 
   onMounted(() => {
@@ -167,21 +173,21 @@
     fetchData(query)
   })
 
-  let state = ref(null)
-  const stateOptions = [
-    {
-      value: AssignmentStatus.NOT_STARTED,
-      label: "未发布"
-    },
-    {
-      value: AssignmentStatus.PROCEEDING,
-      label: "进行中"
-    },
-    {
-      value: AssignmentStatus.FINISHED,
-      label: "已截止"
-    },
-  ]
+  // let state = ref(null)
+  // const stateOptions = [
+  //   {
+  //     value: AssignmentStatus.NOT_STARTED,
+  //     label: "未发布"
+  //   },
+  //   {
+  //     value: AssignmentStatus.PROCEEDING,
+  //     label: "进行中"
+  //   },
+  //   {
+  //     value: AssignmentStatus.FINISHED,
+  //     label: "已截止"
+  //   },
+  // ]
 
 </script>
 

+ 6 - 10
src/views/CorrectPage/CorrectAssignmentPage.vue

@@ -82,18 +82,15 @@
 </template>
 
 <script lang="ts" setup>
-import {Refresh, ZoomIn, ArrowLeft, Search} from "@element-plus/icons-vue";
+import {Refresh, ZoomIn, ArrowLeft} from "@element-plus/icons-vue";
   import {inject, onMounted, reactive, ref} from "vue";
   import useApis from "@/apis";
   import {useStore} from "@/store";
-  import type {AssignmentVO, CourseVO, engagementVO, IAssignment} from "@/types/vo";
+  import type {AssignmentVO, IAssignment} from "@/types/vo";
   import router from "@/router";
   import {useRoute} from "vue-router";
   import "./CorrectAssignmentPage.scss"
-  import {AssignmentCompletionStatus, AssignmentStatus} from "@/types/enums";
-  import type {EngagementQuery} from "@/types/query";
-// import * as process from "node:process";
-import {useFormatDate} from "@/hooks/useFormatDate";
+  import {AssignmentCompletionStatus} from "@/types/enums";
 
   const apis = useApis()
   const store = useStore()
@@ -218,12 +215,11 @@ import {useFormatDate} from "@/hooks/useFormatDate";
         })
   }
 
+  /*
+  * 处理状态
+   */
   async function processData(data:any){
     for(let i = 0; i < data.tableData.length; i++){
-      apis.findUserById(data.tableData[i].studentId)
-          .then((res:any)=>{
-            data.tableData[i].studentName = res.data.data.records[0].name
-          })
       for(let j = 0; j < statusOptions.length; j++){
         if(data.tableData[i].status == statusOptions[j].value){
           data.tableData[i].statusName = statusOptions[j].label

+ 13 - 5
src/views/CoursePage/CoursePage.vue

@@ -48,18 +48,26 @@
   </el-card>
 
   <el-dialog v-model="visible" title="新增课程">
-    <el-form :model="newCourse">
+    <el-form :model="newCourse" label-width="80px">
       <el-form-item label="课程名称" >
         <el-input v-model="newCourse.courseName" placeholder="请输入课程名称"></el-input>
       </el-form-item>
       <el-form-item label="面向年级">
         <el-input v-model="newCourse.targetGrade" placeholder="请输入目标年级,例:2024级软件1-4班"></el-input>
       </el-form-item>
-      <el-form-item label="描述">
-        <el-input v-model="newCourse.description" placeholder="请输入课程描述"></el-input>
+      <el-form-item label="课程描述">
+        <el-input
+            type="textarea"
+            autosize
+            resize="none"
+            v-model="newCourse.description"
+            placeholder="请输入课程描述"
+        >
+        </el-input>
       </el-form-item>
-      <el-form-item label="选课码">
-        <el-input v-model="newCourse.enrollCode" placeholder="请输入选课码"></el-input>
+      <el-form-item label="选课码" style="display: flex; align-items: center">
+        <el-input v-model="newCourse.enrollCode" placeholder="请输入选课码" style="flex: 1; margin-right: 10px;"></el-input>
+        <el-button type="primary" plain size="mini" @click="newCourse.enrollCode = Math.random().toString(36).substr(2, 6).toUpperCase()">随机生成</el-button>
       </el-form-item>
       <el-form-item label="开始时间">
         <el-date-picker v-model="newCourse.startTime" type="datetime" placeholder="截止时间" style="width: 180px"/>

+ 7 - 25
src/views/CourseSquare/component/AllCourse/MoreCourse.vue

@@ -15,12 +15,12 @@
       <div class="course-items-container">
         <el-card v-for="item in getCoursesSlice(0, 5)" :key="item.courseId" class="course-item active" @click="handleClick(item.courseId)">
           <div style="width: 200px; height: 120px">
-            <img :src="item.courseImages[0]" :alt="item.courseName" class="course-item-img">
+            <img :src="convertImageUrl(item.courseImages[0], item.courseName)" :alt="item.courseName" class="course-item-img">
           </div>
           <div class="course-item-content">
             <div style="font-weight: bold; font-size: 16px; margin: 5px 0">{{item.courseName}}</div>
             <div style="line-height: 1.5" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">课程描述:</span>{{item.description}}</div>
-            <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherIds.join(",")}}</div>
+            <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherNames.join(",")}}</div>
           </div>
         </el-card>
 
@@ -33,12 +33,12 @@
       <div class="course-items-container">
         <el-card v-for="item in getCoursesSlice(5, 10)" :key="item.courseId" class="course-item active" @click="handleClick(item.courseId)">
           <div style="width: 200px; height: 120px">
-            <img :src="item.courseImages[0]" :alt="item.courseName" class="course-item-img">
+            <img :src="convertImageUrl(item.courseImages[0], item.courseName)" :alt="item.courseName" class="course-item-img">
           </div>
           <div class="course-item-content">
             <div style="font-weight: bold; font-size: 16px; margin: 5px 0">{{item.courseName}}</div>
             <div style="line-height: 1.5" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">课程描述:</span>{{item.description}}</div>
-            <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherIds.join(",")}}</div>
+            <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherNames.join(",")}}</div>
           </div>
         </el-card>
 
@@ -70,6 +70,7 @@ import type {CourseQuery} from "@/types/query";
 import router from "@/router";
 import {useStore} from "@/store";
 import {Refresh, Search} from "@element-plus/icons-vue";
+import {convertImageUrl} from "@/utils/convertUtil";
 
 const apis = useApis()
 const store = useStore()
@@ -171,29 +172,12 @@ const fetchData = () => {
   }
 }
 
-const processData = () => {
-  for(let i:number = 0; i < pageInfo.courseData.length; i++){
-    for(let j = 0; j < pageInfo.courseData[i].teacherIds.length; j++){
-      apis.findUserById(pageInfo.courseData[i].teacherIds[j])
-          .then((res:any) => {
-            pageInfo.courseData[i].teacherIds[j] = res.data.data.records[0].name
-          })
-          .catch((err:any) => {
-            console.log("错误信息",err)
-          })
-    }
-  }
-  for(let i:number = 0; i < pageInfo.courseData.length; i++){
-    pageInfo.courseData[i].courseImages[0] = pageInfo.courseData[i].courseImages[0].split("?")[0]
-  }
-}
 
 const fetchAllCourse = () => {
   apis.getAllCourse(query, queryInfo.pageNow, queryInfo.pageSize)
       .then((res: any) => {
         console.log(res)
         pageInfo.courseData = res.data.data.records
-        processData()
         pageInfo.total = res.data.data.total
         Object.assign(pageInfo2Show, pageInfo)
       })
@@ -205,11 +189,10 @@ const fetchAllCourse = () => {
 
 const fetchCourseByUserId = () => {
   if(role === 'student'){
-    apis.getCourseByStudentId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
+    apis.getCourseByStudentId(queryInfo.pageNow, queryInfo.pageSize)
         .then((res: any) => {
           console.log(res)
           pageInfo.courseData = res.data.data.records
-          processData()
           pageInfo.total = res.data.data.total
           Object.assign(pageInfo2Show, pageInfo)
         })
@@ -218,11 +201,10 @@ const fetchCourseByUserId = () => {
         })
         .finally(() => {});
   } else if(role === "teachers"){
-    apis.getCourseByTeacherId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
+    apis.getCourseByTeacherId(queryInfo.pageNow, queryInfo.pageSize)
         .then((res: any) => {
           console.log(res.data.data)
           pageInfo.courseData = res.data.data.records
-          processData()
           pageInfo.total = res.data.data.total
           Object.assign(pageInfo2Show, pageInfo)
         })

+ 7 - 91
src/views/CourseSquare/component/Course/index.vue

@@ -16,12 +16,12 @@
     <div class="course-items-container">
       <el-card v-for="item in getCoursesSlice()" :key="item.courseId" class="course-item active" @click="handleClick(item.courseId)">
         <div style="width: 200px; height: 120px">
-          <img :src="item.courseImages[0]" :alt="item.courseName" class="course-item-img">
+          <img :src="convertImageUrl(item.courseImages[0], item.courseName)" :alt="item.courseName" class="course-item-img">
         </div>
         <div class="course-item-content">
           <div style="font-weight: bold; font-size: 16px; margin: 5px 0">{{item.courseName}}</div>
           <div style="line-height: 1.5;" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">课程描述:</span>{{item.description}}</div>
-          <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherIds.join(",")}}</div>
+          <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherNames.join(",")}}</div>
         </div>
       </el-card>
       <template v-if="getCoursesSlice().length < 5">
@@ -48,81 +48,20 @@
   import router from "@/router";
   import type {CourseQuery} from "@/types/query";
   import {useStore} from "@/store";
+  import { convertImageUrl } from '@/utils/convertUtil';
 
   const apis = useApis()
   const store = useStore()
   const role:'teachers' | 'student' = store.user.role === 'STUDENT' ?   'student':'teachers';
 
   const props = defineProps<{
-    title:string,
+    title: string,
     type: 'all' | 'my'
   }>()
 
   // 课程数据
   const courses = reactive({
-    course: [
-      {
-        courseId: 5,
-        courseName: '英文论文写作',
-        description: '',
-        teacherIds: [],
-        courseImages: [],
-        targetGrade: null,
-        startTime: new Date(),
-        endTime: new Date(),
-      },
-      {
-        courseId: 7,
-        courseName: '数学分析',
-        description: '',
-        teacherIds: [],
-        courseImages: [],
-        targetGrade: null,
-        startTime: new Date(),
-        endTime: new Date(),
-      },
-      {
-        courseId: 8,
-        courseName: '线性代数',
-        description: '',
-        teacherIds: [],
-        courseImages: [],
-        targetGrade: null,
-        startTime: new Date(),
-        endTime: new Date(),
-      },
-      // {
-      //   courseId: 4,
-      //   courseName: '计算机科学',
-      //   description: '',
-      //   teacherIds: [],
-      //   courseImages: [],
-      //   targetGrade: null,
-      //   startTime: new Date(),
-      //   endTime: new Date(),
-      // },
-      // {
-      //   courseId: 5,
-      //   courseName: '物理学基础',
-      //   description: '',
-      //   teacherIds: [],
-      //   courseImages: [],
-      //   targetGrade: null,
-      //   startTime: new Date(),
-      //   endTime: new Date(),
-      // },
-      // {
-      //   courseId: 6,
-      //   courseName: '化学基础',
-      //   description: '',
-      //   teacherIds: [],
-      //   courseImages: [],
-      //   targetGrade: null,
-      //   startTime: new Date(),
-      //   endTime: new Date(),
-      // },
-      // 可以根据需要添加更多课程对象
-    ],
+    course: [],
   })
 
   //只获取前五个课程
@@ -167,7 +106,6 @@
     apis.getAllCourse(query, 0, 10)
         .then((res: any) => {
           courses.course = res.data.data.records
-          processCourses()
         })
         .catch((err: any) => {
           console.error("错误信息",err);
@@ -177,20 +115,18 @@
 
   const fetchCourseByUserId = () => {
     if(role === 'student'){
-      apis.getCourseByStudentId(store.user.id)
+      apis.getCourseByStudentId()
           .then((res: any) => {
             courses.course = res.data.data.records
-            processCourses()
           })
           .catch((err: any) => {
             console.error(err);
           })
           .finally(() => {});
     } else if(role === "teachers"){
-      apis.getCourseByTeacherId(store.user.id)
+      apis.getCourseByTeacherId()
           .then((res: any) => {
             courses.course = res.data.data.records
-            processCourses()
           })
           .catch((err: any) => {
             console.error(err);
@@ -199,26 +135,6 @@
     }
   }
 
-  /*
-  用于显示教师姓名
-   */
-  const processCourses = () => {
-    for(let i:number = 0; i < courses.course.length; i++){
-      for(let j = 0; j < courses.course[i].teacherIds.length; j++){
-        apis.findUserById(courses.course[i].teacherIds[j])
-            .then((res:any) => {
-              courses.course[i].teacherIds[j] = res.data.data.records[0].name
-            })
-            .catch((err:any) => {
-              console.log("错误信息",err)
-            })
-      }
-    }
-    for(let i:number = 0; i < courses.course.length; i++){
-      courses.course[i].courseImages[0] = courses.course[i].courseImages[0].split("?")[0]
-    }
-  }
-
   onMounted(()=>{
     fetchData()
   })

+ 7 - 19
src/views/CourseSquare/component/CourseDetails/index.vue

@@ -7,7 +7,7 @@
   <div class="course-details">
     <div class="course-details-info">
       <div>
-        <img  class="course-details-image" :src="dataForm.courseImages?.length > 0 ? dataForm.courseImages[0] : null" :alt="dataForm.courseName">
+        <img  class="course-details-image" :src="convertImageUrl(dataForm.courseImages[0], dataForm.courseName)" :alt="dataForm.courseName">
       </div>
       <div class="course-details-text">
         <div class="title">
@@ -38,7 +38,7 @@
     </div>
     <div class="course-tabs">
       <el-tabs v-model="activeTab" >
-        <el-tab-pane v-for="item in items" :name="item.key" :label="item.label">
+        <el-tab-pane v-for="item in items" :key="item.key" :name="item.key" :label="item.label">
           <template v-if="activeTab == '课程简介'">
             <div>
               {{dataForm.description}}
@@ -118,9 +118,6 @@ import {onMounted, reactive, ref} from 'vue';
 import {
   ElTabs,
   ElTabPane,
-  ElTable,
-  ElTableColumn,
-  ElAvatar,
   ElMessage,
   ElNotification,
   type UploadFiles, type UploadFile, type FormRules, type FormInstance
@@ -135,7 +132,7 @@ import {useStore} from "@/store";
 import type {CourseUpdateDTO, EnrollDTO} from "@/types/dto";
 import {UploadFilled} from "@element-plus/icons-vue"
 import type { UploadProps, UploadUserFile } from 'element-plus'
-import axiosInstance from "@/apis/axios.config";
+import { convertImageUrl } from '@/utils/convertUtil';
 
 const apis = useApis()
 const store = useStore()
@@ -308,18 +305,9 @@ const handleChange = (file,fileList) => {
 
 
 /*
-  用于显示教师姓名
+  用于处理课程图片
    */
 const processCourses = () => {
-  for(let i = 0; i < dataForm.teacherIds.length; i++){
-    apis.findUserById(dataForm.teacherIds[i])
-        .then((res:any) => {
-          dataForm.teacherNames[i] = res.data.data.records[0].name
-        })
-        .catch((err:any) => {
-          console.log("错误信息",err)
-        })
-  }
   dataForm.courseImages[0] = dataForm.courseImages[0].split("?")[0]
 }
 
@@ -391,7 +379,7 @@ const getHomeworkList = () => {
   学生,是否显示选课码输入框选课
  */
 const isShowCode = () => {
-  apis.getCourseByStudentId(store.user.id)
+  apis.getCourseByStudentId()
     .then((res: any) => {
       let data = res.data.data.records
       for(let i = 0 ; i < data.length; i++){
@@ -439,10 +427,10 @@ const enroll = () => {
   教师,是否显示编辑课程按钮
  */
 const isShowEdit = () => {
-  apis.getCourseByTeacherId(store.user.id)
+  apis.getCourseByTeacherId()
       .then((res: any) => {
         let total = res.data.data.total
-        apis.getCourseByTeacherId(store.user.id, 1, total)
+        apis.getCourseByTeacherId(1, total)
             .then((res: any) => {
               let data = res.data.data.records
               for(let i = 0 ; i < data.length; i++){

+ 2 - 1
src/views/HomeworkPage/component/HomeworkDetail.vue

@@ -14,7 +14,7 @@
         </div>
         <div class="item">
           <span style="font-weight: 600">发布老师: </span>
-          {{data.teacherId}}
+          {{data.teacherName}}
         </div>
         <div class="item">
           <span style="font-weight: 600">截止日期: </span>
@@ -68,6 +68,7 @@ let data = reactive<IAssignment>({
   descriptionFile: null,
   attachments: null,
   teacherId: null,
+  teacherName: "",
   courseId: null,
   startTime: "",
   endTime: "",

+ 12 - 6
src/views/HomeworkPage/index.vue

@@ -31,9 +31,15 @@
       </template>
       <el-table-column type="index"/>
       <el-table-column prop="assignmentName" label="课程名称" width="400"/>
-      <!-- <el-table-column prop="description" label="描述" width="400"/> -->
+<!--      <el-table-column prop="description" label="描述" width="400"/>-->
       <el-table-column prop="endTime" label="截止时间" sortable/>
-      <el-table-column prop="status" label="状态" sortable/>
+      <el-table-column prop="status" label="状态" sortable>
+        <template #default="{row}">
+          <el-tag v-if="row.status === AssignmentStatus.NOT_STARTED" type="info">未发布</el-tag>
+          <el-tag v-else-if="row.status === AssignmentStatus.PROCEEDING" type="success">进行中</el-tag>
+          <el-tag v-else-if="row.status === AssignmentStatus.FINISHED" type="danger">已截止</el-tag>
+        </template>
+      </el-table-column>
       <el-table-column label="操作" width="100">
         <template #default="scope">
           <el-button @click="handleShowDetail(scope.row.assignmentId)" style="margin-right: 0; margin-left: 0;padding-left: 10px; padding-right: 10px" color="#597D3B">
@@ -139,11 +145,11 @@
 
   const fetchData = () => {
     if (role === 'student') {
-      apis.getCourseByStudentId(store.user.id)
+      apis.getCourseByStudentId()
           .then((res: any) => {
             // 获取课程总数
             let total = res.data.data.total;
-            apis.getCourseByStudentId(store.user.id,1,total)
+            apis.getCourseByStudentId(1, total)
                 .then((res: any) => {
                   let data:CourseVO[] = res.data.data.records
                   for(let i = 0; i < data.length; i++){
@@ -152,11 +158,11 @@
                 })
           })
     } else if (role === "teachers") {
-      apis.getCourseByTeacherId(store.user.id)
+      apis.getCourseByTeacherId()
           .then((res: any) => {
             // 获取课程总数
             let total = res.data.data.total;
-            apis.getCourseByTeacherId(store.user.id,1,total)
+            apis.getCourseByTeacherId(1, total)
                 .then((res: any) => {
                   let data:CourseVO[] = res.data.data.records
                   for(let i = 0; i < data.length; i++){

+ 35 - 14
src/views/LoginPage/component/Register.vue

@@ -8,7 +8,7 @@
       <!-- <div style="background-color: #8e8e8e; padding: 20px; width: 600px; border-radius: 5px; margin: 20px auto"> -->
 
       <div class="vessel-title">
-        欢迎注册SEEAI平台账号
+        欢迎注册 SEEAI 平台账号
       </div>
       <!--角色-->
       <el-form :rules="userRules" :model="userRegisterDTO" ref="formRef" :size="formSize">
@@ -45,14 +45,18 @@
           <el-form-item label="验证码" prop="verifyCode" class="form-item">
             <el-input v-model="userRegisterDTO.verifyCode" placeholder="输入验证码"></el-input>
           </el-form-item>
-          <el-button @click="sendVerifyCode"  class="button">发送验证码</el-button>
+          <el-button @click="sendVerifyCode" class="button">发送验证码</el-button>
         </div>
 
         <div style="display: flex; justify-content: center; align-items: center;">
-          <el-button @click="register(formRef)"  class="login-button" >注册</el-button>
+          <el-button @click="register(formRef)" class="login-button">注册</el-button>
+        </div>
+
+        <!-- 返回登录页面,下划线灰色小字 -->
+        <div style="display: flex; justify-content: center; align-items: center; margin-top: 10px;">
+          <router-link to="/login" style="color: #8e8e8e; text-decoration: underline;">已有帐号,去登录?</router-link>
         </div>
 
-        <div class="sign" @click="onClickLogin" style="margin-top: 10px">已有帐号,去登录?</div>
       </el-form>
 
     </div>
@@ -70,7 +74,6 @@ import { reactive, ref } from "vue";
 import useApis from "@/apis";
 import { Role } from "@/types/enums";
 import { type ComponentSize, ElMessage, type FormInstance, type FormRules } from "element-plus";
-import { useRoute } from "vue-router";
 import router from "@/router";
 
 const apis = useApis()
@@ -87,7 +90,7 @@ const roleOptions = [
     value: Role.TEACHER,
     disabled: false
   },
-  
+
 ]
 
 const formSize = ref<ComponentSize>('default')
@@ -144,10 +147,25 @@ const register = async (formEl: FormInstance | undefined) => {
       console.log("合法输入")
       apis.register(userRegisterDTO)
         .then((res: any) => {
-          router.push(`/login`)
+          if (res.data.code === 200) {
+            ElMessage({
+              message: '注册成功',
+              type: 'success',
+            })
+            router.push(`/login`)
+          } else {
+            ElMessage({
+              message: '注册失败: ' + res.data.msg,
+              type: 'error',
+            })
+          }
         })
         .catch((err: any) => {
           console.error(err);
+          ElMessage({
+            message: '注册失败',
+            type: 'error',
+          })
         })
         .finally(() => {
         });
@@ -164,10 +182,17 @@ const register = async (formEl: FormInstance | undefined) => {
 const sendVerifyCode = () => {
   apis.sendVerifyCode(userRegisterDTO.officialEmail)
     .then((res: any) => {
-      ElMessage({
+      if (res.data.code === 200) {
+        ElMessage({
         message: '验证码发送成功,请前往您的邮箱查看',
-        type: 'success',
-      })
+          type: 'success',
+        })
+      } else {
+        ElMessage({
+          message: '验证码发送失败: ' + res.data.msg,
+          type: 'error',
+        })
+      }
     })
     .catch((err: any) => {
       ElMessage({
@@ -179,10 +204,6 @@ const sendVerifyCode = () => {
     .finally(() => {
     });
 }
-
-const onClickLogin = () => {
-  router.push('/login');
-};
 </script>
 
 <script lang="ts">