用 iBiu 3 秒构建出大型 Vue 项目架子

6,687 阅读2分钟

本套工具是iview cli 的二次开发,意在解决项目创建时路由与页面对应的大痛点

项目地址

windows 64位版本软件下载

MAC 软件下载

linux ,windows 32位版本 你们可以自己build

我从去年11月开始用vue写项目,算算到现在已经经历了4-5个项目的历练了,但是即使每次项目搭建有脚手架的辅助以及自己每次对自己项目架构的优化,总会遇到一件恶心的事,那就是创建页面,并且将页面绑定到路由上,而且每次项目页面结构改变,就得又重新注册一路由,极其繁琐,没有意义。况且在一些页面层级繁多的产品中这一点更是折磨人。

孔子曾经说过懒惰是程序员的第一美德,而我是懒癌晚期,不想浪费时间写那些重复几十次的东西,我就想给他个数组

[
    {
    "name": "视频",
    "short": "video",
    "children": [
      {
        "name": "搞笑视频",
        "short": "funny",
        "children": [
          {
            "name": "恶搞",
            "short": "sproof"
          },
          {
            "name": "无厘头",
            "short": "wulitou"
          }
        ]
      },
    }
    ...,
    ..., // 假比这里有很多。。。


]

然后自己就屁颠屁颠生成

├── 404.vue
└── video
    ├── funny
    │   ├── index.vue
    │   ├── sproof
    │   │   └── index.vue
    │   └── wulitou
    │       └── index.vue
    ├── index.vue
    ├── scary
    │   ├── blood
    │   │   └── index.vue
    │   ├── ghost
    │   │   └── index.vue
    │   └── index.vue
    ├── sports
    │   ├── index.vue
    │   ├── skating
    │   │   └── index.vue
    │   └── surfing
    │       └── index.vue
    └── travel
        ├── history
        │   └── index.vue
        ├── index.vue
        └── scenery
            └── index.vue
        ....
        ...
    .....
    ..... //剩余的不再赘述

还给我注册好了路由 🕶

import Vue from 'vue';
import Router from 'vue-router';
import contend from 'views/index.vue'
import login from 'views/login.vue'
import notF from 'views/404.vue'



import video from './video.js';
import posts from './posts.js';
import games from './games.js';
import music from './music.js';


Vue.use(Router);

export default new Router({
    mode: 'history',
    routes: [{
            path: '/',
            name: 'home',
            redirect: '/video',
            component: contend,
            children: [
                video, // 这里面全是每个主要页面的子页面路由
                posts,
                games,
                music,

            ]

        },
        {
            path: '/login',
            name: 'login',
            component: login
        },
        {
            path: '*',
            name: '404',
            component: notF
        }
    ]
})

这才是我心中更好的脚手架工具,说干就干,于是自己操刀写了一个 cli工具,意在解决开发者不用浪费时间在路由的注册上。
于是...

iBiu诞生了

你只需要三步操作

然后打开目录,terminal敲下
npm install
然后
npm run dev
NOW 见证奇迹的时刻!!!!

你会发现你的前端网页架子已经搭好了,而且你会发现所有页面的路由已经为你配置好了(注意看 地址栏)😱,而且,而且还给你贴心的加上了一个login页面!!!

而你现在只需要做的就是在各个页面里面填交互代码就行了!🕶
是不是特别方便快捷!

生成的demo在此

注意 这是个脚手架工具 不是admin template,重点在路由与页面的绑定上,不是样式!!!