lx-music-desktop/src/renderer-lyric/components/index.js
2023-08-07 18:49:14 +08:00

23 lines
659 B
JavaScript

import upperFirst from 'lodash/upperFirst'
import camelCase from 'lodash/camelCase'
const requireComponent = import.meta.glob(['./**/*.vue', '!./**/components/**/*.vue'], { eager: true })
const vueFileRxp = /\.vue$/
const vueIndexFileRxp = /\/index\.vue$/
export default app => {
Object.entries(requireComponent).forEach(([path, module]) => {
path = path.replace(/^\.\//, '')
let fileName = vueIndexFileRxp.test(path)
? path.replace(vueIndexFileRxp, '')
: path.replace(vueFileRxp, '')
let componentName = upperFirst(camelCase(fileName))
// console.log(componentName)
app.component(componentName, module.default)
})
}