Init project
This commit is contained in:
+136
@@ -0,0 +1,136 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
import 'firebase/auth'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
const router = new Router({
|
||||
mode: 'history',
|
||||
base: process.env.BASE_URL,
|
||||
scrollBehavior() {
|
||||
return {x: 0, y: 0}
|
||||
},
|
||||
routes: [
|
||||
{
|
||||
path: '/auth',
|
||||
component: () => import('@/layouts/full-page/FullPage.vue'),
|
||||
|
||||
children: [
|
||||
{
|
||||
path: '/auth/login',
|
||||
name: 'auth-login',
|
||||
component: () => import('./views/auth/Login.vue'),
|
||||
meta: {
|
||||
rule: 'editor'
|
||||
}
|
||||
},
|
||||
// {
|
||||
// path: '/auth/register',
|
||||
// name: 'auth-register',
|
||||
// component: () => import('@/views/auth/Register.vue'),
|
||||
// meta: {
|
||||
// rule: 'editor'
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// path: '/auth/forgot-password',
|
||||
// name: 'auth-forget',
|
||||
// component: () => import('@/views/auth/ForgotPassword.vue'),
|
||||
// meta: {
|
||||
// rule: 'editor'
|
||||
// }
|
||||
// },
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
component: () => import('./layouts/main/Main.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'dashboard',
|
||||
redirect: '/dashboard'
|
||||
},
|
||||
{
|
||||
path: '/dashboard',
|
||||
name: 'dashborrdPage',
|
||||
component: () => import('./views/DashboardAnalytics.vue'),
|
||||
meta: {
|
||||
rule: 'editor'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/config',
|
||||
name: 'config',
|
||||
component: () => import('./views/config/Config.vue'),
|
||||
meta: {
|
||||
rule: 'editor',
|
||||
parent: 'main'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/proposal',
|
||||
name: 'proposal',
|
||||
component: () => import('./views/proposal/Proposal.vue'),
|
||||
meta: {
|
||||
rule: 'editor',
|
||||
parent: 'main'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/personel',
|
||||
name: 'personel',
|
||||
component: () => import('./views/personel/Personel.vue'),
|
||||
meta: {
|
||||
rule: 'editor',
|
||||
parent: 'main'
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '*',
|
||||
redirect: '/pages/error-404'
|
||||
}
|
||||
],
|
||||
})
|
||||
|
||||
router.afterEach(() => {
|
||||
const appLoading = document.getElementById('loading-bg')
|
||||
if (appLoading) {
|
||||
appLoading.style.display = "none";
|
||||
}
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
let isLogin = localStorage.getItem('accessToken');
|
||||
console.log("to.path ==> ", to.path);
|
||||
if (
|
||||
(
|
||||
to.path === "/auth/login" ||
|
||||
to.path === "/auth/register" ||
|
||||
to.path === "/pages/error-404" ||
|
||||
to.path === "/auth/forgot-password"
|
||||
)
|
||||
) {
|
||||
if (isLogin) {
|
||||
router.push({path: '/'});
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
||||
if (!isLogin) {
|
||||
router.push({path: '/auth/login'});
|
||||
return;
|
||||
} else {
|
||||
return next();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default router
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user