mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 02:50:39 +00:00
vue router implemented
This commit is contained in:
Vendored
+58
-7
@@ -1,10 +1,14 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
import store from '@/store'
|
||||
|
||||
import Index from './views/Index'
|
||||
import SignUp from './views/SignUp'
|
||||
import ForgottenPassword from './views/ForgottenPassword'
|
||||
//import ForgottenPassword from './views/ForgottenPassword'
|
||||
import Index from './views/Auth/SignIn'
|
||||
import SignUp from './views/Auth/SignUp'
|
||||
import ForgottenPassword from './views/Auth/ForgottenPassword'
|
||||
import CreateNewPassword from './views/Auth/CreateNewPassword'
|
||||
|
||||
import Files from './views/Files'
|
||||
import Profile from './views/Profile'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
@@ -12,25 +16,53 @@ const router = new Router({
|
||||
mode: 'history',
|
||||
routes: [
|
||||
{
|
||||
name: 'index',
|
||||
name: 'SignIn',
|
||||
path: '/',
|
||||
component: Index,
|
||||
meta: {
|
||||
requiresAuth: false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'SignUp',
|
||||
path: '/sign-up',
|
||||
component: SignUp,
|
||||
meta: {
|
||||
requiresAuth: false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'ForgottenPassword',
|
||||
path: '/forgotten-password',
|
||||
component: ForgottenPassword,
|
||||
meta: {
|
||||
requiresAuth: false
|
||||
},
|
||||
},
|
||||
/*{
|
||||
{
|
||||
name: 'CreateNewPassword',
|
||||
path: '/create-new-password',
|
||||
component: CreateNewPassword,
|
||||
},*/
|
||||
meta: {
|
||||
requiresAuth: false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Files',
|
||||
path: '/files',
|
||||
component: Files,
|
||||
meta: {
|
||||
requiresAuth: true
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Profile',
|
||||
path: '/profile',
|
||||
component: Profile,
|
||||
meta: {
|
||||
requiresAuth: true
|
||||
},
|
||||
},
|
||||
],
|
||||
scrollBehavior(to, from, savedPosition) {
|
||||
|
||||
@@ -39,6 +71,25 @@ const router = new Router({
|
||||
} else {
|
||||
return {x: 0, y: 0}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
|
||||
if (to.matched.some(record => record.meta.requiresAuth)) {
|
||||
// this route requires auth, check if logged in
|
||||
// if not, redirect to login page.
|
||||
|
||||
if ( ! store.getters.isLogged || ! config.hasAuthCookie) {
|
||||
next({
|
||||
name: 'SignIn',
|
||||
query: { redirect: to.fullPath }
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
} else {
|
||||
next() // make sure to always call next()!
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user