소스 검색

回评 reload & fixbug

Michael Wang 4 년 전
부모
커밋
4f809103a6
2개의 변경된 파일24개의 추가작업 그리고 7개의 파일을 삭제
  1. 12 5
      src/features/mark/Mark.vue
  2. 12 2
      src/features/mark/MarkHistory.vue

+ 12 - 5
src/features/mark/Mark.vue

@@ -2,7 +2,7 @@
   <div class="my-container">
     <mark-header />
     <div class="tw-flex tw-gap-1">
-      <mark-history />
+      <mark-history :should-reload="shouldReloadHistory" />
       <mark-body @error="updateTask" />
       <mark-board-track v-if="showMarkBoardTrack" @submit="saveTaskToServer" />
       <mark-board-key-board
@@ -15,7 +15,7 @@
 </template>
 
 <script lang="ts">
-import { computed, defineComponent, onMounted, watch } from "vue";
+import { computed, defineComponent, onMounted, ref, watch } from "vue";
 import {
   clearMarkTask,
   getGroup,
@@ -157,6 +157,8 @@ export default defineComponent({
       );
     });
 
+    const shouldReloadHistory = ref(0);
+
     const saveTaskToServer = async () => {
       const markResult = findCurrentTaskMarkResult();
       if (!markResult) return;
@@ -174,9 +176,13 @@ export default defineComponent({
       updateStatus();
       if (res.data.success && store.currentTask) {
         message.success({ content: "保存成功", key: mkey, duration: 2 });
-        removeCurrentMarkResult();
-        store.currentTask = undefined;
-        store.tasks.shift();
+        if (!store.historyOpen) {
+          removeCurrentMarkResult();
+          store.currentTask = undefined;
+          store.tasks.shift();
+        } else {
+          shouldReloadHistory.value = Date.now();
+        }
       } else {
         if (markResult) {
           markResult.spent = Date.now() - markResult.spent;
@@ -193,6 +199,7 @@ export default defineComponent({
       showMarkBoardTrack,
       showMarkBoardKeyBoard,
       showMarkBoardMouse,
+      shouldReloadHistory,
     };
   },
 });

+ 12 - 2
src/features/mark/MarkHistory.vue

@@ -52,14 +52,17 @@
 <script lang="ts">
 import { getHistoryTask } from "@/api/markPage";
 import { Task } from "@/types";
-import { defineComponent, ref, watchEffect } from "vue";
+import { defineComponent, ref, watch, watchEffect } from "vue";
 import { store } from "./store";
 import { CloseOutlined, SearchOutlined } from "@ant-design/icons-vue";
 
 export default defineComponent({
   name: "MarkHistory",
   components: { CloseOutlined, SearchOutlined },
-  setup() {
+  props: {
+    shouldReload: { type: Number, required: true },
+  },
+  setup(props) {
     watchEffect(async () => {
       if (store.historyOpen) {
         replaceCurrentTask(undefined);
@@ -70,6 +73,13 @@ export default defineComponent({
       }
     });
 
+    watch(
+      () => props.shouldReload,
+      () => {
+        updateHistoryTask({ pageNumber: currentPage.value });
+      }
+    );
+
     const secretNumberInput = ref(null);
     const loading = ref(false);
     const currentPage = ref(1);