tab ที่ผ่านมาแล้วเปลี่ยนเป็นสีเขียว

This commit is contained in:
Kittapath 2023-03-17 17:42:45 +07:00
parent 8266e11d11
commit 3f4a0704d3
16 changed files with 407 additions and 166 deletions

View file

@ -3,31 +3,32 @@ import HomeView from '../views/HomeView.vue'
import Exam from '@/modules/01_exam/router'
import Meta02 from '@/modules/02_meta/router'
import keycloak from "@/plugins/keycloak";
import keycloak from '@/plugins/keycloak'
const MainLayout = () => import('@/views/MainLayout.vue')
const Error404NotFound = () => import('@/views/Error404NotFound.vue')
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
path: '/exam/:id',
// name: 'home',
component: MainLayout,
children: [
{
path: '/',
name: 'dashboard',
component: HomeView,
meta: {
Auth: true,
Key: [7]
}
},
...Exam,
...Meta02
// {
// path: '/',
// name: 'dashboard',
// component: HomeView,
// meta: {
// Auth: true,
// Key: [7]
// }
// },
...Exam
// ...Meta02
]
}
},
/**
* 404 Not Found
* ref: https://router.vuejs.org/guide/essentials/dynamic-matching.html#catch-all-404-not-found-route
@ -37,6 +38,11 @@ const router = createRouter({
// path: "/:pathMatch(.*)*",
// component: Error404NotFound,
// },
{
// path: "/:catchAll(.*)*", // TODO: ใช้ pathMatch แทนตามในเอกสารแนะนำ คงไว้เผื่อจำเป็น
path: '/:pathMatch(.*)*',
component: Error404NotFound
}
]
})
@ -59,20 +65,20 @@ const router = createRouter({
// ]
// })
router.beforeEach((to, from, next) => {
if (to.meta.Auth) {
if (!keycloak.authenticated) {
keycloak.login({
redirectUri: `${window.location.protocol}//${window.location.host}${to.path}`,
locale: "th",
});
} else {
// keycloak.updateToken(60);
next();
}
if (to.meta.Auth) {
if (!keycloak.authenticated) {
keycloak.login({
redirectUri: `${window.location.protocol}//${window.location.host}${to.path}`,
locale: 'th'
})
} else {
next();
// keycloak.updateToken(60);
next()
}
// next();
});
} else {
next()
}
// next();
})
export default router