Explorar o código

fix typecheck

Michael Wang %!s(int64=3) %!d(string=hai) anos
pai
achega
9c6557c806

+ 7 - 3
src/features/OnlineExam/Examing/BooleanQuestionView.vue

@@ -38,7 +38,11 @@ function answerQuestion(studentAnswer: "true" | "false") {
   });
 }
 
-const optionWithNames = { true: "正确", false: "错误" };
+const optionWithNames: Record<string, string> = {
+  true: "正确",
+  false: "错误",
+  "": "",
+};
 </script>
 
 <template>
@@ -46,7 +50,7 @@ const optionWithNames = { true: "正确", false: "错误" };
     <question-body :questionBody="examQuestion.body" />
     <div class="ops">
       <div class="stu-answer">
-        {{ optionWithNames[examQuestion.studentAnswer] }}
+        {{ optionWithNames[examQuestion.studentAnswer ?? ""] }}
       </div>
       <div class="score">({{ examQuestion.questionScore }}分)</div>
     </div>
@@ -91,7 +95,7 @@ const optionWithNames = { true: "正确", false: "错误" };
       <div v-if="isShowAnswer" class="tw-mt-2">
         正确答案:
         <div>
-          {{ optionWithNames[examQuestion.rightAnswer] }}
+          {{ optionWithNames[examQuestion.rightAnswer + ""] }}
         </div>
       </div>
     </div>

+ 6 - 1
src/features/SiteMessage/SiteMessage.vue

@@ -67,6 +67,11 @@ async function toMarkRead() {
 onMounted(() => {
   void fetchSiteMessage();
 });
+
+// make ts happy
+function rowKey(row: { id: number }) {
+  return row.id;
+}
 </script>
 
 <template>
@@ -83,7 +88,7 @@ onMounted(() => {
       :columns="columns"
       :data="messageList"
       :pagination="pagination"
-      :rowKey="(row) => row.id"
+      :rowKey="rowKey"
       @update:checkedRowKeys="selectedChange"
     ></n-data-table>
   </div>