Skip to content

Commit 78bf55c

Browse files
committed
Improve the VueCrudGenerator
1 parent cec2438 commit 78bf55c

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/generators/VueCrudGenerator.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ export default class VueCrudGenerator {
2424
this.registerTemplate(templatePath, 'api/fooFetch.js');
2525

2626
// components
27-
this.registerTemplate(templatePath, 'components/foo/Create.js');
28-
this.registerTemplate(templatePath, 'components/foo/Form.js');
29-
this.registerTemplate(templatePath, 'components/foo/index.js');
30-
this.registerTemplate(templatePath, 'components/foo/List.js');
31-
this.registerTemplate(templatePath, 'components/foo/Update.js');
32-
this.registerTemplate(templatePath, 'components/foo/Show.js');
27+
this.registerTemplate(templatePath, 'components/foo/Create.vue');
28+
this.registerTemplate(templatePath, 'components/foo/Form.vue');
29+
this.registerTemplate(templatePath, 'components/foo/List.vue');
30+
this.registerTemplate(templatePath, 'components/foo/Update.vue');
31+
this.registerTemplate(templatePath, 'components/foo/Show.vue');
3332

3433
// routes
3534
this.registerTemplate(templatePath, 'routes/foo.js');
@@ -55,18 +54,23 @@ export default class VueCrudGenerator {
5554
import ${titleLc}Routes from './routes/${titleLc}';
5655
5756
// Add the modules in the store
58-
import foo from './store/modules/foo';
57+
import { ${titleLc} from './store/modules/{ ${titleLc}/';
5958
6059
export const store = new Vuex.Store({
6160
// ...
6261
modules: {
63-
foo
62+
{ ${titleLc}
6463
}
6564
});
6665
6766
68-
// Add routes to <Switch>
69-
{ ${titleLc}Routes }
67+
// Add routes to VueRouter
68+
const router = new VueRouter({
69+
// ...
70+
routes: [
71+
...{ ${titleLc}Routes },
72+
]
73+
});
7074
`));
7175
}
7276

@@ -107,12 +111,11 @@ export const store = new Vuex.Store({
107111
this.createFile('api/fooFetch.js', `${dir}/api/${lc}Fetch.js`, context);
108112

109113
// components
110-
this.createFile('components/foo/Create.js', `${dir}/components/${lc}/Create.js`, context);
111-
this.createFile('components/foo/Form.js', `${dir}/components/${lc}/Form.js`, context);
112-
this.createFile('components/foo/index.js', `${dir}/components/${lc}/index.js`, context);
113-
this.createFile('components/foo/List.js', `${dir}/components/${lc}/List.js`, context);
114-
this.createFile('components/foo/Update.js', `${dir}/components/${lc}/Update.js`, context);
115-
this.createFile('components/foo/Show.js', `${dir}/components/${lc}/Show.js`, context);
114+
this.createFile('components/foo/Create.vue', `${dir}/components/${lc}/Create.vue`, context);
115+
this.createFile('components/foo/Form.vue', `${dir}/components/${lc}/Form.vue`, context);
116+
this.createFile('components/foo/List.vue', `${dir}/components/${lc}/List.vue`, context);
117+
this.createFile('components/foo/Update.vue', `${dir}/components/${lc}/Update.vue`, context);
118+
this.createFile('components/foo/Show.vue', `${dir}/components/${lc}/Show.vue`, context);
116119

117120
// routes
118121
this.createFile('routes/foo.js', `${dir}/routes/${lc}.js`, context)

0 commit comments

Comments
 (0)