feat(im): tenant-wide IM channels overview under the user menu
Until now the IM channels a tenant has connected were only visible from
inside each agent's editor (AgentEditorModal → IMChannelPanel). Finding
out which bots are live across all agents meant clicking through every
one of them. Add a tenant-scoped overview so the set of connected IMs is
always one hop away from the avatar.
Backend
- im.Service.ListChannelsByTenant(tenantID) returns all non-deleted
channels in the tenant, LEFT JOIN'd with custom_agents.name so
built-in agents (which don't have rows in custom_agents) still show
up with an empty agent_name; the frontend substitutes a localized
"built-in agent" label.
- Credentials are intentionally stripped from this response — the list
view is read-only and the editor route (GET /agents/:id/im-channels)
remains the only source for secrets.
- New ChannelWithAgent DTO + IMHandler.ListAllIMChannels wired at
GET /api/v1/im-channels under the existing RegisterIMChannelRoutes
group, so auth middleware is inherited.
Frontend
- IMChannelsOverviewPanel.vue: floating submenu pane, stacked rows
(agent on top, channel below) with identical 20px avatars and 12px
labels so neither identity dominates. Each row is the whole click
target (jumps to the agent editor); the switch uses @click.stop to
toggle in place without triggering navigation.
- UserMenu.vue: new hover-driven submenu entry ("已接入的 IM" + link
icon). The pane is teleported to <body> because the sidebar container
has overflow:hidden that would otherwise clip right-flying content.
Position is computed from the menu item's rect and clamps/flips
against the viewport edges.
- "Live" indicator: a pulsing green dot on the menu item when at least
one channel is enabled. UserMenu prefetches the list once on mount;
the panel re-emits channels-changed after every load/toggle so the
dot stays in sync. Respects prefers-reduced-motion.
- AgentList.vue: supplement the existing onMounted-only
checkAndOpenEditModal with a watch(route.query.edit) so
router.push({ path: '/platform/agents', query: { edit, section } })
from an already-mounted AgentList (the common case when navigating
from the overview) opens the editor immediately instead of only
after a hard refresh.
Assets
- Seven platform SVGs under assets/img/im/, pulled from iconify
(simple-icons / logos / tdesign / icon-park / remix icon) and baked
with brand colors so monochrome sources (wecom/wechat/dingtalk/
feishu) don't render black.
i18n
- New imOverview namespace in zh-CN / en-US / ko-KR / ru-RU covering
the menu label, panel title/subtitle, column headers, builtin-agent
fallback, and the live-indicator tooltip.
Tested
- go build ./...
- go test ./internal/im/...
- vue-tsc --noEmit
- npm run build
This commit is contained in:
@@ -0,0 +1,393 @@
|
||||
<template>
|
||||
<div class="im-submenu" @click.stop>
|
||||
<div class="submenu-header">
|
||||
<div class="titles">
|
||||
<h4 class="title">{{ $t('imOverview.pageTitle') }}</h4>
|
||||
<p class="subtitle">{{ $t('imOverview.subtitle') }}</p>
|
||||
</div>
|
||||
<t-button
|
||||
variant="text"
|
||||
theme="default"
|
||||
size="small"
|
||||
:loading="loading"
|
||||
@click="loadAll"
|
||||
>
|
||||
<template #icon><t-icon name="refresh" /></template>
|
||||
</t-button>
|
||||
</div>
|
||||
|
||||
<div class="submenu-body">
|
||||
<div v-if="loading && channels.length === 0" class="state-placeholder">
|
||||
<t-loading size="small" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="channels.length === 0" class="state-placeholder">
|
||||
<span class="empty-text">{{ $t('imOverview.empty') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else class="channels-list">
|
||||
<div
|
||||
v-for="ch in channels"
|
||||
:key="ch.id"
|
||||
class="channel-item"
|
||||
:class="{ 'is-disabled': !ch.enabled }"
|
||||
role="button"
|
||||
:tabindex="0"
|
||||
:title="$t('imOverview.gotoAgentEditor')"
|
||||
@click="gotoAgentEditor(ch)"
|
||||
@keydown.enter="gotoAgentEditor(ch)"
|
||||
@keydown.space.prevent="gotoAgentEditor(ch)"
|
||||
>
|
||||
<!-- Stacked rows: agent on top, IM channel below. Same avatar size
|
||||
and typography → both read as co-equal identities of the row. -->
|
||||
<div class="stack">
|
||||
<div class="stack-row">
|
||||
<span class="row-avatar">
|
||||
<span
|
||||
v-if="agentMeta(ch.agent_id)?.is_builtin"
|
||||
class="builtin-avatar"
|
||||
:class="agentMeta(ch.agent_id)?.config?.agent_mode === 'smart-reasoning' ? 'agent' : 'normal'"
|
||||
>
|
||||
<t-icon
|
||||
:name="agentMeta(ch.agent_id)?.config?.agent_mode === 'smart-reasoning' ? 'control-platform' : 'chat'"
|
||||
size="12px"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
v-else-if="agentMeta(ch.agent_id)?.avatar"
|
||||
class="builtin-avatar agent-emoji"
|
||||
>{{ agentMeta(ch.agent_id)!.avatar }}</span>
|
||||
<AgentAvatar
|
||||
v-else
|
||||
:name="ch.agent_name || ch.agent_id"
|
||||
size="small"
|
||||
/>
|
||||
</span>
|
||||
<span class="row-label" :title="ch.agent_name || agentMeta(ch.agent_id)?.name || ''">
|
||||
{{ ch.agent_name || agentMeta(ch.agent_id)?.name || $t('imOverview.builtinAgent') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="stack-row">
|
||||
<img
|
||||
class="row-avatar platform-logo"
|
||||
:src="platformLogo(ch.platform)"
|
||||
:alt="platformLabel(ch.platform)"
|
||||
/>
|
||||
<span class="row-label" :title="ch.name || platformLabel(ch.platform)">
|
||||
{{ ch.name || platformLabel(ch.platform) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item-actions" @click.stop>
|
||||
<t-switch
|
||||
:value="ch.enabled"
|
||||
size="small"
|
||||
:loading="togglingId === ch.id"
|
||||
@change="handleToggle(ch)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { MessagePlugin } from 'tdesign-vue-next';
|
||||
import {
|
||||
listAllIMChannels,
|
||||
listAgents,
|
||||
toggleIMChannel,
|
||||
type IMChannelOverview,
|
||||
type CustomAgent,
|
||||
} from '@/api/agent';
|
||||
import AgentAvatar from '@/components/AgentAvatar.vue';
|
||||
|
||||
// Platform logos sourced from iconify (simple-icons / logos / tdesign / remix icon).
|
||||
// Bundled as static assets so they share the app's caching story.
|
||||
import wecomLogo from '@/assets/img/im/wecom.svg';
|
||||
import feishuLogo from '@/assets/img/im/feishu.svg';
|
||||
import slackLogo from '@/assets/img/im/slack.svg';
|
||||
import telegramLogo from '@/assets/img/im/telegram.svg';
|
||||
import dingtalkLogo from '@/assets/img/im/dingtalk.svg';
|
||||
import mattermostLogo from '@/assets/img/im/mattermost.svg';
|
||||
import wechatLogo from '@/assets/img/im/wechat.svg';
|
||||
|
||||
const PLATFORM_LOGO: Record<string, string> = {
|
||||
wecom: wecomLogo,
|
||||
feishu: feishuLogo,
|
||||
slack: slackLogo,
|
||||
telegram: telegramLogo,
|
||||
dingtalk: dingtalkLogo,
|
||||
mattermost: mattermostLogo,
|
||||
wechat: wechatLogo,
|
||||
};
|
||||
|
||||
const props = defineProps<{
|
||||
active: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'close'): void;
|
||||
(e: 'channels-changed', channels: IMChannelOverview[]): void;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
|
||||
const channels = ref<IMChannelOverview[]>([]);
|
||||
const agentMap = ref<Map<string, CustomAgent>>(new Map());
|
||||
const loading = ref(false);
|
||||
const togglingId = ref<string>('');
|
||||
|
||||
// Parent tells us when the submenu is active (hover/click-open). Reload only
|
||||
// when transitioning into active so we don't refetch on every re-render.
|
||||
watch(
|
||||
() => props.active,
|
||||
(v, old) => {
|
||||
if (v && !old) loadAll();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
function platformLogo(p: string): string {
|
||||
return PLATFORM_LOGO[p] || '';
|
||||
}
|
||||
|
||||
function platformLabel(p: string): string {
|
||||
return t(`agentEditor.im.${p}`);
|
||||
}
|
||||
|
||||
function agentMeta(agentId: string): CustomAgent | undefined {
|
||||
return agentMap.value.get(agentId);
|
||||
}
|
||||
|
||||
async function loadAll() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const [chanResp, agentResp] = await Promise.all([
|
||||
listAllIMChannels(),
|
||||
listAgents(),
|
||||
]);
|
||||
channels.value = chanResp?.data || [];
|
||||
const m = new Map<string, CustomAgent>();
|
||||
(agentResp?.data || []).forEach((a) => m.set(a.id, a));
|
||||
agentMap.value = m;
|
||||
emit('channels-changed', channels.value);
|
||||
} catch (err) {
|
||||
console.error('Failed to load IM overview:', err);
|
||||
MessagePlugin.error(t('imOverview.loadFailed'));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleToggle(ch: IMChannelOverview) {
|
||||
if (togglingId.value) return;
|
||||
togglingId.value = ch.id;
|
||||
try {
|
||||
await toggleIMChannel(ch.id);
|
||||
const resp = await listAllIMChannels();
|
||||
channels.value = resp?.data || [];
|
||||
emit('channels-changed', channels.value);
|
||||
} catch (err: any) {
|
||||
console.error('Failed to toggle IM channel:', err);
|
||||
MessagePlugin.error(err?.message || t('common.operationFailed'));
|
||||
} finally {
|
||||
togglingId.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
function gotoAgentEditor(ch: IMChannelOverview) {
|
||||
emit('close');
|
||||
router.push({
|
||||
path: '/platform/agents',
|
||||
query: { edit: ch.agent_id, section: 'im' },
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.im-submenu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 300px;
|
||||
max-height: 520px;
|
||||
background: var(--td-bg-color-container);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.submenu-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 12px 14px;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
|
||||
.titles {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0 0 2px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-primary);
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin: 0;
|
||||
font-size: 11px;
|
||||
color: var(--td-text-color-secondary);
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
.submenu-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 6px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.state-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
padding: 40px 0;
|
||||
color: var(--td-text-color-placeholder);
|
||||
|
||||
.empty-text {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.channels-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.channel-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 10px;
|
||||
background: transparent;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
}
|
||||
|
||||
&.is-disabled {
|
||||
opacity: 0.55;
|
||||
}
|
||||
}
|
||||
|
||||
// Stacked rows: agent on top, channel below. Both lines share identical
|
||||
// typography and avatar size so neither dominates — they read as two facets
|
||||
// of the same row rather than a headline + caption.
|
||||
.stack {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.stack-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.row-avatar {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 4px;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.platform-logo {
|
||||
object-fit: contain;
|
||||
background: transparent;
|
||||
padding: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
.row-label {
|
||||
font-size: 12px;
|
||||
color: var(--td-text-color-primary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
min-width: 0;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
// Switch stays right-anchored, separated from the stack by the natural row gap.
|
||||
.item-actions {
|
||||
margin-left: 8px;
|
||||
flex-shrink: 0;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.builtin-avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 4px;
|
||||
flex-shrink: 0;
|
||||
|
||||
&.agent-emoji {
|
||||
font-size: 13px;
|
||||
line-height: 1;
|
||||
background: var(--td-bg-color-container-hover);
|
||||
}
|
||||
&.normal {
|
||||
background: linear-gradient(135deg, rgba(7, 192, 95, 0.15) 0%, rgba(7, 192, 95, 0.08) 100%);
|
||||
color: var(--td-brand-color-active);
|
||||
}
|
||||
&.agent {
|
||||
background: linear-gradient(135deg, rgba(124, 77, 255, 0.15) 0%, rgba(124, 77, 255, 0.08) 100%);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
// Size the generated AgentAvatar (hash-based gradient + letter) to match the
|
||||
// builtin-avatar and platform-logo so all three rows align perfectly.
|
||||
.stack-row {
|
||||
:deep(.agent-avatar),
|
||||
:deep(.agent-avatar-small) {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
:deep(.agent-avatar-letter) {
|
||||
font-size: 10px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -47,6 +47,25 @@
|
||||
<t-icon name="secured" class="menu-icon" />
|
||||
<span>{{ $t('settings.apiInfo') }}</span>
|
||||
</div>
|
||||
<div
|
||||
ref="imMenuItemRef"
|
||||
class="menu-item menu-item--submenu"
|
||||
:class="{ 'is-open': imSubmenuOpen }"
|
||||
@mouseenter="showIMSubmenu"
|
||||
@mouseleave="scheduleHideIMSubmenu"
|
||||
>
|
||||
<t-icon name="link" class="menu-icon" />
|
||||
<span class="menu-item-label">{{ $t('imOverview.menuTitle') }}</span>
|
||||
<span
|
||||
v-if="hasActiveIMChannels"
|
||||
class="live-indicator"
|
||||
:title="$t('imOverview.liveIndicator')"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<span class="live-indicator-dot"></span>
|
||||
</span>
|
||||
<t-icon name="chevron-right" class="menu-chevron" />
|
||||
</div>
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item" @click="handleSettings">
|
||||
<t-icon name="setting" class="menu-icon" />
|
||||
@@ -105,6 +124,25 @@
|
||||
</template>
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<!-- IM submenu is teleported to body because the sidebar (.aside_box) has
|
||||
overflow:hidden, which would otherwise clip any absolutely-positioned
|
||||
child that reaches past its bounds. -->
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="imSubmenuOpen"
|
||||
class="im-submenu-floating"
|
||||
:style="imSubmenuStyle"
|
||||
@mouseenter="showIMSubmenu"
|
||||
@mouseleave="scheduleHideIMSubmenu"
|
||||
>
|
||||
<IMChannelsOverviewPanel
|
||||
:active="imSubmenuOpen"
|
||||
@close="closeAll"
|
||||
@channels-changed="onChannelsChanged"
|
||||
/>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -116,6 +154,8 @@ import { useAuthStore } from '@/stores/auth'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { getCurrentUser, logout as logoutApi } from '@/api/auth'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import IMChannelsOverviewPanel from '@/components/IMChannelsOverviewPanel.vue'
|
||||
import { listAllIMChannels, type IMChannelOverview } from '@/api/agent'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -124,7 +164,12 @@ const uiStore = useUIStore()
|
||||
const authStore = useAuthStore()
|
||||
|
||||
const menuRef = ref<HTMLElement>()
|
||||
const imMenuItemRef = ref<HTMLElement>()
|
||||
const menuVisible = ref(false)
|
||||
const imSubmenuOpen = ref(false)
|
||||
const imSubmenuStyle = ref<Record<string, string>>({})
|
||||
const hasActiveIMChannels = ref(false)
|
||||
let imSubmenuHideTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
// 用户信息
|
||||
const userInfo = ref({
|
||||
@@ -168,6 +213,81 @@ const handleSettings = () => {
|
||||
router.push('/platform/settings')
|
||||
}
|
||||
|
||||
// Hover-driven submenu controls. A small hide delay tolerates the pointer
|
||||
// slipping off briefly onto the gap between menu item and submenu pane.
|
||||
const showIMSubmenu = () => {
|
||||
if (imSubmenuHideTimer) {
|
||||
clearTimeout(imSubmenuHideTimer)
|
||||
imSubmenuHideTimer = null
|
||||
}
|
||||
// Compute panel position based on the menu item's rect — the panel is
|
||||
// teleported to body so we can't rely on CSS `left: 100%`.
|
||||
positionIMSubmenu()
|
||||
imSubmenuOpen.value = true
|
||||
}
|
||||
|
||||
const scheduleHideIMSubmenu = () => {
|
||||
if (imSubmenuHideTimer) clearTimeout(imSubmenuHideTimer)
|
||||
imSubmenuHideTimer = setTimeout(() => {
|
||||
imSubmenuOpen.value = false
|
||||
imSubmenuHideTimer = null
|
||||
}, 180)
|
||||
}
|
||||
|
||||
const closeAll = () => {
|
||||
imSubmenuOpen.value = false
|
||||
menuVisible.value = false
|
||||
}
|
||||
|
||||
// Silent prefetch so the "live" indicator on the IM menu item reflects reality
|
||||
// as soon as the user sees the avatar area. Errors are swallowed — the
|
||||
// indicator just stays off if the request fails, which is the conservative
|
||||
// default. The panel component emits channels-changed after toggle/refresh so
|
||||
// we stay in sync without re-polling.
|
||||
const refreshIMStatus = async () => {
|
||||
try {
|
||||
const resp = await listAllIMChannels()
|
||||
const data: IMChannelOverview[] = resp?.data || []
|
||||
hasActiveIMChannels.value = data.some((c) => c.enabled)
|
||||
} catch {
|
||||
// Intentionally ignored — indicator just stays off.
|
||||
}
|
||||
}
|
||||
|
||||
const onChannelsChanged = (channels: IMChannelOverview[]) => {
|
||||
hasActiveIMChannels.value = channels.some((c) => c.enabled)
|
||||
}
|
||||
|
||||
// Anchor the floating submenu just to the right of the hovered menu item,
|
||||
// clamped to the viewport so it stays visible near the screen edge.
|
||||
const positionIMSubmenu = () => {
|
||||
const el = imMenuItemRef.value
|
||||
if (!el) return
|
||||
const rect = el.getBoundingClientRect()
|
||||
const PANEL_WIDTH = 300
|
||||
const PANEL_MAX_HEIGHT = 520
|
||||
const GAP = 8
|
||||
const MARGIN = 8
|
||||
|
||||
let left = rect.right + GAP
|
||||
// If the panel would overflow the right edge, flip to the left side.
|
||||
if (left + PANEL_WIDTH + MARGIN > window.innerWidth) {
|
||||
left = Math.max(MARGIN, rect.left - PANEL_WIDTH - GAP)
|
||||
}
|
||||
|
||||
// Align the panel's top with the menu item, then clamp so it doesn't
|
||||
// spill past the bottom of the viewport.
|
||||
let top = rect.top - 4
|
||||
const maxTop = window.innerHeight - Math.min(PANEL_MAX_HEIGHT, window.innerHeight - MARGIN * 2) - MARGIN
|
||||
if (top > maxTop) top = maxTop
|
||||
if (top < MARGIN) top = MARGIN
|
||||
|
||||
imSubmenuStyle.value = {
|
||||
left: `${left}px`,
|
||||
top: `${top}px`,
|
||||
}
|
||||
}
|
||||
|
||||
const CHROME_EXTENSION_URL =
|
||||
'https://chromewebstore.google.com/detail/jpemjbopikggjlmikmclgbmkhhopjdgd?utm_source=item-share-cb'
|
||||
|
||||
@@ -252,14 +372,20 @@ const loadUserInfo = async () => {
|
||||
|
||||
// 点击外部关闭菜单
|
||||
const handleClickOutside = (e: MouseEvent) => {
|
||||
if (menuRef.value && !menuRef.value.contains(e.target as Node)) {
|
||||
menuVisible.value = false
|
||||
}
|
||||
const target = e.target as Node
|
||||
if (menuRef.value && menuRef.value.contains(target)) return
|
||||
// The submenu is teleported to body, so it's not inside menuRef — check it
|
||||
// separately to avoid closing the dropdown when the user clicks the submenu.
|
||||
const floating = document.querySelector('.im-submenu-floating')
|
||||
if (floating && floating.contains(target)) return
|
||||
menuVisible.value = false
|
||||
imSubmenuOpen.value = false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener('click', handleClickOutside)
|
||||
loadUserInfo()
|
||||
refreshIMStatus()
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
@@ -411,6 +537,69 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
|
||||
// 包含右弹子菜单的菜单项
|
||||
&--submenu {
|
||||
position: relative;
|
||||
|
||||
.menu-item-label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.menu-chevron {
|
||||
font-size: 14px;
|
||||
color: var(--td-text-color-placeholder);
|
||||
flex-shrink: 0;
|
||||
transition: transform 0.15s;
|
||||
}
|
||||
|
||||
&.is-open {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
|
||||
.menu-chevron {
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
}
|
||||
|
||||
// "Live" indicator — shown when at least one IM channel is enabled.
|
||||
// A small green dot with a halo that pulses to signal active connections.
|
||||
.live-indicator {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-right: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.live-indicator-dot {
|
||||
position: relative;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--td-success-color, #07c160);
|
||||
|
||||
// Pulsing halo around the dot. Prefers-reduced-motion disables it.
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -3px;
|
||||
border-radius: 50%;
|
||||
background: var(--td-success-color, #07c160);
|
||||
opacity: 0.45;
|
||||
animation: im-live-pulse 1.6s ease-out infinite;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.live-indicator-dot::after {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.menu-icon {
|
||||
font-size: 16px;
|
||||
color: var(--td-text-color-secondary);
|
||||
@@ -506,5 +695,35 @@ onUnmounted(() => {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
// Live indicator halo animation — a soft expanding ring to signal that at
|
||||
// least one IM channel is actively connected.
|
||||
@keyframes im-live-pulse {
|
||||
0% {
|
||||
transform: scale(0.9);
|
||||
opacity: 0.45;
|
||||
}
|
||||
70% {
|
||||
transform: scale(1.8);
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
transform: scale(1.8);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
// Non-scoped: the IM submenu is teleported to <body> so scoped styles
|
||||
// from this component won't reach it. The panel component's own CSS is
|
||||
// scoped and self-contained; this rule only positions the wrapper.
|
||||
.im-submenu-floating {
|
||||
position: fixed;
|
||||
z-index: 1100;
|
||||
// Invisible padding forms a pointer bridge from the menu item to the
|
||||
// panel so hovering across the gap doesn't fire mouseleave-hide.
|
||||
padding-left: 2px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user