@@ -6,29 +6,42 @@ import themeConfig from '<%= options.theme %>'
66< % } % >
77
88const mergeConfig = ( objValue , srcValue ) => {
9- if ( _ . isArray ( objValue ) ) {
10- return objValue . concat ( srcValue )
11- } else if ( _ . isObject ( objValue ) ) {
12- return _ . merge ( objValue , srcValue )
13- } else {
14- return srcValue
15- }
9+ if ( _ . isArray ( objValue ) ) {
10+ return objValue . concat ( srcValue )
11+ } else if ( _ . isObject ( objValue ) ) {
12+ return _ . merge ( objValue , srcValue )
13+ } else {
14+ return srcValue
15+ }
1616}
1717
1818let themeOptions = mainConfig
1919if ( typeof themeConfig !== 'undefined' ) {
20- themeOptions = _ . mergeWith ( themeOptions , themeConfig , mergeConfig )
20+ themeOptions = _ . mergeWith ( themeOptions , themeConfig , mergeConfig )
2121}
2222themeOptions = _ . mergeWith ( themeOptions , userConfig , mergeConfig )
2323
2424export const getRoutes = ( ) => {
25- return [ < % for ( var i = 0 ; i < options . routes . length ; i ++ ) { % >
26- {
27- name : '<%= options.routes[i].name %>' ,
28- path : '<%= options.routes[i].path %>' , < % if ( typeof options . routes [ i ] . props ! == 'undefined' ) { % >
29- props : < %= JSON . stringify ( options . routes [ i ] . props ) % > , < % } % >
30- component: () =>
31- < %= 'themeOptions.pages.' + options . routes [ i ] . component % >
32- } , < % } % >
33- ]
34- }
25+ return [ < % for ( var i = 0 ; i < options . routes . length ; i ++ ) { % > {
26+ name : '<%= options.routes[i].name %>' ,
27+ path : '<%= options.routes[i].path %>' ,
28+ < % if ( typeof options . routes [ i ] . props ! == 'undefined' ) { % >
29+ props : < %= JSON . stringify ( options . routes [ i ] . props ) % > ,
30+ < % } % >
31+ component: () => {
32+ < %= 'themeOptions.pages.' + options . routes [ i ] . component % > . created = function ( ) {
33+ if ( typeof this . loaded !== 'undefined' ) {
34+ this . $store . dispatch ( 'common/breadcrumbs/init' ) ;
35+ this . $watch ( 'loaded' , ( ) => {
36+ this . $store . dispatch ( 'common/breadcrumbs/load' ) ;
37+ } )
38+ } else {
39+ this . $store . dispatch ( 'common/breadcrumbs/load' ) ;
40+
41+ }
42+ }
43+ return < %= 'themeOptions.pages.' + options . routes [ i ] . component % >
44+ }
45+
46+ } , < % } % > ]
47+ }
0 commit comments