fix: darkMode plugin
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { defineEmits, defineExpose, defineProps, watch, ref, onMounted } from 'vue';
|
import { defineEmits, defineExpose, defineProps, watch, ref, onMounted, getCurrentInstance } from 'vue';
|
||||||
|
|
||||||
import VueHcaptcha from '@hcaptcha/vue3-hcaptcha';
|
import VueHcaptcha from '@hcaptcha/vue3-hcaptcha';
|
||||||
import { RecaptchaV2, useRecaptcha } from "vue3-recaptcha-v2";
|
import { RecaptchaV2, useRecaptcha } from "vue3-recaptcha-v2";
|
||||||
@@ -80,7 +80,7 @@ defineExpose({
|
|||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log(props);
|
console.log(getCurrentInstance().appContext.config.globalProperties.$darkMode);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -3,12 +3,10 @@ import { reactive } 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({
|
const darkMode = reactive(matchMedia.matches);
|
||||||
value: matchMedia.matches,
|
|
||||||
});
|
|
||||||
|
|
||||||
matchMedia.addEventListener('change', (event) => {
|
matchMedia.addEventListener('change', (event) => {
|
||||||
darkMode.value = event.matches;
|
darkMode = event.matches;
|
||||||
});
|
});
|
||||||
|
|
||||||
export const install = (app) => {
|
export const install = (app) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user