mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 01:11:25 +08:00
23 lines
575 B
TypeScript
23 lines
575 B
TypeScript
import { computed, unref } from 'vue'
|
|
import { useData } from 'vitepress'
|
|
import { isClient, useBrowserLocation } from '@vueuse/core'
|
|
import type { MaybeRef } from '@vueuse/core'
|
|
|
|
const location = useBrowserLocation()
|
|
|
|
export const useFeatureFlag = (flag: MaybeRef<string>) => {
|
|
const { theme } = useData()
|
|
return computed(() => {
|
|
const _flag = unref(flag)
|
|
|
|
if (isClient) {
|
|
const params = new URLSearchParams(location.value.search)
|
|
if (params.get(`feature:${_flag}`)) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return theme.value.features[_flag]
|
|
})
|
|
}
|