2026-08-01 16:27:22 +08:00
|
|
|
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
|
|
|
|
|
|
|
|
|
// `/` redirects to `/customers`. Chat timeline params are path segments so the
|
|
|
|
|
// URL is shareable + survives refresh:
|
2026-08-01 16:38:47 +08:00
|
|
|
// /chat/:channel/:ownerId/:talkerId (1:1 DM)
|
|
|
|
|
// /group/:channel/:ownerId/:roomId (group chat — same component, room_id)
|
2026-08-01 16:27:22 +08:00
|
|
|
const routes: RouteRecordRaw[] = [
|
|
|
|
|
{
|
|
|
|
|
path: '/',
|
|
|
|
|
redirect: { name: 'customers' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/customers',
|
|
|
|
|
name: 'customers',
|
|
|
|
|
component: () => import('@/views/CustomerList.vue'),
|
|
|
|
|
meta: { title: '客户列表' },
|
|
|
|
|
},
|
2026-08-01 17:11:17 +08:00
|
|
|
{
|
|
|
|
|
path: '/staff',
|
|
|
|
|
name: 'staff',
|
|
|
|
|
component: () => import('@/views/StaffList.vue'),
|
|
|
|
|
meta: { title: '员工列表' },
|
|
|
|
|
},
|
2026-08-01 17:47:50 +08:00
|
|
|
{
|
|
|
|
|
path: '/accounts',
|
|
|
|
|
name: 'accounts',
|
|
|
|
|
component: () => import('@/views/AccountList.vue'),
|
|
|
|
|
meta: { title: '账号列表' },
|
|
|
|
|
},
|
2026-08-01 16:38:47 +08:00
|
|
|
{
|
|
|
|
|
path: '/groups',
|
|
|
|
|
name: 'groups',
|
|
|
|
|
component: () => import('@/views/GroupList.vue'),
|
|
|
|
|
meta: { title: '群列表' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/calls',
|
|
|
|
|
name: 'calls',
|
|
|
|
|
component: () => import('@/views/CallList.vue'),
|
|
|
|
|
meta: { title: '通话记录' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/sms',
|
|
|
|
|
name: 'sms',
|
|
|
|
|
component: () => import('@/views/SmsList.vue'),
|
|
|
|
|
meta: { title: '短信记录' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/sync',
|
|
|
|
|
name: 'sync',
|
|
|
|
|
component: () => import('@/views/SyncStatus.vue'),
|
|
|
|
|
meta: { title: '同步状态' },
|
|
|
|
|
},
|
2026-08-05 11:46:21 +08:00
|
|
|
{
|
|
|
|
|
path: '/search',
|
|
|
|
|
name: 'search',
|
|
|
|
|
component: () => import('@/views/SearchView.vue'),
|
|
|
|
|
meta: { title: '搜索' },
|
|
|
|
|
},
|
2026-08-01 16:27:22 +08:00
|
|
|
{
|
|
|
|
|
path: '/chat/:channel/:ownerId/:talkerId',
|
|
|
|
|
name: 'chat',
|
|
|
|
|
component: () => import('@/views/ChatTimeline.vue'),
|
|
|
|
|
props: true,
|
|
|
|
|
meta: { title: '聊天记录' },
|
|
|
|
|
},
|
2026-08-01 16:38:47 +08:00
|
|
|
{
|
|
|
|
|
// Group chat timeline — same component, but with a `roomId` prop so it
|
|
|
|
|
// issues a room_id query instead of a talker_id query.
|
|
|
|
|
path: '/group/:channel/:ownerId/:roomId',
|
|
|
|
|
name: 'group-chat',
|
|
|
|
|
component: () => import('@/views/ChatTimeline.vue'),
|
|
|
|
|
props: true,
|
|
|
|
|
meta: { title: '群聊记录' },
|
|
|
|
|
},
|
2026-08-01 16:27:22 +08:00
|
|
|
{
|
|
|
|
|
// Anything else → back to the list.
|
|
|
|
|
path: '/:pathMatch(.*)*',
|
|
|
|
|
redirect: { name: 'customers' },
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
export const router = createRouter({
|
|
|
|
|
history: createWebHistory(),
|
|
|
|
|
routes,
|
|
|
|
|
scrollBehavior() {
|
|
|
|
|
return { top: 0 }
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
router.afterEach((to) => {
|
|
|
|
|
const title = (to.meta.title as string | undefined) ?? ''
|
|
|
|
|
document.title = title ? `${title} · 云客数据镜像` : '云客数据镜像'
|
|
|
|
|
})
|