Prechádzať zdrojové kódy

Fix some type errors

Andrea Franceschini 2 rokov pred
rodič
commit
4785f3fb74
1 zmenil súbory, kde vykonal 10 pridanie a 7 odobranie
  1. 10 7
      components/CookieMonster.vue

+ 10 - 7
components/CookieMonster.vue

@@ -10,11 +10,11 @@
                         <p class="col-span-5 sm:col-span-11"><strong>Consent</strong>: I must use a cookie to keep track of your choices, no way around it.</p>
                     </div>
                     <div class="sm:pl-4 pt-2 grid sm:grid-cols-12 grid-cols-6">
-                        <p><input type="checkbox" class="form-control toggle toggle-primary" v-model="consentStore.analytics" @change="(e) => { consentStore.analytics = e.target.checked }" /></p>
+                        <p><input type="checkbox" class="form-control toggle toggle-primary" v-model="consentStore.analytics" @change="(e: Event) => consentStore.analytics = (e.target as HTMLInputElement).checked " /></p>
                         <p class="col-span-5 sm:col-span-11"><strong>Analytics</strong>: optional, but it'd be great if you agreed 😊</p>
                     </div>
                     <div class="sm:pl-4 pt-2 grid sm:grid-cols-12 grid-cols-6">
-                        <p><input type="checkbox" class="form-control toggle toggle-primary" v-model="consentStore.ads" @change="(e) => { consentStore.ads = e.target.checked }" /></p>
+                        <p><input type="checkbox" class="form-control toggle toggle-primary" v-model="consentStore.ads" @change="(e: Event) => consentStore.ads = (e.target as HTMLInputElement).checked" /></p>
                         <p class="col-span-5 sm:col-span-11"><strong>Advertising</strong>: fully optional, feel free to skip this one.</p>
                     </div>
                     <p class="pt-2">You can read more on how I use cookies on <a href="/cookies">this page</a>.</p>
@@ -26,36 +26,38 @@
                 </div>
             </div>
         </div>
-        <div v-else @click="isOpen = true" class="fixed max-w-0 bottom-2 sm:right-16 right-11 cursor-pointer">
+        <div v-else class="fixed max-w-0 bottom-2 sm:right-16 right-11 cursor-pointer" @click="isOpen = true">
             <ClientOnly><fa-icon icon="fa-solid fa-cookie-bite" class="sm:text-6xl text-4xl text-sky-500" /></ClientOnly>
         </div>
     </div>
 </template>
 
-<script setup>
+<script lang="ts" setup>
 import { useConsent } from '~~/store/consent';
 const consentStore = useConsent();
 
 const error = useError();
 const isOpen = useState('isOpen', () => !consentStore.preferenceGiven && error.value === undefined);
 
-const rejectAll = () => {
+const rejectAll = (e: MouseEvent | undefined) => {
     window._paq.push(['forgetCookieConsentGiven']);
     consentStore.analytics = false;
     consentStore.ads = false;
     consentStore.preferenceGiven = true;
     isOpen.value = false;
+    return e;
 }
 
-const acceptAll = (e) => {
+const acceptAll = (e: MouseEvent | undefined) => {
     window._paq.push(['rememberCookieConsentGiven']);
     consentStore.analytics = true;
     consentStore.ads = true;
     consentStore.preferenceGiven = true;
     isOpen.value = false;
+    return e;
 }
 
-const acceptMyChoice = () => {
+const acceptMyChoice = (e: MouseEvent | undefined) => {
     consentStore.preferenceGiven = true;
     isOpen.value = false;
     if (consentStore.analytics) {
@@ -63,6 +65,7 @@ const acceptMyChoice = () => {
     } else {
         window._paq.push(['forgetCookieConsentGiven']);
     }
+    return e;
 }
 </script>