2026-08-01 16:27:22 +08:00
|
|
|
<script setup lang="ts">
|
2026-08-14 18:05:39 +08:00
|
|
|
import { computed } from 'vue'
|
|
|
|
|
import { useRoute } from 'vue-router'
|
2026-08-01 16:27:22 +08:00
|
|
|
import { useChannelStore } from '@/stores/channel'
|
|
|
|
|
import type { Channel } from '@/api/types'
|
|
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const channelStore = useChannelStore()
|
|
|
|
|
|
2026-08-01 16:38:47 +08:00
|
|
|
// `el-menu` with `router` mode emits when an item is clicked; we drive
|
|
|
|
|
// `default-active` from the current path so the active item highlights on load
|
2026-08-14 18:05:39 +08:00
|
|
|
// and on browser back/forward.
|
2026-08-01 16:38:47 +08:00
|
|
|
const activeMenu = computed(() => {
|
|
|
|
|
// Map chat timeline routes back to their entry list so the nav reflects the
|
|
|
|
|
// "owning" section while a conversation is open.
|
|
|
|
|
if (route.name === 'chat') return '/customers'
|
|
|
|
|
if (route.name === 'group-chat') return '/groups'
|
|
|
|
|
return route.path
|
|
|
|
|
})
|
|
|
|
|
|
2026-08-01 16:27:22 +08:00
|
|
|
const channelOptions: { value: Channel | 'all'; label: string }[] = [
|
|
|
|
|
{ value: 'all', label: '全部渠道' },
|
|
|
|
|
{ value: 'wechat', label: '微信' },
|
|
|
|
|
{ value: 'whatsapp', label: 'WhatsApp' },
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
function onChannelChange(value: string | number | boolean | undefined): void {
|
|
|
|
|
channelStore.setChannel(value as Channel | 'all')
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-14 18:05:39 +08:00
|
|
|
// Navigation menu items — vertical sidebar layout
|
|
|
|
|
const navItems = [
|
|
|
|
|
{ path: '/customers', label: '客户', icon: 'ChatLineSquare' },
|
|
|
|
|
{ path: '/staff', label: '员工', icon: 'Avatar' },
|
|
|
|
|
{ path: '/groups', label: '群', icon: 'User' },
|
|
|
|
|
{ path: '/calls', label: '通话', icon: 'Phone' },
|
|
|
|
|
{ path: '/sms', label: '短信', icon: 'Message' },
|
|
|
|
|
{ path: '/sync', label: '同步', icon: 'Refresh' },
|
|
|
|
|
{ path: '/search', label: '搜索', icon: 'Search' },
|
|
|
|
|
]
|
2026-08-01 16:27:22 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<el-container class="yk-app">
|
2026-08-14 18:05:39 +08:00
|
|
|
<!-- Top header: title + channel filter -->
|
2026-08-01 16:27:22 +08:00
|
|
|
<el-header class="yk-header">
|
|
|
|
|
<h1 class="yk-header__title">云客数据镜像</h1>
|
|
|
|
|
<el-radio-group
|
|
|
|
|
:model-value="channelStore.channel"
|
|
|
|
|
size="default"
|
|
|
|
|
@change="onChannelChange"
|
|
|
|
|
>
|
|
|
|
|
<el-radio-button
|
|
|
|
|
v-for="opt in channelOptions"
|
|
|
|
|
:key="opt.value"
|
|
|
|
|
:value="opt.value"
|
|
|
|
|
>
|
|
|
|
|
{{ opt.label }}
|
|
|
|
|
</el-radio-button>
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-header>
|
|
|
|
|
|
|
|
|
|
<el-container>
|
2026-08-14 18:05:39 +08:00
|
|
|
<!-- Left sidebar: vertical nav menu (replaces department tree) -->
|
|
|
|
|
<el-aside class="yk-sidenav" width="200px">
|
|
|
|
|
<el-menu
|
|
|
|
|
:default-active="activeMenu"
|
|
|
|
|
class="yk-sidenav__menu"
|
|
|
|
|
router
|
|
|
|
|
>
|
|
|
|
|
<el-menu-item
|
|
|
|
|
v-for="item in navItems"
|
|
|
|
|
:key="item.path"
|
|
|
|
|
:index="item.path"
|
2026-08-01 16:27:22 +08:00
|
|
|
>
|
2026-08-14 18:05:39 +08:00
|
|
|
<el-icon>
|
|
|
|
|
<component :is="item.icon" />
|
|
|
|
|
</el-icon>
|
|
|
|
|
<span>{{ item.label }}</span>
|
|
|
|
|
</el-menu-item>
|
|
|
|
|
</el-menu>
|
2026-08-01 16:27:22 +08:00
|
|
|
</el-aside>
|
|
|
|
|
|
|
|
|
|
<el-main class="yk-main">
|
|
|
|
|
<router-view />
|
|
|
|
|
</el-main>
|
|
|
|
|
</el-container>
|
|
|
|
|
</el-container>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-08-14 18:05:39 +08:00
|
|
|
.yk-sidenav {
|
|
|
|
|
border-right: 1px solid var(--el-border-color-light, #e4e7ed);
|
|
|
|
|
background: #fff;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.yk-sidenav__menu {
|
|
|
|
|
border-right: none;
|
|
|
|
|
padding-top: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.yk-sidenav__menu :deep(.el-menu-item) {
|
|
|
|
|
height: 48px;
|
|
|
|
|
line-height: 48px;
|
|
|
|
|
margin: 2px 8px;
|
|
|
|
|
border-radius: 6px;
|
2026-08-01 16:27:22 +08:00
|
|
|
}
|
2026-08-01 16:38:47 +08:00
|
|
|
|
2026-08-14 18:05:39 +08:00
|
|
|
.yk-sidenav__menu :deep(.el-menu-item.is-active) {
|
|
|
|
|
background: var(--el-color-primary-light-9, #ecf5ff);
|
2026-08-01 16:38:47 +08:00
|
|
|
}
|
|
|
|
|
|
2026-08-14 18:05:39 +08:00
|
|
|
.yk-sidenav__menu :deep(.el-menu-item:hover) {
|
|
|
|
|
background: var(--el-fill-color-light, #f5f7fa);
|
2026-08-01 16:38:47 +08:00
|
|
|
}
|
2026-08-01 16:27:22 +08:00
|
|
|
</style>
|