mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-13 17:05:47 +08:00
3ab869b446
* refactor(docs): improve style and fix typo * fix(docs): dark
17 lines
506 B
TypeScript
17 lines
506 B
TypeScript
import { computed, unref } from 'vue'
|
|
import { useData } from 'vitepress'
|
|
import { 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)
|
|
const params = new URLSearchParams(location.value.search)
|
|
return params.get(`feature:${_flag}`) || (theme.value.features || {})[_flag]
|
|
})
|
|
}
|