mirror of
https://github.com/fmhy/edit.git
synced 2026-01-12 23:11:06 +11:00
feat: disable toggle starred to maintain consistency
This commit is contained in:
parent
da9cb76361
commit
61d5f2b08c
1 changed files with 12 additions and 2 deletions
|
|
@ -2,10 +2,13 @@
|
||||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
import Switch from './Switch.vue'
|
import Switch from './Switch.vue'
|
||||||
|
|
||||||
|
const isDisabled = ref(false)
|
||||||
const isOn = ref(false)
|
const isOn = ref(false)
|
||||||
|
|
||||||
const syncState = () => {
|
const syncState = () => {
|
||||||
isOn.value = document.documentElement.classList.contains('indexes-only')
|
const root = document.documentElement
|
||||||
|
isDisabled.value = root.classList.contains('starred-only')
|
||||||
|
isOn.value = root.classList.contains('indexes-only')
|
||||||
}
|
}
|
||||||
|
|
||||||
let observer: MutationObserver | undefined
|
let observer: MutationObserver | undefined
|
||||||
|
|
@ -22,6 +25,11 @@ onMounted(syncState)
|
||||||
onBeforeUnmount(() => observer?.disconnect())
|
onBeforeUnmount(() => observer?.disconnect())
|
||||||
|
|
||||||
const toggleIndexes = (value: boolean) => {
|
const toggleIndexes = (value: boolean) => {
|
||||||
|
if (isDisabled.value) {
|
||||||
|
isOn.value = document.documentElement.classList.contains('indexes-only')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const root = document.documentElement
|
const root = document.documentElement
|
||||||
const enabling = value
|
const enabling = value
|
||||||
const wasStarred = root.classList.contains('starred-only')
|
const wasStarred = root.classList.contains('starred-only')
|
||||||
|
|
@ -47,7 +55,9 @@ const toggleIndexes = (value: boolean) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Switch v-model="isOn" @update:modelValue="toggleIndexes" />
|
<Switch v-model="isOn"
|
||||||
|
:disabled="isDisabled"
|
||||||
|
:class="{ disabled: isDisabled }"@update:modelValue="toggleIndexes" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue