首页 > 代码库 > 可以一行指令新建一个新的页面及路由

可以一行指令新建一个新的页面及路由

//新 viewgulp.task("new_view",function(name,distName){  return gulp.src(‘templates/page.handlebars‘)//取源文件    .pipe(template({name: name?name:"new"}))//name参数是否有值    .pipe(rename({      basename:name    }))    .pipe(gulp.dest(‘jade/views‘));//在views文件夹输出})//新 servicegulp.task("new_service ",function(name,distName ){  return gulp.src(‘templates/service .js‘)    .pipe(template({name: distName ?distName :"new"}))    .pipe(rename({      basename:name    }))    .pipe(gulp.dest(‘js/‘+distName+‘/‘));//在distName 文件夹输出})//新 controllergulp.task("new_controller ",function(name,distName ){  return gulp.src(‘templates/controller .js‘)    .pipe(template({name: name?name:"new"}))    .pipe(rename({      basename:name    }))    .pipe(gulp.dest(‘js/‘+distName+‘/‘));//在distName 文件夹输出})//gulp.task("new_less",function(name){ // return gulp.src(‘templates/style.less‘) //   .pipe(template({name: name?name:"new"})) //   .pipe(rename({ //     basename:name //   }))//    .pipe(gulp.dest(‘src/less‘));//})gulp.task("inject_routes",function(name){  return gulp.src("js/common/routes.config.js")  .pipe(replace("//more", ‘ .state(getState(),{\nurl:,\ntitle:,\ntemplateUrl:helper.basepath(),\nresolve: helper.resolveFor( ),\nconf : { login : true, level : [1, 2, 3]},})\n //more‘)) // .pipe(replace("//newRouter", ‘//newRouter\napp.use("/‘+name+‘", router_‘+name+‘);‘))  .pipe(gulp.dest("js/common/routes.config.js "))})gulp.task(‘new‘,function (name,controller,distName) {  if(router) //   return runsequence([‘new_view‘,"new_less","new_router","inject_app"]);    return runsequence([‘new_view‘,"new_controller ","inject_routes "]);  else    return runsequence([‘new_view‘]);//   return runsequence([‘new_view‘,"new_less"]);})

  

可以一行指令新建一个新的页面及路由