mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-06 03:50:47 +08:00
feat: initialize frosted glass setting
This commit is contained in:
26
frontend_nuxt/utils/frosted.js
Normal file
26
frontend_nuxt/utils/frosted.js
Normal file
@@ -0,0 +1,26 @@
|
||||
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()
|
||||
}
|
||||
@@ -143,7 +143,7 @@ function fallbackThemeTransition(applyFn) {
|
||||
background-color: ${currentBg};
|
||||
z-index: 9999;
|
||||
pointer-events: none;
|
||||
backdrop-filter: blur(1px);
|
||||
backdrop-filter: var(--blur-1);
|
||||
`
|
||||
document.body.appendChild(transitionElement)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user