import { Plugin } from '@nuxt/types' const routePlugin: Plugin = (ctx) => { if (ctx.app.router) { ctx.app.router.beforeEach((to, from, next) => { if (ctx.store.state.form.dirty) { ctx.store.commit('form/setShowConfirmToLeave', true) ctx.store.commit('form/setGoAfterLeave', to) } else { next() } }) ctx.app.router.afterEach(() => { }) } } export default routePlugin