2026-08-01 16:27:22 +08:00
|
|
|
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
2026-09-03 15:03:20 +08:00
|
|
|
import { isLoggedIn } from '@/api/client'
|
2026-08-01 16:27:22 +08:00
|
|
|
|
|
|
|
|
// `/` redirects to `/customers`. Chat timeline params are path segments so the
|
|
|
|
|
// URL is shareable + survives refresh:
|
2026-08-08 15:22:20 +08:00
|
|
|
// /chat/:channel/:ownerId/:talkerId? (1:1 DM; talkerId optional → account-level)
|
|
|
|
|
// /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-11 17:05:01 +08:00
|
|
|
{
|
|
|
|
|
// Standalone 员工详情 page mirroring 云客's
|
|
|
|
|
// /cms/customer/userDetailNew?userId=... — replaces the all-fields drawer
|
|
|
|
|
// degradation for the 员工姓名 click. Row-click in StaffList still opens
|
|
|
|
|
// the drawer for a quick preview.
|
|
|
|
|
path: '/staff-detail/:userId',
|
|
|
|
|
name: 'staff-detail',
|
|
|
|
|
component: () => import('@/views/StaffDetail.vue'),
|
|
|
|
|
props: true,
|
|
|
|
|
meta: { title: '员工详情' },
|
|
|
|
|
},
|
2026-08-01 17:47:50 +08:00
|
|
|
{
|
|
|
|
|
path: '/accounts',
|
2026-08-08 17:16:26 +08:00
|
|
|
redirect: { name: 'staff' },
|
2026-08-01 17:47:50 +08:00
|
|
|
},
|
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-09-04 21:24:32 +08:00
|
|
|
{
|
|
|
|
|
// 数据分析板块(spec 2026-09-04):四页
|
|
|
|
|
path: '/analytics/dashboard',
|
|
|
|
|
name: 'analytics-dashboard',
|
|
|
|
|
component: () => import('@/views/analytics/DashboardView.vue'),
|
|
|
|
|
meta: { title: '数据看板' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/analytics/churn',
|
|
|
|
|
name: 'analytics-churn',
|
|
|
|
|
component: () => import('@/views/analytics/ChurnView.vue'),
|
|
|
|
|
meta: { title: '流失预警' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/analytics/unreplied',
|
|
|
|
|
name: 'analytics-unreplied',
|
|
|
|
|
component: () => import('@/views/analytics/UnrepliedView.vue'),
|
|
|
|
|
meta: { title: '该回未回' },
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/analytics/sensitive',
|
|
|
|
|
name: 'analytics-sensitive',
|
|
|
|
|
component: () => import('@/views/analytics/SensitiveView.vue'),
|
|
|
|
|
meta: { title: '敏感词' },
|
|
|
|
|
},
|
2026-09-10 10:20:13 +08:00
|
|
|
{
|
|
|
|
|
// 经营管理板块(批次C):驾驶舱;员工分析/考核快照批次D/E再加
|
|
|
|
|
path: '/management/dashboard',
|
|
|
|
|
name: 'management-dashboard',
|
|
|
|
|
component: () => import('@/views/management/ManagementDashboardView.vue'),
|
|
|
|
|
meta: { title: '管理驾驶舱' },
|
|
|
|
|
},
|
2026-08-01 16:27:22 +08:00
|
|
|
{
|
2026-08-08 15:22:20 +08:00
|
|
|
path: '/chat/:channel/:ownerId/:talkerId?',
|
2026-08-01 16:27:22 +08:00
|
|
|
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.
|
2026-08-08 15:22:20 +08:00
|
|
|
path: '/group/:channel/:ownerId/:roomId?',
|
2026-08-01 16:38:47 +08:00
|
|
|
name: 'group-chat',
|
|
|
|
|
component: () => import('@/views/ChatTimeline.vue'),
|
|
|
|
|
props: true,
|
|
|
|
|
meta: { title: '群聊记录' },
|
|
|
|
|
},
|
2026-08-25 16:44:47 +08:00
|
|
|
{
|
|
|
|
|
// 员工聊天窗口(对齐云客 wechat-window 五视图): tab=single|group|moments|contacts|stats
|
|
|
|
|
// tab=group 时 talkerId 语义为 roomId; ?msgid= 定位消息(红包转账明细跳转)
|
|
|
|
|
path: '/staff-chat/:ownerId/:tab(single|group|moments|contacts|stats)?/:talkerId?',
|
|
|
|
|
name: 'staff-chat',
|
|
|
|
|
component: () => import('@/views/StaffChat.vue'),
|
|
|
|
|
props: true,
|
|
|
|
|
meta: { title: '员工聊天窗口' },
|
|
|
|
|
},
|
2026-09-08 16:14:44 +08:00
|
|
|
{
|
|
|
|
|
// 员工客户列表(2026-09-08 对齐云客员工详情):员工列表「好友数/微信群数」
|
|
|
|
|
// 账号维度下钻,与全局 /customers 分离; ?name= 直带员工显示名(直链自动解析)
|
|
|
|
|
path: '/staff-friends/:ownerId/:tab(customers|groups)?',
|
|
|
|
|
name: 'staff-friends',
|
|
|
|
|
component: () => import('@/views/StaffFriends.vue'),
|
|
|
|
|
props: true,
|
|
|
|
|
meta: { title: '员工客户列表' },
|
|
|
|
|
},
|
2026-09-03 15:03:20 +08:00
|
|
|
{
|
|
|
|
|
// 登录页(public:未登录可进;守卫据此放行)
|
|
|
|
|
path: '/login',
|
|
|
|
|
name: 'login',
|
|
|
|
|
component: () => import('@/views/LoginView.vue'),
|
|
|
|
|
meta: { title: '登录', public: true },
|
|
|
|
|
},
|
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 }
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
2026-09-03 15:03:20 +08:00
|
|
|
// 登录守卫:非 public 页面未登录一律去 /login,登录后回跳。判定用
|
|
|
|
|
// isLoggedIn(key 存在)而非 token 非空 — 后端鉴权关闭时 token 是空串,
|
|
|
|
|
// 但用户确实登录过,不能把人锁在登录页。
|
|
|
|
|
router.beforeEach((to) => {
|
|
|
|
|
if (to.meta.public) return true
|
|
|
|
|
if (!isLoggedIn()) {
|
|
|
|
|
return { name: 'login', query: { redirect: to.fullPath } }
|
|
|
|
|
}
|
|
|
|
|
return true
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-01 16:27:22 +08:00
|
|
|
router.afterEach((to) => {
|
|
|
|
|
const title = (to.meta.title as string | undefined) ?? ''
|
|
|
|
|
document.title = title ? `${title} · 云客数据镜像` : '云客数据镜像'
|
|
|
|
|
})
|