12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- const config = require('./config.json')
- module.exports = function (plop) {
- plop.setGenerator('controller', {
- description: '生成新页面',
- prompts: [
- {
- type: 'input',
- name: 'path',
- message: '请输入页面路径',
- },
- {
- type: 'input',
- name: 'title',
- message: '请输入页面标题',
- default: config.VITE_APP_TITLE,
- },
- ],
- actions: [
- {
- type: 'add',
- path: 'page/{{path}}.html',
- templateFile: 'plop-template/index.html.hbs',
- },
- {
- type: 'add',
- path: 'page/{{path}}.js',
- templateFile: 'plop-template/index.js.hbs',
- },
- {
- type: 'add',
- path: 'src/views/{{path}}/index.vue',
- templateFile: 'plop-template/index.vue.hbs',
- },
- {
- type: 'append',
- path: 'index.html',
- pattern: '<body>',
- template: "<a target='_blank' href='page/{{path}}.html'>{{path}}</a>",
- },
- ],
- })
- }
|