client initial commit

This commit is contained in:
Methapon2001 2023-11-23 08:47:44 +07:00
parent b5f98baa2b
commit dd1547d7c2
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
70 changed files with 18446 additions and 0 deletions

View file

@ -0,0 +1,55 @@
import { createRouter, createWebHistory } from 'vue-router'
import UserModule from '@/modules/01_user/router'
import AdminModule from '@/modules/02_admin/router'
import KeyCloakService from '@/services/KeyCloakService'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'UserModule',
component: () => import('@/views/MainLayout.vue'),
children: [...UserModule],
meta: {
statusAccount: false,
},
},
{
path: '/admin',
name: 'AdminModule',
component: () => import('@/views/MainLayout.vue'),
beforeEnter: (_to, _from, next) => {
const token = KeyCloakService.GetAccesToken()
if (token) {
next()
} else {
KeyCloakService.CallLogin(() => {
const tokenAfterLogin = KeyCloakService.GetAccesToken()
if (tokenAfterLogin) {
next()
} else {
console.error('ไม่สามารถดึง Token หลังจากล็อกอินได้')
next('/')
}
})
}
},
meta: {
statusAccount: true,
},
children: [...AdminModule],
},
/**
* 404 Not Found
* ref: https://router.vuejs.org/guide/essentials/dynamic-matching.html#catch-all-404-not-found-route
*/
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: () => import('@/views/ErrorNotFoundPage.vue'),
},
],
})
export default router

View file

@ -0,0 +1,12 @@
/**
***** DEPRECATED - Must be delete later *****
*/
/** async/await
* @param view "ชี่อไฟล์".vue
* @param folder "folderในsrc" [Ex. /src/"folder"] default=views
*/
export function load(view: string, folder: string = 'views') {
// console.log(`@/${folder}/${view}.vue`);
return async () => await import(`@/${folder}/${view}.vue`)
}