43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
|
|
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
||
|
|
|
||
|
|
// `/` redirects to `/customers`. Chat timeline params are path segments so the
|
||
|
|
// URL is shareable + survives refresh:
|
||
|
|
// /chat/:channel/:ownerId/:talkerId
|
||
|
|
const routes: RouteRecordRaw[] = [
|
||
|
|
{
|
||
|
|
path: '/',
|
||
|
|
redirect: { name: 'customers' },
|
||
|
|
},
|
||
|
|
{
|
||
|
|
path: '/customers',
|
||
|
|
name: 'customers',
|
||
|
|
component: () => import('@/views/CustomerList.vue'),
|
||
|
|
meta: { title: '客户列表' },
|
||
|
|
},
|
||
|
|
{
|
||
|
|
path: '/chat/:channel/:ownerId/:talkerId',
|
||
|
|
name: 'chat',
|
||
|
|
component: () => import('@/views/ChatTimeline.vue'),
|
||
|
|
props: true,
|
||
|
|
meta: { title: '聊天记录' },
|
||
|
|
},
|
||
|
|
{
|
||
|
|
// 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} · 云客数据镜像` : '云客数据镜像'
|
||
|
|
})
|