首页 > 代码库 > 可以一行指令新建一个新的页面及路由
可以一行指令新建一个新的页面及路由
//新 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"]);})
可以一行指令新建一个新的页面及路由
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。