mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Implement import of all SVG icons as assets in new frontend
This commit is contained in:
parent
81c4eebf06
commit
bc3f18ae87
@ -7,14 +7,34 @@ import { createVuetify, IconAliases } from 'vuetify'
|
||||
import { aliases } from 'vuetify/iconsets/mdi-svg'
|
||||
import { createVueI18nAdapter } from 'vuetify/locale/adapters/vue-i18n'
|
||||
|
||||
import CustomIcons from '#assets/icons'
|
||||
import CustomIcon from '#assets/icons/svgComponents/glass.vue'
|
||||
|
||||
console.log('aliases: ', aliases)
|
||||
console.log('CustomIcons.glass: ', CustomIcons.glass.default)
|
||||
console.log('CustomIcon: ', CustomIcon)
|
||||
|
||||
const aliasesCustom: IconAliases = {
|
||||
...aliases,
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
glass: CustomIcon,
|
||||
// glass: CustomIcon,
|
||||
glass: CustomIcons.glass.default as never,
|
||||
// ...CustomIcons,
|
||||
}
|
||||
|
||||
// CustomIcons.forEach((component) => {
|
||||
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
// aliasesCustom[component.iconName] = component.mod
|
||||
// })
|
||||
|
||||
// for (const component in CustomIcons) {
|
||||
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
// aliasesCustom[component.iconName] = component.mod
|
||||
// }
|
||||
// Object.entries(CustomIcons).forEach(([key, module]) => {
|
||||
// // aliasesCustom[key] = module as IconValue
|
||||
// aliasesCustom = { ...aliasesCustom, [key]: module }
|
||||
// })
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export default (i18n: I18n<any, NonNullable<unknown>, NonNullable<unknown>, string, false>) =>
|
||||
createVuetify({
|
||||
|
||||
21
frontend/src/assets/icons/index.ts
Normal file
21
frontend/src/assets/icons/index.ts
Normal file
@ -0,0 +1,21 @@
|
||||
// see https://vitejs.dev/guide/features.html#glob-import
|
||||
const iconsModule = import.meta.glob('./svgComponents/' + '*.vue', {
|
||||
eager: true,
|
||||
})
|
||||
|
||||
// Wolle console.log('iconsModule: ', iconsModule)
|
||||
|
||||
type Module = {
|
||||
default: object
|
||||
}
|
||||
const icons: Record<string, Module> = {}
|
||||
|
||||
Object.entries(iconsModule).forEach(([key, module]) => {
|
||||
const iconName: string = key.split('/').slice(-1)[0].replace('.vue', '')
|
||||
// eslint-disable-next-line security/detect-object-injection
|
||||
icons[iconName] = module as Module
|
||||
})
|
||||
|
||||
// Wolle console.log('icons: ', icons)
|
||||
|
||||
export default icons
|
||||
Loading…
x
Reference in New Issue
Block a user