init 初始化

This commit is contained in:
yuping
2022-11-28 11:33:26 +08:00
parent 6424a4857b
commit 89c47f7a60
14 changed files with 636 additions and 30 deletions

View File

@@ -1,16 +1,14 @@
const routes = [];
const context = require.context('@/views', true, /\.vue$/, 'lazy');
context.keys().forEach(path => {
// console.log('path', path)
const context =import.meta.glob("../views/*/*.vue")
Object.keys(context).forEach(path => {
const componentName = path.replace(/.*\/([^\\.\\/]*)\.vue$/, '$1');
routes.push({
path: `/${componentName.toLowerCase()}`,
name: componentName,
component: () => context(path),
component: () => import(path/* @vite-ignore */),
meta: {
isLink: true
}
});
});
export default routes;