mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 19:15:52 +02:00
Update MkSwitch.vue
This commit is contained in:
@@ -27,7 +27,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { toRefs } from 'vue';
|
import { ref, toRefs, watch } from 'vue';
|
||||||
import type { Ref } from 'vue';
|
import type { Ref } from 'vue';
|
||||||
import XButton from '@/components/MkSwitch.button.vue';
|
import XButton from '@/components/MkSwitch.button.vue';
|
||||||
import { haptic } from '@/utility/haptic.js';
|
import { haptic } from '@/utility/haptic.js';
|
||||||
@@ -44,11 +44,18 @@ const emit = defineEmits<{
|
|||||||
(ev: 'change', v: boolean): void;
|
(ev: 'change', v: boolean): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const checked = toRefs(props).modelValue;
|
const checked = ref(props.modelValue);
|
||||||
|
|
||||||
|
watch(() => props.modelValue, v => {
|
||||||
|
checked.value = v;
|
||||||
|
});
|
||||||
|
|
||||||
const toggle = () => {
|
const toggle = () => {
|
||||||
if (props.disabled) return;
|
if (props.disabled) return;
|
||||||
emit('update:modelValue', !checked.value);
|
|
||||||
emit('change', !checked.value);
|
checked.value = !checked.value;
|
||||||
|
emit('update:modelValue', checked.value);
|
||||||
|
emit('change', checked.value);
|
||||||
|
|
||||||
haptic();
|
haptic();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user