2025/2/8第一次更新

This commit is contained in:
爱吃咸鱼小猫咪
2025-02-08 18:50:38 +08:00
commit d7af560866
26519 changed files with 5046029 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import { computed, inject, ref, unref } from 'vue'
import { isNumber } from '../../utils'
import type { InjectionKey, Ref } from 'vue'
const zIndex = ref(0)
const defaultInitialZIndex = 2000
export const zIndexContextKey: InjectionKey<Ref<number | undefined>> =
Symbol('zIndexContextKey')
export const useZIndex = () => {
const zIndexInjection = inject(zIndexContextKey, undefined)
const initialZIndex = computed(() => {
const zIndexFromInjection = unref(zIndexInjection)
return isNumber(zIndexFromInjection)
? zIndexFromInjection
: defaultInitialZIndex
})
const currentZIndex = computed(() => initialZIndex.value + zIndex.value)
const nextZIndex = () => {
zIndex.value++
return currentZIndex.value
}
const prevZIndex = () => {
zIndex.value--
return currentZIndex.value
}
return {
initialZIndex,
currentZIndex,
nextZIndex,
prevZIndex,
}
}