You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

23 lines
757 B

const project = 'nervui-smart-parking'; //修改成对象项目 并手动生成routes.json
const gulp = require('gulp');
const replace = require('gulp-replace');
const json = require(`./${project}/routes.json`);
const router = {};
for (let i = 0, j = json.length; i < j; i++) {
router[json[i].path] = json[i].name;
}
function defaultTask() {
return gulp
.src([`${project}/src/view/**/*.vue`])
.pipe(
replace(/route: ('[a-zA-Z\-\/]+')/g, function () {
let key = arguments[1].replace(/'/g, '');
console.log(key, router[key]);
if (router[key]) return `route: { name: '${router[key]}' }`;
return `route: '${key}'`;
}),
)
.pipe(gulp.dest(`${project}/src/view/`));
}
exports.default = defaultTask;