Просмотр исходного кода

优化部分ui,智能批改按钮增加节流

stupig-zcx 1 год назад
Родитель
Сommit
a7af0fd6c4

+ 4 - 3
src/views/CorrectPage/CorrectPage.vue

@@ -38,10 +38,11 @@
       <el-table :data="fileList" stripe>
         <el-table-column prop="id" label="ID"></el-table-column>
         <el-table-column prop="assignmentId" label="作业 ID"></el-table-column>
-        <el-table-column prop="recordFileUrl" label="文件链接" width="300px">
+        <el-table-column prop="recordFileUrl" label="文件链接 (复制粘贴到浏览器中打开)" width="300px">
           <template #default="scope">
-            <a :href="scope.row.recordFileUrl" target="_blank">{{ scope.row.recordFileUrl }}</a>
-          </template>
+            <!-- <a :href="scope.row.recordFileUrl" target="_blank">{{ scope.row.recordFileUrl }}</a> -->
+            <span>{{ scope.row.recordFileUrl }}</span>
+          </template> 
         </el-table-column>
         <el-table-column prop="time" label="时间"></el-table-column>
         <el-table-column prop="studentId" label="学生 ID"></el-table-column>

+ 1 - 1
src/views/Home/component/Silder/index.scss

@@ -60,7 +60,7 @@
 
   .capacity-item {
     width: 100%;
-    height: 50vh;
+    height: 40vh;
     background-color: #d9d9d9;
     border-radius: 10px;
 

+ 19 - 5
src/views/Home/component/Silder/index.vue

@@ -39,8 +39,8 @@
             </template>
           </div>
         </template>
+        <div>智能批改</div> 
         <div class="edit-box-header">
-          智能批改
           <el-button @click="handleCorrect" :disabled="!showCorrectBtn" @mouseover="handleCorrectTip">开始批改</el-button>
           <el-button @click="handleCorrectToPage" :disabled="!showCorrectToPageBtn" @mouseover="handleCorrectToPageTip">查看完整批改报告</el-button>
         </div>
@@ -236,10 +236,24 @@ import * as path from "node:path";
 
   }
 
-  const handleCorrectTip = () => {
-    if(!showCorrectBtn.value)
-      ElMessage.error("请更新作文内容并暂存后批改")
-  }
+  // 添加节流函数
+  const throttle = (fn: Function, delay: number) => {
+    let lastTime = 0;
+    return function (...args: any[]) {
+      const now = Date.now();
+      if (now - lastTime >= delay) {
+        fn.apply(this, args);
+        lastTime = now;
+      }
+    };
+  };
+
+  // 使用节流包装 handleCorrectTip
+  const handleCorrectTip = throttle(() => {
+    if(!showCorrectBtn.value) {
+      ElMessage.error("请更新作文内容并暂存后批改");
+    }
+  }, 2000); // 2秒的节流时间
 
   const handleCorrectToPageTip = () => {
     if(!showCorrectToPageBtn.value)