import {
addIcon,
// addCollection
} from '@vben-core/icons';
let loaded = false;
if (!loaded) {
loadSvgIcons();
loaded = true;
}
// addCollection({
// prefix: 'mdi',
// icons: {
// 'account-box': {
// body: '',
// },
// 'account-cash': {
// body: '',
// },
// 'account': {
// body: '',
// },
// 'home': {
// body: '',
// },
// },
// width: 24,
// height: 24,
// });
/**
* 自定义的svg图片转化为组件
* @example ./svg/avatar.svg
*
*/
async function loadSvgIcons() {
const svgEagers = import.meta.glob('./icons/**', {
eager: true,
query: '?raw',
});
await Promise.all(
Object.entries(svgEagers).map((svg) => {
const [key, body] = svg as [string, { default: string } | string];
// ./icons/xxxx.svg => xxxxxx
const start = key.lastIndexOf('/') + 1;
const end = key.lastIndexOf('.');
const iconName = key.slice(start, end);
return addIcon(`svg:${iconName}`, {
body: typeof body === 'object' ? body.default : body,
});
}),
);
}