vue-progressbar icon indicating copy to clipboard operation
vue-progressbar copied to clipboard

Could I use this out of Vue Component?

Open thearabbit opened this issue 7 years ago • 6 comments
trafficstars

I base on Meteor. I check Progressbar on Meteor Startup

import VueProgressBar from 'vue-progressbar'

Meteor.startup(() => {
  // Before each
  router.beforeEach((to, from, next) => {
    VueProgressBar.start()

    if (!to.meta.notRequiresAuth) {
      // Check user
      if (!Meteor.loggingIn() && !Meteor.userId()) {
        next({ path: '/login' })
      } else {
        next()
      }
    } else {
      next()
    }
  })

  // // After each
  router.afterEach((to, from) => {
    VueProgressBar.finish()
  })

  // Start the vue app
  new Vue({
    router,
    store,
    ...AppLayout,
  }).$mount('app')
})

Bc I use check router hook in App Layout don't work

thearabbit avatar Feb 20 '18 02:02 thearabbit

@thearabbit Haven't tested it but you could do something like this:

import VueProgressBar from 'vue-progressbar'
Vue.use(VueProgressBar )

Meteor.startup(() => {
  // Start the vue app
  const app = new Vue({
    store,
    ...AppLayout,
  }).$mount('app')

  // Before each
  app.$router.beforeEach((to, from, next) => {
    app.$Progress.start()

    if (!to.meta.notRequiresAuth) {
      // Check user
      if (!Meteor.loggingIn() && !Meteor.userId()) {
        next({ path: '/login' })
      } else {
        next()
      }
    } else {
      next()
    }
  })

  // // After each
  app.$router.afterEach((to, from) => {
    app.$Progress.finish()
  })
})

malinbranduse avatar Feb 20 '18 13:02 malinbranduse

Thank for your reply, I will try soon

thearabbit avatar Feb 20 '18 15:02 thearabbit

It work for Progressbar, but don't work my Authentication

thearabbit avatar Feb 22 '18 16:02 thearabbit

Have any solve?

thearabbit avatar Mar 12 '18 04:03 thearabbit

Waiting...

thearabbit avatar Mar 23 '18 00:03 thearabbit

Is your authentication a route change within Vue, or do you only initialize Vue itself after the user has logged in?

rijkvanzanten avatar May 10 '18 20:05 rijkvanzanten