# vue-router-automation

> 提供了vue项目的路由自动化，匹配所有.vue文件，剔除APP.vue入口文件

Latest version **2.3.1** (published 2024-05-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install vue-router-automation
pnpm add vue-router-automation
yarn add vue-router-automation
bun add vue-router-automation
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.1 |
| Published | 2024-05-09 |
| First published | 2022-10-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | huyaopeng |
| Keywords | vue-router-automation, vue-router, vue-router-auto, vue路由自动化, vue路由自定义, 实用函数, Node.js, vue2, vue3 |

## Links

- npm: https://www.npmjs.com/package/vue-router-automation
- Repository: https://gitee.com/web_io/node-packages/tree/master
- npm.io page: https://npm.io/package/vue-router-automation

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 2.3.1 (latest) — 2024-05-09
- 2.3.0 — 2024-05-09
- 2.2.8 — 2023-12-02
- 2.2.7 — 2023-12-02
- 2.2.6 — 2023-12-01
- 2.2.5 — 2023-12-01
- 2.2.4 — 2023-05-12
- 2.2.3 — 2023-04-19
- 2.2.2 — 2023-04-19
- 2.2.1 — 2023-04-18
- 2.1.5 — 2023-04-12
- 2.1.4 — 2023-01-10
- 2.1.3 — 2022-12-19
- 2.1.2 — 2022-12-19
- 2.1.1 — 2022-12-19
- … 10 more at https://npm.io/package/vue-router-automation/versions

## README

## 安装本项目
```
npm i vue-router-automation
```
## 项目说明
本项目基于webpack提供了一个context方法来获取到目录下的所有文件，我们可以通过require.context方法拿到我们想要的指定文件夹下所有的vue文件。
基于webpack的vue2/vue3项目都可以使用本项目，只需要在router/index.js文件中导入vue-router-automation，然后调用Sroutes方法即可。
## 参数说明
| 序号 | 内容 |
|--|--|
| 参数1 | 第一个参数是根路由指向文件 |
| 参数2 | 第二个参数是路由meta默认自定义信息，默认为{} |
## 使用说明
### 1、基础使用
```js
// 在router/index.js文件使用，将包导入router/index.js文件中
// 导入
const R=require('vue-router-automation');
// 路由生成
const routers=R.Sroutes('views/index',{});

// 导出生成的路由，将生成的路由添加到vue-router中
const routes = R.routes;
const router = new VueRouter({
  routes
})
```
### 2.进阶使用（路由信息自定义）
```js
// 在router/index.js文件使用，将包导入router/index.js文件中
// 导入
const R=require('vue-router-automation');
// 注意：当需要添加自定义meta信息时，第二个meta参数，必须填写默认信息，不能为{}。
// 路由生成
const routers=R.Sroutes('views/index',{header:true,footer:true});

// 导出生成的路由，将生成的路由添加到vue-router中
const routes = R.routes;
const router = new VueRouter({
  routes
})

// 通过路由守卫进行路由定制化，自定义meta等信息
router.beforeEach((to,form,next)=>{
    //当前路由
    const Rpath=to.path;
    //定制化路由集合
    let Rarry=[
        "/",
        "/curriculum/view",
        "/news/view"
    ];
    //添加路由自定义信息
    Rarry.forEach(item=>{
        if (Rpath==item) {
          to.meta.haeder=false;
          to.meta.footer=true
        }
    })
    console.log('打印守卫信息',to)
    next();
})
```

---
_Source: https://npm.io/package/vue-router-automation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
