mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-02 11:17:46 +08:00
perf(hooks): [use-namespace] simplify code (#9298)
This commit is contained in:
parent
8fb1d458df
commit
f0414c7822
@ -1,4 +1,3 @@
|
||||
import { computed, unref } from 'vue'
|
||||
import { useGlobalConfig } from '../use-global-config'
|
||||
|
||||
export const defaultNamespace = 'el'
|
||||
@ -25,29 +24,28 @@ const _bem = (
|
||||
}
|
||||
|
||||
export const useNamespace = (block: string) => {
|
||||
const globalConfig = useGlobalConfig('namespace')
|
||||
const namespace = computed(() => globalConfig.value || defaultNamespace)
|
||||
const namespace = useGlobalConfig('namespace', defaultNamespace)
|
||||
const b = (blockSuffix = '') =>
|
||||
_bem(unref(namespace), block, blockSuffix, '', '')
|
||||
_bem(namespace.value, block, blockSuffix, '', '')
|
||||
const e = (element?: string) =>
|
||||
element ? _bem(unref(namespace), block, '', element, '') : ''
|
||||
element ? _bem(namespace.value, block, '', element, '') : ''
|
||||
const m = (modifier?: string) =>
|
||||
modifier ? _bem(unref(namespace), block, '', '', modifier) : ''
|
||||
modifier ? _bem(namespace.value, block, '', '', modifier) : ''
|
||||
const be = (blockSuffix?: string, element?: string) =>
|
||||
blockSuffix && element
|
||||
? _bem(unref(namespace), block, blockSuffix, element, '')
|
||||
? _bem(namespace.value, block, blockSuffix, element, '')
|
||||
: ''
|
||||
const em = (element?: string, modifier?: string) =>
|
||||
element && modifier
|
||||
? _bem(unref(namespace), block, '', element, modifier)
|
||||
? _bem(namespace.value, block, '', element, modifier)
|
||||
: ''
|
||||
const bm = (blockSuffix?: string, modifier?: string) =>
|
||||
blockSuffix && modifier
|
||||
? _bem(unref(namespace), block, blockSuffix, '', modifier)
|
||||
? _bem(namespace.value, block, blockSuffix, '', modifier)
|
||||
: ''
|
||||
const bem = (blockSuffix?: string, element?: string, modifier?: string) =>
|
||||
blockSuffix && element && modifier
|
||||
? _bem(unref(namespace), block, blockSuffix, element, modifier)
|
||||
? _bem(namespace.value, block, blockSuffix, element, modifier)
|
||||
: ''
|
||||
const is: {
|
||||
(name: string, state: boolean | undefined): string
|
||||
|
Loading…
Reference in New Issue
Block a user