Skip to content

Commit 7c276e9

Browse files
authored
Update routes.js
1 parent 644dd30 commit 7c276e9

File tree

1 file changed

+31
-18
lines changed

1 file changed

+31
-18
lines changed

src/routes.js

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,42 @@ import themeConfig from '<%= options.theme %>'
66
<% } %>
77

88
const 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

1818
let themeOptions = mainConfig
1919
if (typeof themeConfig !== 'undefined') {
20-
themeOptions = _.mergeWith(themeOptions, themeConfig, mergeConfig)
20+
themeOptions = _.mergeWith(themeOptions, themeConfig, mergeConfig)
2121
}
2222
themeOptions = _.mergeWith(themeOptions, userConfig, mergeConfig)
2323

2424
export 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

Comments
 (0)