Skip to content

Commit

Permalink
refactor: better way to extend store with locale properties
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Mar 15, 2021
1 parent e1c319b commit 6fd7343
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/templates/plugin.routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,17 @@ const plugin = {

export default (context) => {
Vue.use(plugin)
const { app, store = {} } = context
app.localePath = store.localePath = NuxtContextProxy(context, localePath)
app.localeRoute = store.localeRoute = NuxtContextProxy(context, localeRoute)
app.switchLocalePath = store.switchLocalePath = NuxtContextProxy(context, switchLocalePath)
app.getRouteBaseName = store.getRouteBaseName = NuxtContextProxy(context, getRouteBaseName)
const { app, store } = context

app.localePath = NuxtContextProxy(context, localePath)
app.localeRoute = NuxtContextProxy(context, localeRoute)
app.switchLocalePath = NuxtContextProxy(context, switchLocalePath)
app.getRouteBaseName = NuxtContextProxy(context, getRouteBaseName)

if (store) {
store.localePath = app.localePath
store.localeRoute = app.localeRoute
store.switchLocalePath = app.switchLocalePath
store.getRouteBaseName = app.getRouteBaseName
}
}

0 comments on commit 6fd7343

Please sign in to comment.