Open resources\ts\plugins\1.router\guards.ts You will find the below example code. In the below code, we have shown routes. default is the main layout routing you see after login.
router.beforeEach(to => {/* for page loader (before page load it is show) */constuiStore=useUIStore()uiStore.isLoading =true/* * If it's a public route, continue navigation. This kind of pages are allowed to visited by login & non-login users. Basically, without any restrictions.
* Examples of public routes are, 404, under maintenance, etc. */if (to.meta.public)return/** * Check if user is logged in by checking if token & user data exists in local storage */constisLoggedIn=!!(useCookie('userData').value &&useCookie('accessToken').value)/* If user is logged in and is trying to access login like page, redirect to home else allow visiting the page (Don't allow executing further by return statement because next code will check for permissions) */if (to.meta.unauthenticatedOnly) {if (isLoggedIn)return'/'elsereturnundefined }if (!canNavigate(to) &&to.matched.length) {/* eslint-disable indent */return isLoggedIn? { name:'not-authorized' }: { name:'authentication-auth1-login1', query: {...to.query, to:to.fullPath !=='/'?to.path :undefined, }, }/* eslint-enable indent */ } })