mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-13 10:30:58 +08:00
27 lines
619 B
JavaScript
27 lines
619 B
JavaScript
import { reactive } from 'vue'
|
|
|
|
const FROSTED_KEY = 'frosted-glass'
|
|
|
|
export const frostedState = reactive({
|
|
enabled: true,
|
|
})
|
|
|
|
function apply() {
|
|
if (!import.meta.client) return
|
|
document.documentElement.dataset.frosted = frostedState.enabled ? 'on' : 'off'
|
|
}
|
|
|
|
export function initFrosted() {
|
|
if (!import.meta.client) return
|
|
const saved = localStorage.getItem(FROSTED_KEY)
|
|
frostedState.enabled = saved !== 'false'
|
|
apply()
|
|
}
|
|
|
|
export function setFrosted(enabled) {
|
|
if (!import.meta.client) return
|
|
frostedState.enabled = enabled
|
|
localStorage.setItem(FROSTED_KEY, enabled ? 'true' : 'false')
|
|
apply()
|
|
}
|