fix
This commit is contained in:
1 parent
d206c7df38
commit
affd47193c
14 files changed
+73
-160
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import { ROUTE_AUTH_CALLBACK, ROUTE_AUTH_LOGIN, ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_INDEX } from './constants';
|
||||
|
||||
export default {
|
||||
path: '/chat',
|
||||
component: () => import('@/layouts/Main.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: ROUTE_CHAT_INDEX,
|
||||
component: () => import('@/pages/chat/Index.vue')
|
||||
},
|
||||
{
|
||||
path: 'conversation/:id',
|
||||
name: ROUTE_CHAT_CONVERSATION,
|
||||
component: () => import('@/pages/chat/Conversation.vue')
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -3,5 +3,8 @@ export const ROUTE_INDEX = 'index';
|
||||
export const ROUTE_AUTH_LOGIN = 'auth-login';
|
||||
export const ROUTE_AUTH_CALLBACK = 'auth-callback';
|
||||
|
||||
export const ROUTE_CHAT_INDEX = 'chat-index';
|
||||
export const ROUTE_CHAT_CONVERSATION = 'chat-conversation';
|
||||
|
||||
export const ROUTE_CONVERSATION_NEW = 'conversation-new';
|
||||
export const ROUTE_CONVERSATION_DETAIL = 'conversation-detail';
|
||||
+2
-17
@@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router';
|
||||
import auth from './auth';
|
||||
import conversation from './conversation';
|
||||
import store from '@/store';
|
||||
import chat from './chat';
|
||||
import { ROUTE_AUTH_LOGIN, ROUTE_CONVERSATION_NEW, ROUTE_INDEX } from './constants';
|
||||
|
||||
const routes = [
|
||||
@@ -12,8 +13,7 @@ const routes = [
|
||||
name: ROUTE_CONVERSATION_NEW
|
||||
}
|
||||
},
|
||||
auth,
|
||||
conversation
|
||||
chat
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
@@ -21,21 +21,6 @@ const router = createRouter({
|
||||
routes
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.matched.some((record) => record.meta.auth)) {
|
||||
if (!store.getters.authenticated) {
|
||||
next({
|
||||
name: ROUTE_AUTH_LOGIN,
|
||||
query: { redirect: to.fullPath }
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
export * from './constants';
|
||||
Reference in new issue
Block a user