make changes in route.js

This commit is contained in:
Mohd Arief
2018-06-22 11:33:07 +08:00
parent 31813d627e
commit 1f757fc7b1
4 changed files with 18 additions and 17 deletions
+3 -5
View File
@@ -3,11 +3,9 @@ import store from '~/store'
export default async (to, from, next) => {
if (!store.getters['auth/check']) {
next({ name: 'login' })
}
else if (store.getters['auth/user'].role == "admin"){
next({ name : 'admin.home' })
}
else {
} else if (store.getters['auth/user'].role === 'admin') {
next({ name: 'home' })
} else {
next()
}
}
+3 -3
View File
@@ -1,12 +1,12 @@
<template>
<card :title="$t('home')">
This is admin
<card>
This is home
</card>
</template>
<script>
export default {
middleware: 'admin',
middleware: ['auth'],
metaInfo () {
return { title: this.$t('home') }
+3 -8
View File
@@ -2,7 +2,7 @@
<div>
<div class="top-right links">
<template v-if="authenticated">
<router-link :to="{ name: 'home' }">
<router-link :to="{ name: 'admin/home' }">
{{ $t('home') }}
</router-link>
</template>
@@ -18,7 +18,7 @@
<div class="text-center">
<div class="title mb-4">
This is admin
This index
</div>
</div>
@@ -32,7 +32,7 @@ export default {
layout: 'basic',
metaInfo () {
return { title: this.$t('home') }
// return { title: this.$t('admin.home') }
},
data: () => ({
@@ -51,8 +51,3 @@ export default {
right: 10px;
top: 18px;
}
.title {
font-size: 85px;
}
</style>
+9 -1
View File
@@ -11,6 +11,8 @@ const Settings = () => import('~/pages/settings/index').then(m => m.default || m
const SettingsProfile = () => import('~/pages/settings/profile').then(m => m.default || m)
const SettingsPassword = () => import('~/pages/settings/password').then(m => m.default || m)
// const Admin = () => import('~/pages/admin/adminhome').then(m => m.default || m)
const Admin = () => import('~/pages/admin/index').then(m => m.default || m)
const AdminHome = () => import('~/pages/admin/home').then(m => m.default || m)
export default [
@@ -31,7 +33,13 @@ export default [
{ path: 'password', name: 'settings.password', component: SettingsPassword }
] },
{ path: '/admin', name: 'admin.home', component: AdminHome },
{ path: '/admin',
component: Admin,
children: [
{ path: '', redirect: { name: 'admin.index' } },
{ path: 'index', name: 'admin.index', component: Admin },
{ path: 'home', name: 'admin.home', component: AdminHome }
] },
{ path: '*', component: NotFound }
]