
Security News
PolinRider: North Korea-Linked Supply Chain Campaign Expands Across Open Source Ecosystems
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.
vite-plugin-vue-pages
Advanced tools
自动生成路由和菜单。
因为文件命名规则和路由匹配语法冲突,因此添加了使用template的path属性支持路由匹配的方式;因为目录结构通常用于组织模块,而布局和视图通常是二级的关系,很多时候无法通过目录结构生成布局,因此使用布局文件解决这个问题;通过给目录添加同名组件的方式,支持自定义菜单的生成。
// ...
import vuePages from 'vite-plugin-vue-pages';
export default defineConfig({
// ...
plugins: [
// { pageDir: 'src/pages', menuDir: 'src/assets/icons' }
vuePages({ pageDir: 'src/views' })
],
});
|--- _Layout.vue |---_Empty.vue |--- Index.vue |--- About.vue |--- Login.vue |--- NotFound.vue |--- Account.vue |--- Account | |--- _Layout.vue | |--- Index.vue |--- Admin.vue |--- Admin | |---_Layout.vue | |--- Index.vue | |--- Group1 | |--- Index.vue | |--- Group2 | |---_Layout.vue | |--- Index.vue
// import { routes,menus } from 'virtual:vuepages';
import { defineAsyncComponent } from "vue";
const routes = [
{
"children": [
{
"name": "About",
"component": () => import('./src/views/About.vue'),
"meta": {
"title": "About",
"order": "3",
"icon": "folder"
},
"path": "/About"
},
{
"name": "Index",
"component": () => import('./src/views/Index.vue'),
"meta": {
"title": "Home",
"roles": "*",
"icon": "home"
},
"path": "/"
}
],
"isDirectory": false,
"fileNameWithoutExt": "_Layout",
"name": "_Layout",
"component": () => import('./src/views/_Layout.vue'),
"meta": {
"icon": "folder"
},
"path": "/"
},
{
"children": [
{
"name": "Account-Index",
"component": () => import('./src/views/Account/Index.vue'),
"meta": {
"title": "Account-Index",
"icon": "folder"
},
"path": "/Account"
}
],
"isDirectory": false,
"fileNameWithoutExt": "_Layout",
"name": "Account-_Layout",
"component": () => import('./src/views/Account/_Layout.vue'),
"meta": {
"icon": "folder"
},
"path": "/Account"
},
{
"children": [
{
"name": "Admin-Group2-Index",
"component": () => import('./src/views/Admin/Group2/Index.vue'),
"meta": {
"title": "Admin-Group2-Index",
"order": "1",
"icon": "folder"
},
"path": "/Admin/Group2"
}
],
"isDirectory": false,
"fileNameWithoutExt": "_Layout",
"name": "Admin-Group2-_Layout",
"component": () => import('./src/views/Admin/Group2/_Layout.vue'),
"meta": {
"icon": "folder"
},
"path": "/Admin/Group2"
},
{
"children": [
{
"name": "Admin-Group1-Index",
"component": () => import('./src/views/Admin/Group1/Index.vue'),
"meta": {
"title": "Admin-Group1-Index",
"order": "2",
"icon": "folder"
},
"path": "/Admin/Group1"
},
{
"name": "Admin-Index",
"component": () => import('./src/views/Admin/Index.vue'),
"meta": {
"title": "Admin-Index",
"icon": "folder"
},
"path": "/Admin"
}
],
"isDirectory": false,
"fileNameWithoutExt": "_Layout",
"name": "Admin-_Layout",
"component": () => import('./src/views/Admin/_Layout.vue'),
"meta": {
"icon": "folder"
},
"path": "/Admin"
},
{
"children": [
{
"name": "Login",
"component": () => import('./src/views/Login.vue'),
"meta": {
"title": "Login",
"layout": "_Empty",
"hidden": true,
"icon": "folder"
},
"path": "/Login"
}
],
"isDirectory": false,
"fileNameWithoutExt": "_Empty",
"name": "_Empty",
"component": () => import('./src/views/_Empty.vue'),
"meta": {
"icon": "folder"
},
"path": "/"
},
{
"name": "NotFound",
"component": () => import('./src/views/NotFound.vue'),
"meta": {
"path": ":pathMatch(.*)*",
"layout": "null",
"title": "404",
"hidden": true,
"icon": "folder"
},
"path": "/:pathMatch(.*)*"
}];
const menus = [
{
"isDirectory": false,
"path": "/",
"title": "Home",
"icon": "home",
"order": 0,
"component": defineAsyncComponent(() => import('./src/assets/icons/home.svg'))
},
{
"isDirectory": false,
"path": "/Login",
"hidden": true,
"title": "Login",
"icon": "folder",
"order": 0,
"component": defineAsyncComponent(() => import('./src/assets/icons/folder.svg'))
},
{
"isDirectory": false,
"path": "/:pathMatch(.*)*",
"hidden": true,
"title": "404",
"icon": "folder",
"order": 0,
"component": defineAsyncComponent(() => import('./src/assets/icons/folder.svg'))
},
{
"isDirectory": true,
"title": "Admin",
"icon": "file",
"order": 1,
"component": defineAsyncComponent(() => import('./src/assets/icons/file.svg')),
"children": [
{
"isDirectory": false,
"path": "/Admin",
"title": "Admin-Index",
"icon": "folder",
"order": 0,
"component": defineAsyncComponent(() => import('./src/assets/icons/folder.svg'))
},
{
"isDirectory": false,
"path": "/Admin/Group2",
"title": "Admin-Group2-Index",
"icon": "folder",
"order": 1,
"component": defineAsyncComponent(() => import('./src/assets/icons/folder.svg'))
},
{
"isDirectory": false,
"path": "/Admin/Group1",
"title": "Admin-Group1-Index",
"icon": "folder",
"order": 2,
"component": defineAsyncComponent(() => import('./src/assets/icons/folder.svg'))
}
]
},
{
"isDirectory": true,
"title": "Account",
"icon": "user",
"order": 2,
"component": defineAsyncComponent(() => import('./src/assets/icons/user.svg')),
"children": [
{
"isDirectory": false,
"path": "/Account",
"title": "Account-Index",
"icon": "folder",
"order": 0,
"component": defineAsyncComponent(() => import('./src/assets/icons/folder.svg'))
}
]
},
{
"isDirectory": false,
"path": "/About",
"title": "About",
"icon": "folder",
"order": 3,
"component": defineAsyncComponent(() => import('./src/assets/icons/folder.svg'))
}];
export { routes, menus };
FAQs
File system based routing for Vue 3 applications using Vite
The npm package vite-plugin-vue-pages receives a total of 8 weekly downloads. As such, vite-plugin-vue-pages popularity was classified as not popular.
We found that vite-plugin-vue-pages demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
PolinRider expands across npm, Packagist, Go modules, and Chrome extensions, using hidden loaders to target developer environments.

Security News
Open source attacks are accelerating as AI coding agents pull in dependencies faster, with less human review.

Research
/Security News
Malicious Chrome and Firefox extensions posed as free VPNs while stealing clipboard data through later extension updates.