|
|
@@ -2,196 +2,292 @@ import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
|
|
|
import { useAppStore } from '@/stores/index';
|
|
|
import appSetting from '@/app-setting';
|
|
|
|
|
|
-/*import HomeView from '../views/index.vue';*/
|
|
|
- import HomeView from '../views/auth/boxed-signin.vue';
|
|
|
+import HomeView from '../views/index.vue';
|
|
|
+/*import HomeView from '../views/auth/boxed-signin.vue';*/
|
|
|
|
|
|
const routes: RouteRecordRaw[] = [
|
|
|
// dashboard
|
|
|
- { path: '/', name: 'home', component: HomeView },
|
|
|
+ { path: '/', name: 'home', component: HomeView ,meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },},
|
|
|
+ {
|
|
|
+ path: '/dashboard',
|
|
|
+ name: 'dashboard',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
+ component: () => import(/* webpackChunkName: "apps-scrumboard" */ '../views/apps/scrumboard.vue'),
|
|
|
+ },
|
|
|
{
|
|
|
path: '/apps/scrumboard',
|
|
|
name: 'scrumboard',
|
|
|
component: () => import(/* webpackChunkName: "apps-scrumboard" */ '../views/apps/scrumboard.vue'),
|
|
|
},
|
|
|
-
|
|
|
+ {
|
|
|
+ path: '/login',
|
|
|
+ name: 'login',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: false
|
|
|
+ },
|
|
|
+ component: () => import(/* webpackChunkName: "apps-scrumboard" */ '../views/auth/boxed-signin.vue'),
|
|
|
+ },
|
|
|
|
|
|
// apps
|
|
|
{
|
|
|
path: '/apps/applist',
|
|
|
name: 'applist',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "apps-chat" */ '../views/apps/applist.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/apps/custom',
|
|
|
name: 'custom',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "apps-chat" */ '../views/apps/custom.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/apps/stock',
|
|
|
name: 'stock',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "apps-chat" */ '../views/apps/stock.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/apps/order',
|
|
|
name: 'order',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "apps-chat" */ '../views/apps/order.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/apps/goods',
|
|
|
name: 'goods',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "apps-chat" */ '../views/apps/goods.vue'),
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
|
|
|
//user
|
|
|
{
|
|
|
path: '/users/contacts',
|
|
|
name: 'contacts',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "apps-contacts" */ '../views/users/contacts.vue'),
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
{
|
|
|
- path: '/users/profile',
|
|
|
- name: 'profile',
|
|
|
- component: () => import(/* webpackChunkName: "users-profile" */ '../views/users/profile.vue'),
|
|
|
+ path: '/users/profile',
|
|
|
+ name: 'profile',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
+ component: () => import(/* webpackChunkName: "users-profile" */ '../views/users/profile.vue'),
|
|
|
},
|
|
|
|
|
|
{
|
|
|
path: '/users/user-account-settings',
|
|
|
name: 'user-account-settings',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "users-profile" */ '../views/users/user-account-settings.vue'),
|
|
|
},
|
|
|
// components
|
|
|
{
|
|
|
path: '/components/tabs',
|
|
|
name: 'tabs',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-tabs" */ '../views/components/tabs.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/accordions',
|
|
|
name: 'accordions',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-accordions" */ '../views/components/accordions.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/modals',
|
|
|
name: 'modals',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-modals" */ '../views/components/modals.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/cards',
|
|
|
name: 'cards',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-cards" */ '../views/components/cards.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/carousel',
|
|
|
name: 'carousel',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-carousel" */ '../views/components/carousel.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/countdown',
|
|
|
name: 'countdown',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-countdown" */ '../views/components/countdown.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/counter',
|
|
|
name: 'counter',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-counter" */ '../views/components/counter.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/sweetalert',
|
|
|
name: 'sweetalert',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-sweetalert" */ '../views/components/sweetalert.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/timeline',
|
|
|
name: 'timeline',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-timeline" */ '../views/components/timeline.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/notifications',
|
|
|
name: 'notifications',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-notifications" */ '../views/components/notifications.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/media-object',
|
|
|
name: 'media-object',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-media-object" */ '../views/components/media-object.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/list-group',
|
|
|
name: 'list-group',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-list-group" */ '../views/components/list-group.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/pricing-table',
|
|
|
name: 'pricing-table',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-pricing-table" */ '../views/components/pricing-table.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/components/lightbox',
|
|
|
name: 'lightbox',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "components-lightbox" */ '../views/components/lightbox.vue'),
|
|
|
},
|
|
|
|
|
|
-
|
|
|
+
|
|
|
//charts
|
|
|
{
|
|
|
path: '/charts',
|
|
|
name: 'charts',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "charts" */ '../views/charts.vue'),
|
|
|
},
|
|
|
|
|
|
-
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
//auth
|
|
|
{
|
|
|
path: '/auth/cover-login',
|
|
|
name: 'cover-login',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "forms-clipboard" */ '../views/auth/cover-login.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/auth/boxed-password-reset',
|
|
|
name: 'boxed-password-reset',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "forms-clipboard" */ '../views/auth/boxed-password-reset.vue'),
|
|
|
},
|
|
|
{
|
|
|
path: '/auth/boxed-signin',
|
|
|
name: 'boxed-signin',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "forms-clipboard" */ '../views/auth/boxed-signin.vue'),
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
{
|
|
|
path: '/auth/cover-password-reset',
|
|
|
name: 'cover-password-reset',
|
|
|
+ meta: {
|
|
|
+ requiresAuth: true
|
|
|
+ },
|
|
|
component: () => import(/* webpackChunkName: "forms-clipboard" */ '../views/auth/cover-password-reset.vue'),
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
];
|
|
|
|
|
|
const router = createRouter({
|
|
|
history: createWebHistory(),
|
|
|
- linkExactActiveClass: 'active',
|
|
|
+ //linkExactActiveClass: 'active',
|
|
|
routes,
|
|
|
- scrollBehavior(to, from, savedPosition) {
|
|
|
+ /* scrollBehavior(to, from, savedPosition) {
|
|
|
if (savedPosition) {
|
|
|
return savedPosition;
|
|
|
} else {
|
|
|
return { left: 0, top: 0 };
|
|
|
}
|
|
|
- },
|
|
|
+ }, */
|
|
|
});
|
|
|
-
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
const store = useAppStore();
|
|
|
-
|
|
|
- if (to?.meta?.layout == 'auth') {
|
|
|
- store.setMainLayout('auth');
|
|
|
+ console.log(to.meta.requiresAuth && !store.user);
|
|
|
+ if (to.meta.requiresAuth && !store.user) {
|
|
|
+ next({ name: 'login'});
|
|
|
} else {
|
|
|
- store.setMainLayout('app');
|
|
|
+ next();
|
|
|
}
|
|
|
- next(true);
|
|
|
});
|
|
|
router.afterEach((to, from, next) => {
|
|
|
appSetting.changeAnimation();
|