浏览代码

防止reload过程中误操作

Michael Wang 4 年之前
父节点
当前提交
fd4c3fb14c
共有 3 个文件被更改,包括 31 次插入15 次删除
  1. 1 1
      src/features/mark/MarkDrawTrack.vue
  2. 11 6
      src/features/mark/MarkHeader.vue
  3. 19 8
      src/features/mark/MarkSwitchGroupDialog.vue

+ 1 - 1
src/features/mark/MarkDrawTrack.vue

@@ -21,7 +21,7 @@
 
 <script lang="ts">
 import { ModeEnum, SpecialTag, Track } from "@/types";
-import { computed, defineComponent, PropType, ref, watchEffect } from "vue";
+import { computed, defineComponent, PropType } from "vue";
 import { store } from "./store";
 
 export default defineComponent({

+ 11 - 6
src/features/mark/MarkHeader.vue

@@ -28,14 +28,18 @@
     </div>
     <ul class="tw-flex tw-gap-2 tw-mb-0">
       <li>
-        已评<span class="highlight-text">{{ store.status.personCount }}</span>
+        已评<span class="highlight-text">{{
+          store.status.personCount || "-"
+        }}</span>
       </li>
       <li v-if="store.setting.topCount">
-        分配<span class="highlight-text">{{ store.setting.topCount }}</span>
+        分配<span class="highlight-text">{{
+          store.setting.topCount || "-"
+        }}</span>
       </li>
       <li>
         未评<span class="highlight-text">{{
-          store.status.totalCount - store.status.markedCount
+          store.status.totalCount - store.status.markedCount || "-"
         }}</span>
       </li>
       <li
@@ -44,7 +48,7 @@
         <QuestionCircleOutlined class="icon-font icon-font-size-20" />
       </li>
       <li>
-        进度<span class="highlight-text">{{ progress }}%</span>
+        进度<span class="highlight-text">{{ progress || "-" }}%</span>
       </li>
     </ul>
     <ul class="tw-flex tw-gap-2 tw-mb-0">
@@ -180,7 +184,7 @@
       <div
         class="tw-overflow-ellipsis tw-overflow-hidden tw-whitespace-nowrap tw-mr-1"
       >
-        {{ "分组:" + group?.number }}
+        {{ "分组:" + (group?.number || "-") }}
       </div>
       <DownOutlined
         v-if="store.groups.length > 1"
@@ -273,7 +277,8 @@ export default defineComponent({
       store.currentQuestion = undefined;
       store.currentScore = undefined;
 
-      message.info({ content: "重新加载中...", duration: 3 });
+      const body = document.querySelector("body");
+      if (body) body.innerHTML = "重新加载中...";
       // 等待一秒后,重新加载页面
       await new Promise((resolve) => setTimeout(resolve, 1000));
       window.location.reload();

+ 19 - 8
src/features/mark/MarkSwitchGroupDialog.vue

@@ -60,14 +60,25 @@ export default defineComponent({
     };
 
     const chooseGroup = async (markerId: number) => {
-      const res = await doSwitchGroup(markerId).then((res) => {
-        // 切换分组相当于刷新页面,此时之前的所有的状态消失,即task/markResult不存在了
-        if (res.data.success) {
-          window.location.reload();
-        } else {
-          message.error({ content: res.data.message || "错误", duration: 5 });
-        }
-      });
+      const res = await doSwitchGroup(markerId)
+        .then((res) => {
+          // 切换分组相当于刷新页面,此时之前的所有的状态消失,即task/markResult不存在了
+          if (res.data.success) {
+            const body = document.querySelector("body");
+            if (body) body.innerHTML = "重新加载中...";
+            return new Promise((resolve) =>
+              setTimeout(() => resolve(true), 300)
+            );
+          } else {
+            message.error({ content: res.data.message || "错误", duration: 5 });
+            return false;
+          }
+        })
+        .then((res) => {
+          if (res) {
+            window.location.reload();
+          }
+        });
     };
 
     const handleCancel = () => {