Browse Source

$computed let => const

Michael Wang 3 years ago
parent
commit
a2c784a359

+ 1 - 1
src/features/library/inspect/LibraryInspect.vue

@@ -118,7 +118,7 @@ async function getOneOfStuTask() {
   return getOneOfInspectedTaskOfLibraryInspect(subjectCode, groupNumber);
 }
 
-let realLibraryId = $computed(
+const realLibraryId = $computed(
   () => (isSingleStudent ? libraryId : store.currentTask?.libraryId) as string
 );
 const saveTaskToServer = async () => {

+ 5 - 12
src/features/library/inspect/MarkBoardInspect.vue

@@ -23,10 +23,7 @@
       <template v-for="(groupNumber, index) in groups" :key="index">
         <div class="tw-mb-4 tw-bg-white tw-p-4">
           <div
-            class="
-              tw-flex tw-justify-between tw-place-items-center
-              hover:tw-bg-gray-200
-            "
+            class="tw-flex tw-justify-between tw-place-items-center hover:tw-bg-gray-200"
             @mouseover="addFocusTrack(groupNumber, undefined, undefined)"
             @mouseleave="removeFocusTrack"
           >
@@ -43,11 +40,7 @@
             <template v-for="(question, index2) in questions" :key="index2">
               <div
                 v-if="question.groupNumber === groupNumber"
-                class="
-                  question
-                  tw-flex tw-place-items-center tw-mb-1 tw-font-bold
-                  hover:tw-bg-gray-200
-                "
+                class="question tw-flex tw-place-items-center tw-mb-1 tw-font-bold hover:tw-bg-gray-200"
                 @mouseover="
                   addFocusTrack(
                     undefined,
@@ -128,17 +121,17 @@ watch(
     checkedQuestions.splice(0);
   }
 );
-let groups = $computed(() => {
+const groups = $computed(() => {
   const gs = store.currentTask?.questionList.map((q) => q.groupNumber);
   return [...new Set(gs)].sort((a, b) => a - b);
 });
 
-let questions = $computed(() => {
+const questions = $computed(() => {
   const qs = store.currentTask?.questionList;
   return qs;
 });
 
-let markerScore = $computed(() => store.currentTask?.markerScore || 0);
+const markerScore = $computed(() => store.currentTask?.markerScore || 0);
 
 function addToCheckedQuestion(question: Question) {
   checkedQuestions.push(question);

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

@@ -41,7 +41,7 @@
 import { CloseOutlined } from "@ant-design/icons-vue";
 import { store } from "@/store/store";
 
-let urls = $computed(() => {
+const urls = $computed(() => {
   return store.currentTask?.sliceUrls ?? [];
 });
 

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

@@ -454,7 +454,7 @@ watch(
 //#endregion : 计算裁切图和裁切图上的分数轨迹和特殊标记轨迹
 
 //#region : 放大缩小和之后的滚动
-let answerPaperScale = $computed(() => {
+const answerPaperScale = $computed(() => {
   // 放大、缩小不影响页面之前的滚动条定位
   let percentWidth = 0;
   let percentTop = 0;

+ 3 - 3
src/features/mark/MarkBoardKeyBoard.vue

@@ -170,7 +170,7 @@ watch(
   { immediate: true }
 );
 
-let questionScoreSteps = $computed(() => {
+const questionScoreSteps = $computed(() => {
   const question = store.currentQuestion;
   if (!question) return [];
 
@@ -200,7 +200,7 @@ function isCurrentQuestion(question: Question) {
   );
 }
 
-let questionScore = $computed(
+const questionScore = $computed(
   () =>
     store.currentTask &&
     store.currentQuestion &&
@@ -331,7 +331,7 @@ function submit() {
   emit("submit");
 }
 
-let buttonHeightForSelective = $computed(() =>
+const buttonHeightForSelective = $computed(() =>
   store.setting.selective && store.setting.enableAllZero ? "36px" : "76px"
 );
 </script>

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

@@ -171,7 +171,7 @@ function submit() {
   emit("submit");
 }
 
-let buttonHeightForSelective = $computed(() =>
+const buttonHeightForSelective = $computed(() =>
   store.setting.selective && store.setting.enableAllZero ? "36px" : "76px"
 );
 </script>

+ 3 - 3
src/features/mark/MarkBoardTrack.vue

@@ -201,14 +201,14 @@ watch(
   () => (store.currentScore = undefined)
 );
 
-let questionScore = $computed(
+const questionScore = $computed(
   () =>
     store.currentTask &&
     store.currentQuestion &&
     store.currentTask.markResult.scoreList[store.currentQuestion.__index]
 );
 
-let questionScoreSteps = $computed(() => {
+const questionScoreSteps = $computed(() => {
   const question = store.currentQuestion;
   if (!question) return [];
 
@@ -354,7 +354,7 @@ function submit() {
   emit("submit");
 }
 
-let buttonHeightForSelective = $computed(() =>
+const buttonHeightForSelective = $computed(() =>
   store.setting.selective &&
   store.setting.enableAllZero &&
   !store.setting.forceSpecialTag

+ 4 - 4
src/features/mark/MarkHeader.vue

@@ -359,11 +359,11 @@ import MarkProblemDialog from "./MarkProblemDialog.vue";
 import { isNumber } from "lodash-es";
 import { Modal } from "ant-design-vue";
 
-let modeName = $computed(() =>
+const modeName = $computed(() =>
   store.setting.mode === ModeEnum.TRACK ? "轨迹模式" : "普通模式"
 );
 
-let exchangeModeName = $computed(() =>
+const exchangeModeName = $computed(() =>
   store.setting.mode === ModeEnum.TRACK ? "普通模式" : "轨迹模式"
 );
 
@@ -382,7 +382,7 @@ async function toggleSettingMode() {
   window.location.reload();
 }
 
-let progress = $computed(() => {
+const progress = $computed(() => {
   const { totalCount, markedCount } = store.status;
   if (typeof totalCount !== "number" || totalCount === 0) return 0;
   let p = markedCount / totalCount;
@@ -438,7 +438,7 @@ watchEffect(() => {
   }
 });
 
-let todoCount = $computed(() =>
+const todoCount = $computed(() =>
   typeof store.status.totalCount === "number"
     ? store.status.totalCount - store.status.markedCount
     : "-"

+ 3 - 3
src/features/student/importInspect/ImportInspect.vue

@@ -76,9 +76,9 @@ async function updateTask() {
   }
 }
 
-let isCurrentTagged = $computed(() => tagIds.includes(currentStudentId));
-let isFirst = $computed(() => studentIds.indexOf(currentStudentId) === 0);
-let isLast = $computed(
+const isCurrentTagged = $computed(() => tagIds.includes(currentStudentId));
+const isFirst = $computed(() => studentIds.indexOf(currentStudentId) === 0);
+const isLast = $computed(
   () => studentIds.indexOf(currentStudentId) === studentIds.length - 1
 );
 

+ 5 - 12
src/features/student/importInspect/MarkBoardInspect.vue

@@ -28,10 +28,7 @@
       <template v-for="(groupNumber, index) in groups" :key="index">
         <div class="tw-mb-4 tw-bg-white tw-p-4">
           <div
-            class="
-              tw-flex tw-justify-between tw-place-items-center
-              hover:tw-bg-gray-200
-            "
+            class="tw-flex tw-justify-between tw-place-items-center hover:tw-bg-gray-200"
             @mouseover="addFocusTrack(groupNumber, undefined, undefined)"
             @mouseleave="removeFocusTrack"
           >
@@ -41,11 +38,7 @@
             <template v-for="(question, index2) in questions" :key="index2">
               <div
                 v-if="question.groupNumber === groupNumber"
-                class="
-                  question
-                  tw-flex tw-place-items-center tw-mb-1 tw-font-bold
-                  hover:tw-bg-gray-200
-                "
+                class="question tw-flex tw-place-items-center tw-mb-1 tw-font-bold hover:tw-bg-gray-200"
                 @mouseover="
                   addFocusTrack(
                     undefined,
@@ -110,17 +103,17 @@ watch(
     checkedQuestions.splice(0);
   }
 );
-let groups = $computed(() => {
+const groups = $computed(() => {
   const gs = store.currentTask?.questionList.map((q) => q.groupNumber);
   return [...new Set(gs)].sort((a, b) => a - b);
 });
 
-let questions = $computed(() => {
+const questions = $computed(() => {
   const qs = store.currentTask?.questionList;
   return qs;
 });
 
-let markerScore = $computed(() => store.currentTask?.markerScore || 0);
+const markerScore = $computed(() => store.currentTask?.markerScore || 0);
 
 function fetchTask(next: boolean) {
   emit("fetchTask", next);

+ 5 - 12
src/features/student/studentInspect/MarkBoardInspect.vue

@@ -23,10 +23,7 @@
       <template v-for="(groupNumber, index) in groups" :key="index">
         <div class="tw-mb-4 tw-bg-white tw-p-4">
           <div
-            class="
-              tw-flex tw-justify-between tw-place-items-center
-              hover:tw-bg-gray-200
-            "
+            class="tw-flex tw-justify-between tw-place-items-center hover:tw-bg-gray-200"
             @mouseover="addFocusTrack(groupNumber, undefined, undefined)"
             @mouseleave="removeFocusTrack"
           >
@@ -43,11 +40,7 @@
             <template v-for="(question, index2) in questions" :key="index2">
               <div
                 v-if="question.groupNumber === groupNumber"
-                class="
-                  question
-                  tw-flex tw-place-items-center tw-mb-1 tw-font-bold
-                  hover:tw-bg-gray-200
-                "
+                class="question tw-flex tw-place-items-center tw-mb-1 tw-font-bold hover:tw-bg-gray-200"
                 @mouseover="
                   addFocusTrack(
                     undefined,
@@ -128,17 +121,17 @@ watch(
     checkedQuestions.splice(0);
   }
 );
-let groups = $computed(() => {
+const groups = $computed(() => {
   const gs = store.currentTask?.questionList.map((q) => q.groupNumber);
   return [...new Set(gs)].sort((a, b) => a - b);
 });
 
-let questions = $computed(() => {
+const questions = $computed(() => {
   const qs = store.currentTask?.questionList;
   return qs;
 });
 
-let markerScore = $computed(() => store.currentTask?.markerScore || 0);
+const markerScore = $computed(() => store.currentTask?.markerScore || 0);
 
 function addToCheckedQuestion(question: Question) {
   checkedQuestions.push(question);

+ 1 - 1
src/features/student/studentInspect/MarkBody.vue

@@ -131,7 +131,7 @@ const renderPaperAndMark = async () => {
 
 watch(() => store.currentTask, renderPaperAndMark);
 
-let answerPaperScale = $computed(() => {
+const answerPaperScale = $computed(() => {
   // 放大、缩小不影响页面之前的滚动条定位
   let percentWidth = 0;
   let percentTop = 0;

+ 1 - 1
src/features/student/studentInspect/StudentInspect.vue

@@ -157,7 +157,7 @@ async function getOneOfStuTask() {
   });
 }
 
-let realStudentId = $computed(
+const realStudentId = $computed(
   () => (isSingleStudent ? studentId : store.currentTask?.studentId) as string
 );
 const saveTaskToServer = async () => {