Przeglądaj źródła

增加同步成员功能

hushuyu 4 miesięcy temu
rodzic
commit
fa31297f92

+ 9 - 0
src/api/project.js

@@ -67,6 +67,14 @@ function deleteForkProject(projectId) {
   });
 }
 
+function syncProjectMembers(projectId) {
+  return axios.post(`${prefix}/syncMembers`, null, {
+    params: {
+      projectId,
+    }
+  });
+}
+
 function findAllPublicProjectsGroupByCourse() {
   return axios.get(`${prefix}/findAllPublicGroupByCourse`);
 }
@@ -82,6 +90,7 @@ const projectAPIs = {
   updateCourseProjectState,
   forkProject,
   deleteForkProject,
+  syncProjectMembers,
   findAllPublicProjectsGroupByCourse,
 };
 

+ 29 - 0
src/views/CourseDetailPage/tabs/ProjectTab/ProjectLongCard.vue

@@ -21,6 +21,9 @@
         <el-button v-if="isTeacher" size="small" type="primary" @click.stop="$emit('switch')">
           设为{{ isPublic ? "私有" : "公共" }}
         </el-button>
+        <el-button v-if="isTeacher" size="small" type="success" plain :loading="syncingMembers" @click.stop="handleSyncMembers">
+          同步成员
+        </el-button>
         <el-button v-if="isPublic&&!isTeacher" size="small" type="primary" @click.stop="$emit('fork')">
           Fork
         </el-button>
@@ -65,6 +68,7 @@ export default {
   data() {
     return {
       members: [],
+      syncingMembers: false,
     };
   },
   computed:{
@@ -82,6 +86,31 @@ export default {
     }
   },
   methods: {
+    async refreshMembers() {
+      const res = (await this.$apis.findProjectMembers(this.project.id)).data;
+      if (!res.code) {
+        this.members = res.data;
+      }
+    },
+
+    async handleSyncMembers() {
+      if (this.syncingMembers) {
+        return;
+      }
+      this.syncingMembers = true;
+      try {
+        const res = (await this.$apis.syncProjectMembers(this.project.id)).data;
+        if (res.code) {
+          ElMessage.error(res.message);
+          return;
+        }
+        await this.refreshMembers();
+        ElMessage.success("同步成员成功!");
+      } finally {
+        this.syncingMembers = false;
+      }
+    },
+
     async handleDeleteFork() {
       try {
         await ElMessageBox.confirm(