Browse Source

fix: 修改注释作者bug

wzl 2 months ago
parent
commit
b6800a0562
1 changed files with 13 additions and 5 deletions
  1. 13 5
      packages/webview/src/components/Dialogs/SettingsDialog.vue

+ 13 - 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>
@@ -61,6 +61,8 @@
   const show = computed(() => useViewer.isElementOpen('settingsDialog'))
   const author = computed(() => useDocument.getAuthor)
   const annotator = computed(() => useDocument.getAnnotator)
+  const authorInput = ref(useDocument.getAuthor)
+  const annotatorInput = ref(useDocument.getAnnotator)
   const selectedLanguage = ref(locale.value)
   const highlightLink = ref(true)
   const highlightForm = ref(true)
@@ -74,7 +76,13 @@
     }
   })
 
-  watch([author, annotator, selectedLanguage, highlightLink, highlightForm], (newValues, oldValues) => {
+  watch(annotator, (newVal, oldVal) => {
+    if (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 +103,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(author.value ? authorInput.value : 'ComPDFKit')
+    useDocument.setAnnotator(annotator.value ? annotatorInput.value : 'Guest')
     useDocument.setHighlightLink(highlightLink.value)
     useDocument.setHighlightForm(highlightForm.value)
   }