feat(ui): 左侧菜单改分组式(微信管理/WhatsApp管理+下拉子菜单,对齐云客布局)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
浅念
2026-08-15 12:09:55 +08:00
parent 02f95af279
commit 9b21584e9a
5 changed files with 130 additions and 43 deletions
+105 -32
View File
@@ -1,55 +1,96 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed } from 'vue' import { computed } from 'vue'
import { useRoute } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { useChannelStore } from '@/stores/channel'
import type { Channel } from '@/api/types'
const route = useRoute() const route = useRoute()
const router = useRouter()
const channelStore = useChannelStore()
// `el-menu` with `router` mode emits when an item is clicked; we drive // `el-menu` with `router` mode; we drive `default-active` from the current path
// `default-active` from the current path so the active item highlights on load // so the active item highlights on load and on browser back/forward.
// and on browser back/forward.
const activeMenu = computed(() => { 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 === 'chat') return '/customers'
if (route.name === 'group-chat') return '/groups' if (route.name === 'group-chat') return '/groups'
return route.path return route.path
}) })
// Navigation menu items — vertical sidebar layout. // Expand the sub-menu matching the current channel
// Channel filtering is handled by each page's own tabs (微信/WhatsApp). const activeChannel = computed(() => {
const navItems = [ const ch = route.query.channel as string | undefined
{ path: '/customers', label: '客户', icon: 'ChatLineSquare' }, if (ch === 'whatsapp') return 'wa'
{ path: '/staff', label: '员工', icon: 'Avatar' }, return 'wx'
{ path: '/groups', label: '群', icon: 'User' }, })
{ path: '/calls', label: '通话', icon: 'Phone' },
{ path: '/sms', label: '短信', icon: 'Message' }, /** Navigate to a page with the channel preset (page reads ?channel= to set tab). */
{ path: '/sync', label: '同步', icon: 'Refresh' }, function go(path: string, channel: Channel): void {
{ path: '/search', label: '搜索', icon: 'Search' }, channelStore.setChannel(channel)
] router.push({ path, query: { channel } })
}
function goPlain(path: string): void {
router.push(path)
}
</script> </script>
<template> <template>
<el-container class="yk-app"> <el-container class="yk-app">
<el-container> <el-container>
<!-- Left sidebar: vertical nav menu --> <!-- Left sidebar: vertical nav menu with grouped sub-menus (mirrors 云客) -->
<el-aside class="yk-sidenav" width="200px"> <el-aside class="yk-sidenav" width="210px">
<div class="yk-sidenav__header"> <div class="yk-sidenav__header">
<h2 class="yk-sidenav__title">云客数据镜像</h2> <h2 class="yk-sidenav__title">云客数据镜像</h2>
</div> </div>
<el-menu <el-menu
:default-active="activeMenu" :default-active="activeMenu"
:default-openeds="[activeChannel]"
class="yk-sidenav__menu" class="yk-sidenav__menu"
router
> >
<el-menu-item <!-- 微信管理 -->
v-for="item in navItems" <el-sub-menu index="wx">
:key="item.path" <template #title>
:index="item.path" <span class="yk-sidenav__group">微信管理</span>
> </template>
<el-icon> <el-menu-item index="/staff?channel=wechat" @click="go('/staff', 'wechat')">
<component :is="item.icon" /> 员工列表
</el-icon> </el-menu-item>
<span>{{ item.label }}</span> <el-menu-item index="/customers?channel=wechat" @click="go('/customers', 'wechat')">
客户列表
</el-menu-item>
<el-menu-item index="/calls?channel=wechat" @click="go('/calls', 'wechat')">
语音通话列表
</el-menu-item>
<el-menu-item index="/groups?channel=wechat" @click="go('/groups', 'wechat')">
群列表
</el-menu-item>
</el-sub-menu>
<!-- WhatsApp管理 -->
<el-sub-menu index="wa">
<template #title>
<span class="yk-sidenav__group">WhatsApp管理</span>
</template>
<el-menu-item index="/staff?channel=whatsapp" @click="go('/staff', 'whatsapp')">
员工列表
</el-menu-item>
<el-menu-item index="/customers?channel=whatsapp" @click="go('/customers', 'whatsapp')">
客户列表
</el-menu-item>
<el-menu-item index="/calls?channel=whatsapp" @click="go('/calls', 'whatsapp')">
语音通话列表
</el-menu-item>
</el-sub-menu>
<!-- 通用功能 -->
<el-menu-item index="/sms" @click="goPlain('/sms')">
短信记录
</el-menu-item>
<el-menu-item index="/sync" @click="goPlain('/sync')">
同步状态
</el-menu-item>
<el-menu-item index="/search" @click="goPlain('/search')">
全局搜索
</el-menu-item> </el-menu-item>
</el-menu> </el-menu>
</el-aside> </el-aside>
@@ -67,6 +108,7 @@ const navItems = [
background: #fff; background: #fff;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow-y: auto;
} }
.yk-sidenav__header { .yk-sidenav__header {
@@ -79,8 +121,6 @@ const navItems = [
font-weight: 700; font-weight: 700;
color: #303133; color: #303133;
white-space: nowrap; white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
} }
.yk-sidenav__menu { .yk-sidenav__menu {
@@ -88,18 +128,51 @@ const navItems = [
padding-top: 4px; padding-top: 4px;
} }
.yk-sidenav__menu :deep(.el-menu-item) { .yk-sidenav__group {
font-size: 14px;
font-weight: 600;
color: #303133;
}
.yk-sidenav__menu :deep(.el-sub-menu__title) {
height: 44px; height: 44px;
line-height: 44px; line-height: 44px;
margin: 2px 8px; margin: 2px 8px;
border-radius: 6px; border-radius: 6px;
} }
.yk-sidenav__menu :deep(.el-sub-menu__title:hover) {
background: var(--el-fill-color-light, #f5f7fa);
}
.yk-sidenav__menu :deep(.el-sub-menu .el-menu) {
background: transparent;
}
.yk-sidenav__menu :deep(.el-menu-item) {
height: 40px;
line-height: 40px;
margin: 1px 8px 1px 20px;
border-radius: 6px;
font-size: 13px;
min-width: auto;
}
.yk-sidenav__menu :deep(.el-menu-item.is-active) { .yk-sidenav__menu :deep(.el-menu-item.is-active) {
background: var(--el-color-primary-light-9, #ecf5ff); background: var(--el-color-primary-light-9, #ecf5ff);
color: var(--el-color-primary);
} }
.yk-sidenav__menu :deep(.el-menu-item:hover) { .yk-sidenav__menu :deep(.el-menu-item:hover) {
background: var(--el-fill-color-light, #f5f7fa); background: var(--el-fill-color-light, #f5f7fa);
} }
/* 顶层普通菜单项(短信/同步/搜索)——与分组标题同高 */
.yk-sidenav__menu > :deep(.el-menu-item) {
height: 44px;
line-height: 44px;
margin: 2px 8px;
font-size: 14px;
font-weight: 500;
}
</style> </style>
+7 -4
View File
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, ref } from 'vue' import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { ElMessage, type TabPaneName } from 'element-plus' import { ElMessage, type TabPaneName } from 'element-plus'
import { Download } from '@element-plus/icons-vue' import { Download } from '@element-plus/icons-vue'
import { getCalls } from '@/api' import { getCalls } from '@/api'
@@ -16,10 +16,15 @@ import { buildCallSections, readField } from '@/utils/callFields'
import { exportListToCsv } from '@/utils/csvExport' import { exportListToCsv } from '@/utils/csvExport'
import VoiceClipModal from '@/components/VoiceClipModal.vue' import VoiceClipModal from '@/components/VoiceClipModal.vue'
const route = useRoute()
const router = useRouter()
// Calls aren't tied to a messaging channel — `channel` on a call is the call // Calls aren't tied to a messaging channel — `channel` on a call is the call
// type (phone_call / voice_call / wa_voice_call). We keep a LOCAL filter so it // type (phone_call / voice_call / wa_voice_call). We keep a LOCAL filter so it
// doesn't fight the shared top-bar wechat/whatsapp store used by customers/groups. // doesn't fight the shared top-bar wechat/whatsapp store used by customers/groups.
const callType = ref<CallChannel>('voice_call') const callType = ref<CallChannel>(
route.query.channel === 'whatsapp' ? 'wa_voice_call' : 'voice_call',
)
// 微信语音 tab scope filter: 对齐云客 微信好友/微信群 二分(isRoom 0=好友, 1=群)。 // 微信语音 tab scope filter: 对齐云客 微信好友/微信群 二分(isRoom 0=好友, 1=群)。
// 仅在 voice_call tab 生效;client-side 过滤当前页。 // 仅在 voice_call tab 生效;client-side 过滤当前页。
@@ -43,8 +48,6 @@ const voiceClipUserId = ref('')
const voiceClipChannel = ref<'wechat' | 'whatsapp'>('wechat') const voiceClipChannel = ref<'wechat' | 'whatsapp'>('wechat')
const voiceClipStaffName = ref<string | null>(null) const voiceClipStaffName = ref<string | null>(null)
const router = useRouter()
// All-fields drawer state. // All-fields drawer state.
const drawerOpen = ref(false) const drawerOpen = ref(false)
const drawerCall = ref<PhoneCall | null>(null) const drawerCall = ref<PhoneCall | null>(null)
+5 -1
View File
@@ -47,7 +47,11 @@ const org = useOrgStore()
// activeTab 跟随全局 channelStore(StaffList viewCustomers 先 setChannel 再 push /customers)。 // activeTab 跟随全局 channelStore(StaffList viewCustomers 先 setChannel 再 push /customers)。
// channel 总是具体值('wechat' | 'whatsapp'),不会是 'all' —— CustomerList 强制按 tab 选 channel, // channel 总是具体值('wechat' | 'whatsapp'),不会是 'all' —— CustomerList 强制按 tab 选 channel,
// loadTab 永不传 'all'(getCustomers 的 'all'→undefined 分支不会被触发)。 // loadTab 永不传 'all'(getCustomers 的 'all'→undefined 分支不会被触发)。
const activeTab = ref<TabKey>(channelStore.channel === 'whatsapp' ? 'whatsapp' : 'wechat') const activeTab = ref<TabKey>(
route.query.channel === 'whatsapp' || (!route.query.channel && channelStore.channel === 'whatsapp')
? 'whatsapp'
: 'wechat',
)
const tabState = reactive<Record<TabKey, TabState>>({ const tabState = reactive<Record<TabKey, TabState>>({
wechat: freshTabState(), wechat: freshTabState(),
whatsapp: freshTabState(), whatsapp: freshTabState(),
+5 -1
View File
@@ -45,7 +45,11 @@ const channelStore = useChannelStore()
// activeTab 跟随全局 channelStore(StaffList viewGroups 先 setChannel 再 push /groups)。 // activeTab 跟随全局 channelStore(StaffList viewGroups 先 setChannel 再 push /groups)。
// channel 总是具体值('wechat' | 'whatsapp'),不会是 'all'。 // channel 总是具体值('wechat' | 'whatsapp'),不会是 'all'。
const activeTab = ref<TabKey>(channelStore.channel === 'whatsapp' ? 'whatsapp' : 'wechat') const activeTab = ref<TabKey>(
route.query.channel === 'whatsapp' || (!route.query.channel && channelStore.channel === 'whatsapp')
? 'whatsapp'
: 'wechat',
)
const tabState = reactive<Record<TabKey, TabState>>({ const tabState = reactive<Record<TabKey, TabState>>({
wechat: freshTabState(), wechat: freshTabState(),
whatsapp: freshTabState(), whatsapp: freshTabState(),
+8 -5
View File
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue' import { computed, onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { Download } from '@element-plus/icons-vue' import { Download } from '@element-plus/icons-vue'
import { getAccounts, getCustomers, getStaffChatStats } from '@/api' import { getAccounts, getCustomers, getStaffChatStats } from '@/api'
@@ -53,15 +53,18 @@ function freshTabState(): TabState {
} }
} }
const activeTab = ref<TabKey>('wechat') const route = useRoute()
const router = useRouter()
const channelStore = useChannelStore()
const activeTab = ref<TabKey>(
(route.query.channel === 'whatsapp' ? 'whatsapp' : 'wechat') as TabKey,
)
const tabState = reactive<Record<TabKey, TabState>>({ const tabState = reactive<Record<TabKey, TabState>>({
wechat: freshTabState(), wechat: freshTabState(),
whatsapp: freshTabState(), whatsapp: freshTabState(),
}) })
const router = useRouter()
const channelStore = useChannelStore()
// All-fields drawer state (shared across tabs). // All-fields drawer state (shared across tabs).
const drawerOpen = ref(false) const drawerOpen = ref(false)
const drawerAccount = ref<Account | null>(null) const drawerAccount = ref<Account | null>(null)