瀏覽代碼

feat: use Options update

chenhao 2 年之前
父節點
當前提交
baa49b94c3
共有 1 個文件被更改,包括 19 次插入15 次删除
  1. 19 15
      src/hooks/useOptions.ts

+ 19 - 15
src/hooks/useOptions.ts

@@ -107,10 +107,10 @@ const useOptions = (
     () => dataModel.subject,
     () => {
       if (types.includes('question') && dataModel.subject) {
-        resetQuestionFetch()
-        resetGroupList()
-        changeModelValue('question')(void 0)
-        changeModelValue('group')(void 0)
+        // resetQuestionFetch()
+        // resetGroupList()
+        // changeModelValue('question')(void 0)
+        // changeModelValue('group')(void 0)
         getMainQuestionList({ subjectCode: dataModel.subject })
       }
     },
@@ -121,8 +121,8 @@ const useOptions = (
     () => dataModel.question,
     () => {
       if (types.includes('group') && dataModel.subject && dataModel.question) {
-        resetGroupList()
-        changeModelValue('group')(void 0)
+        // resetGroupList()
+        // changeModelValue('group')(void 0)
         getQuestionGroupList({ subjectCode: dataModel.subject, mainNumber: dataModel.question })
       }
     },
@@ -155,15 +155,19 @@ const useOptions = (
 
   const initFinish = ref<boolean>(false)
 
-  const destroyInit = watch(dataModel, () => {
-    if (types.every((t) => dataModel[t])) {
-      nextTick(() => {
-        initCallbacks.forEach((cb) => cb(dataModel))
-        initFinish.value = true
-        destroyInit()
-      })
-    }
-  })
+  const destroyInit = watch(
+    dataModel,
+    () => {
+      if (types.every((t) => dataModel[t])) {
+        nextTick(() => {
+          initCallbacks.forEach((cb) => cb(dataModel))
+          initFinish.value = true
+          destroyInit()
+        })
+      }
+    },
+    { immediate: true }
+  )
 
   const initCallbacks: ((d: DataModel) => void)[] = []