base struktur update
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled

This commit is contained in:
Wian Drs
2026-07-27 16:25:37 +07:00
parent d5cb197f96
commit 73a32380e7
44 changed files with 5456 additions and 139 deletions
+134 -5
View File
@@ -26,6 +26,9 @@ import { h, resolveComponent } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import DefaultLayout from '@/layouts/DefaultLayout'
import { useAuthStore } from '@/stores/auth'
import { useMenuStore } from '@/stores/menu'
import { hasToken } from '@/utils/session'
/**
* Application routes configuration
@@ -37,6 +40,9 @@ const routes = [
name: 'Home',
component: DefaultLayout,
redirect: '/dashboard',
meta: {
requiresAuth: true,
},
children: [
{
path: '/dashboard',
@@ -47,6 +53,11 @@ const routes = [
component: () =>
import(/* webpackChunkName: "dashboard" */ '@/views/dashboard/Dashboard.vue'),
},
{
path: '/profile',
name: 'Profile',
component: () => import('@/views/profile/Profile.vue'),
},
{
path: '/tickets',
name: 'Tickets',
@@ -64,21 +75,25 @@ const routes = [
},
{
path: '/tickets/ticket-type',
alias: '/ticket-types',
name: 'Ticket Type',
component: () => import('@/views/tickets/TicketType.vue'),
},
{
path: '/tickets/ticket-materials',
alias: '/materials',
name: 'Ticket Materials',
component: () => import('@/views/tickets/TicketMaterials.vue'),
},
{
path: '/tickets/ticket-incident',
alias: '/ticket-incident-types',
name: 'Ticket Incident',
component: () => import('@/views/tickets/TicketIncident.vue'),
},
{
path: '/tickets/approved',
alias: '/tickets/approval',
name: 'Approved',
component: () => import('@/views/tickets/Approved.vue'),
},
@@ -87,11 +102,6 @@ const routes = [
name: 'Rejected',
component: () => import('@/views/tickets/Rejected.vue'),
},
{
path: '/tickets/ticket-incident',
name: 'Ticket Incident',
component: () => import('@/views/tickets/TicketIncident.vue'),
},
],
},
{
@@ -349,6 +359,75 @@ const routes = [
},
],
},
{
path: '/group-menus',
name: 'Group Menus',
component: () => import('@/views/group-menus/GroupMenus.vue'),
},
{
path: '/group-menus/:id/menus',
name: 'Group Menu Permissions',
component: () => import('@/views/group-menus/GroupMenuPermissions.vue'),
meta: { activeMenu: '/group-menus' },
},
{
path: '/nas/mikrotik',
name: 'NAS Mikrotik',
component: () => import('@/views/nas/NasResourceView.vue'),
meta: { nasResource: 'mikrotik' },
},
{
path: '/nas/package-profiles',
name: 'NAS Profile Paket',
component: () => import('@/views/nas/NasResourceView.vue'),
meta: { nasResource: 'package-profile' },
},
{
path: '/nas/olt',
name: 'NAS OLT',
component: () => import('@/views/nas/NasResourceView.vue'),
meta: { nasResource: 'olt' },
},
{
path: '/nas/webfig',
name: 'NAS Webfig',
component: () => import('@/views/nas/NasResourceView.vue'),
meta: { nasResource: 'webfig' },
},
{
path: '/users',
name: 'Users',
component: () => import('@/views/users/Users.vue'),
},
{
path: '/tenants',
name: 'Tenants',
component: () => import('@/views/tenants/Tenants.vue'),
},
{
path: '/wilayah/desa',
name: 'Wilayah Desa',
component: () => import('@/views/wilayah/Wilayah.vue'),
meta: { tingkat: 'desa' },
},
{
path: '/wilayah/kecamatan',
name: 'Wilayah Kecamatan',
component: () => import('@/views/wilayah/Wilayah.vue'),
meta: { tingkat: 'kecamatan' },
},
{
path: '/wilayah/kabupaten',
name: 'Wilayah Kabupaten',
component: () => import('@/views/wilayah/Wilayah.vue'),
meta: { tingkat: 'kabupaten' },
},
{
path: '/wilayah/provinsi',
name: 'Wilayah Provinsi',
component: () => import('@/views/wilayah/Wilayah.vue'),
meta: { tingkat: 'provinsi' },
},
{
path: '/widgets',
name: 'Widgets',
@@ -380,11 +459,25 @@ const routes = [
path: 'login',
name: 'Login',
component: () => import('@/views/pages/Login'),
meta: {
guestOnly: true,
},
},
{
path: 'register',
name: 'Register',
component: () => import('@/views/pages/Register'),
meta: {
guestOnly: true,
},
},
{
path: 'verify-code',
name: 'VerifyCode',
component: () => import('@/views/pages/VerifyCode'),
meta: {
guestOnly: true,
},
},
],
},
@@ -399,4 +492,40 @@ const router = createRouter({
},
})
router.beforeEach(async (to) => {
const requiresAuth = to.matched.some((record) => record.meta.requiresAuth)
const guestOnly = to.matched.some((record) => record.meta.guestOnly)
const authenticated = hasToken()
if (requiresAuth && !authenticated) {
return {
name: 'Login',
query: {
redirect: to.fullPath,
},
}
}
if (guestOnly && authenticated) {
return { name: 'Dashboard' }
}
if (requiresAuth) {
try {
await useMenuStore().fetchMenus()
} catch {
useAuthStore().logout()
return {
name: 'Login',
query: {
redirect: to.fullPath,
},
}
}
}
return true
})
export default router