This commit is contained in:
AceDataCloud committed 2023-09-25 20:54:31 +08:00
1 parent d206c7df38
commit affd47193c
14 files changed
+73 -160

No files matched your search

+18
View File
@@ -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
View File
@@ -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
View File
@@ -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';