useWidgetKey.ts
589 Bytes
export const EXTERNAL_WIDGET_PREFIX = 'External'
export const matchExternalPrefixReg = new RegExp(`^${EXTERNAL_WIDGET_PREFIX}`)
export const CHART_COMPONENT_PREFIX = 'VC'
export const CONFIG_COMPONENT_PREFIX = 'VCC'
/**
 * 
 * @param scope directory name 目录名
 * @returns 
 */
export const useWidgetKey = (scope: string, extendPrimitiveCategory = true) => {
  const prefix = extendPrimitiveCategory ? EXTERNAL_WIDGET_PREFIX : ''
  return {
    key: scope,
    chartKey: `${prefix}${CHART_COMPONENT_PREFIX}${scope}`,
    conKey: `${prefix}${CONFIG_COMPONENT_PREFIX}${scope}`
  }
}