Add indexes toggle and disable starred

This commit is contained in:
Eason Li 2026-01-05 09:12:06 +08:00
parent 2373c0acfd
commit 01dfd2ec26
5 changed files with 68 additions and 13 deletions

View file

@ -1,12 +1,34 @@
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue'
import Switch from './Switch.vue'
const toggleStarred = () =>
const isDisabled = ref(false)
const syncDisabled = () => {
isDisabled.value = document.documentElement.classList.contains('indexes-only')
}
let observer: MutationObserver | undefined
onMounted(() =>
(observer = new MutationObserver(syncDisabled)).observe(document.documentElement, {
attributes: true,
attributeFilter: ['class']
})
)
onMounted(syncDisabled)
onBeforeUnmount(() => observer?.disconnect())
const toggleStarred = () => {
if (isDisabled.value) return
document.documentElement.classList.toggle('starred-only')
}
</script>
<template>
<Switch @click="toggleStarred()" />
<Switch :class="{ disabled: isDisabled }" @click="toggleStarred()" />
</template>
<style>