UNPKG

@fish-render/icons

Version:
37 lines (31 loc) 699 B
interface IconConfig { path: string prefix?: string } let globalIconConfig: IconConfig = { path: '/public/icons', prefix: '', } /** * 设置全局图标配置 * @param config 图标配置 */ export function setIconConfig(config: Partial<IconConfig>) { globalIconConfig = { ...globalIconConfig, ...config } } /** * 获取全局图标配置 */ export function getIconConfig(): IconConfig { return globalIconConfig } /** * 构建图标路径 * @param iconName 图标名称 */ export function buildIconPath(iconName: string): string { const config = getIconConfig() const path = config.path const prefix = config.prefix || '' return `${path}/${prefix}${iconName}.svg` }