File tree Expand file tree Collapse file tree 4 files changed +31
-3
lines changed Expand file tree Collapse file tree 4 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 1
1
/generator /template
2
+ /generator /template-vue3
2
3
node_modules
Original file line number Diff line number Diff line change 1
- module . exports = ( api ) => {
1
+ /* eslint-disable-next-line no-unused-vars */
2
+ module . exports = ( api , _options = { } , rootOptions = { } ) => {
3
+ const isVue3 = rootOptions . vueVersion === '3'
4
+
2
5
api . extendPackage ( {
3
6
dependencies : {
4
- 'vue-router-layout' : '^0.2.0' ,
7
+ 'vue-router-layout' : isVue3 ? '^0.2.0' : '^0.1.2 ',
5
8
} ,
6
9
devDependencies : {
7
10
'vue-auto-routing' : '^1.0.0' ,
@@ -17,6 +20,10 @@ module.exports = (api) => {
17
20
18
21
api . render ( './template' )
19
22
23
+ if ( isVue3 ) {
24
+ api . render ( './template-vue3' )
25
+ }
26
+
20
27
if ( api . invoking ) {
21
28
api . postProcessFiles ( ( files ) => {
22
29
Object . keys ( files ) . forEach ( ( name ) => {
Original file line number Diff line number Diff line change
1
+ import { createRouter , createWebHistory } from 'vue-router'
2
+ import routes from 'vue-auto-routing'
3
+ import { createRouterLayout } from 'vue-router-layout'
4
+
5
+ const RouterLayout = createRouterLayout ( layout => {
6
+ return import ( '@/layouts/' + layout + '.vue' )
7
+ } )
8
+
9
+ const router = createRouter ( {
10
+ history : createWebHistory ( process . env . BASE_URL ) ,
11
+ routes : [
12
+ {
13
+ path : '/' ,
14
+ component : RouterLayout ,
15
+ children : routes
16
+ }
17
+ ]
18
+ } )
19
+
20
+ export default router
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const RouterLayout = createRouterLayout(layout => {
10
10
} )
11
11
12
12
export default new Router ( {
13
- mode : " history" ,
13
+ mode : ' history' ,
14
14
base : process . env . BASE_URL ,
15
15
routes : [
16
16
{
You can’t perform that action at this time.
0 commit comments