Преглед на файлове

fix: 设置弹窗修改作者名bug

wzl преди 1 месец
родител
ревизия
92de432b16
променени са 1 файла, в които са добавени 15 реда и са изтрити 5 реда
  1. 15 5
      packages/webview/src/components/Dialogs/SettingsDialog.vue

+ 15 - 5
packages/webview/src/components/Dialogs/SettingsDialog.vue

@@ -6,11 +6,11 @@
         <div class="info">
           <div class="row">
             <span>{{ $t('header.settings.author') }}</span>
-            <input type="text" placeholder="ComPDFKit" v-model="author" name="settings">
+            <input type="text" placeholder="ComPDFKit" v-model="authorInput" name="settings">
           </div>
           <div class="row">
             <span>{{ $t('header.settings.annotator') }}</span>
-            <input type="text" placeholder="Guest" v-model="annotator" name="settings">
+            <input type="text" placeholder="Guest" v-model="annotatorInput" name="settings">
           </div>
           <div class="row">
             <span>{{ $t('header.settings.language') }}</span>
@@ -57,6 +57,8 @@
 
   const useViewer = useViewerStore()
   const useDocument = useDocumentStore()
+  const authorInput = ref(useDocument.getAuthor)
+  const annotatorInput = ref(useDocument.getAnnotator)
 
   const show = computed(() => useViewer.isElementOpen('settingsDialog'))
   const author = computed(() => useDocument.getAuthor)
@@ -74,7 +76,15 @@
     }
   })
 
-  watch([author, annotator, selectedLanguage, highlightLink, highlightForm], (newValues, oldValues) => {
+  watch(author, (newVal, oldVal) => {
+    authorInput.value = newVal
+  })
+
+  watch(annotator, (newVal, oldVal) => {
+    annotatorInput.value = newVal
+  })
+
+  watch([authorInput, annotatorInput, selectedLanguage, highlightLink, highlightForm], (newValues, oldValues) => {
     if (newValues[0] !== useDocument.getAuthor ||
       newValues[1] !== useDocument.getAnnotator ||
       newValues[2] !== locale.value ||
@@ -95,8 +105,8 @@
     locale.value = selectedLanguage.value
     window.localStorage.setItem('language', selectedLanguage.value)
     useViewer.closeElement('settingsDialog')
-    useDocument.setAuthor(author.value ? author.value : 'ComPDFKit')
-    useDocument.setAnnotator(annotator.value ? annotator.value : 'Guest')
+    useDocument.setAuthor(authorInput.value ? authorInput.value : 'ComPDFKit')
+    useDocument.setAnnotator(annotatorInput.value ? annotatorInput.value : 'Guest')
     useDocument.setHighlightLink(highlightLink.value)
     useDocument.setHighlightForm(highlightForm.value)
   }