route.ts 403 B

123456789101112131415161718
  1. import { Plugin } from '@nuxt/types'
  2. import Form from "~/services/store/form";
  3. const routePlugin: Plugin = (ctx) => {
  4. if (ctx.app.router) {
  5. ctx.app.router.beforeEach((to, from, next) => {
  6. new Form(ctx.store).handleActionsAfterLeavePage(to)
  7. if (!ctx.store.state.form.dirty) {
  8. next()
  9. }
  10. })
  11. ctx.app.router.afterEach(() => {
  12. })
  13. }
  14. }
  15. export default routePlugin