fix: global reactive attrs
change to ref for primitive types, use provide/inject instead of globalConfig
This commit is contained in:
@@ -5,6 +5,8 @@ import VueHcaptcha from '@hcaptcha/vue3-hcaptcha';
|
|||||||
import { RecaptchaV2, useRecaptcha } from "vue3-recaptcha-v2";
|
import { RecaptchaV2, useRecaptcha } from "vue3-recaptcha-v2";
|
||||||
import VueTurnstile from 'vue-turnstile';
|
import VueTurnstile from 'vue-turnstile';
|
||||||
|
|
||||||
|
const $darkMode = inject('$darkMode');
|
||||||
|
|
||||||
const { handleReset: handleRecaptchaReset } = useRecaptcha();
|
const { handleReset: handleRecaptchaReset } = useRecaptcha();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { useRouter, RouterLink } from 'vue-router';
|
import { useRouter, RouterLink } from 'vue-router';
|
||||||
import { computed } from 'vue';
|
import { computed, inject } from 'vue';
|
||||||
import { useAuthStore } from '../stores/auth';
|
import { useAuthStore } from '../stores/auth';
|
||||||
|
|
||||||
|
const $isMobile = inject('$isMobile');
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
import { reactive } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const darkModeMediaQuery = '(prefers-color-scheme: dark)';
|
const darkModeMediaQuery = '(prefers-color-scheme: dark)';
|
||||||
const matchMedia = window.matchMedia(darkModeMediaQuery);
|
const matchMedia = window.matchMedia(darkModeMediaQuery);
|
||||||
|
|
||||||
const darkMode = reactive(matchMedia.matches);
|
const darkMode = ref(matchMedia.matches);
|
||||||
|
|
||||||
matchMedia.addEventListener('change', (event) => {
|
matchMedia.addEventListener('change', (event) => {
|
||||||
darkMode = event.matches;
|
darkMode.value = event.matches;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const install = (app) => {
|
export const install = (app) => {
|
||||||
app.config.globalProperties.$darkMode = darkMode;
|
app.provide('$darkMode', darkMode);
|
||||||
}
|
}
|
||||||
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
import { reactive } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const mobileMediaQuery = 'screen and (max-width: 768px)';
|
const mobileMediaQuery = 'screen and (max-width: 768px)';
|
||||||
const matchMedia = window.matchMedia(mobileMediaQuery);
|
const matchMedia = window.matchMedia(mobileMediaQuery);
|
||||||
|
|
||||||
const isMobile = reactive(matchMedia.matches);
|
const isMobile = ref(matchMedia.matches);
|
||||||
|
|
||||||
matchMedia.addEventListener('change', (event) => {
|
matchMedia.addEventListener('change', (event) => {
|
||||||
isMobile = event.matches;
|
isMobile.value = event.matches;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const install = (app) => {
|
export const install = (app) => {
|
||||||
app.config.globalProperties.$isMobile = isMobile;
|
app.provide('$isMobile', isMobile);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user