Files
ai_academy/frontend/src/components/menu.vue
T
runny 242dd7e1a6 feat(training): 企业培训迭代:核验权限收窄、课程发布状态与培训中心改版
需求域:
- 需求导入修复内/外培训与外部讲师落库;按模板标题年入库(年-月一致)
- 核验确认收窄为「需求归属部门+经理职称角色」,越权提示联系部门经理
- 确认转月计划后自动推送讲师/课长维护;导入后自动推送部门经理核验(站内+企微)

课程域:
- 课程管理发布状态字段(迁移000154)+发布/下线;培训中心「和信课程」目录
- 需求讲师改选后回写课程管理;确认同步带出适合人员/课件/试题
- 月计划详情课件/试题更换(上传/知识库选择/题库换绑)回写课程管理,
  无关联条目的存量计划自动创建课程条目

模板与表单:
- 教育训练需求表:适合人员/内-外培训口径;部门联动课程下拉;
  适合人员/讲师按所选课程自动带出;在线提报课程下拉(本部门)自动带出分类/讲师/适合人员

页面与权限:
- 培训中心页签重组(和信课程/我的培训/我的考试),移除线上/线下页签
- 数据驾驶舱迁侧栏(职称角色之下);职称角色迁至更多工具配置中心之后
- 配置中心/职称角色对经理开放;页签「职称角色」更名「角色权限」
- 修复年度下拉空白(TDesign options 需对象数组)、月计划列表地点兜底

其他: 培训预览端口修正与 dev:training 脚本;tmp-extract-duckdb 加入 gitignore
2026-11-19 01:49:17 +08:00

2479 lines
93 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="aside_box"
:class="{ 'aside_box--collapsed': uiStore.sidebarCollapsed, 'aside_box--resizing': uiStore.sidebarResizing, 'aside_box--chat-dock': chatDockOpen }">
<!-- 左列:图标栏(收起态)/ 展开侧栏;「AI对话」停靠面板打开时固定为图标栏宽度 -->
<div class="aside_rail">
<!-- 展开时:Logo + 搜索/折叠按钮同行 -->
<div class="logo_row" v-if="!uiStore.sidebarCollapsed">
<div class="logo_box" @click="router.push('/platform/knowledge-bases')" style="cursor: pointer;">
<span class="aido-logo" aria-label="AIDO" title="AIDO">
<span class="aido-logo__text">AIDO</span>
<span class="aido-logo__dot"></span>
</span>
<sup v-if="isLiteEdition" class="lite-badge">Lite</sup>
</div>
<div class="logo_actions">
<t-tooltip placement="bottom">
<template #content>
<span class="cmdk-tip">
<span class="cmdk-tip-label">{{ t('menu.search') }}</span>
<span class="cmdk-tip-keys">{{ cmdModKeyLabel }}K</span>
</span>
</template>
<div class="header-icon-btn" @click="commandPaletteStore.openPalette('')"
:aria-label="t('menu.search')">
<img class="header-icon-img" :src="getImgSrc('search.svg')" alt="">
</div>
</t-tooltip>
<div class="sidebar-toggle" @click="uiStore.toggleSidebar" :title="t('menu.collapseSidebar')">
<svg viewBox="0 0 20 20" width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect x="1.5" y="1.5" width="17" height="17" rx="3" stroke="currentColor" stroke-width="1.5" />
<line x1="7.5" y1="1.5" x2="7.5" y2="18.5" stroke="currentColor" stroke-width="1.5" />
<line x1="4" y1="7.5" x2="4" y2="12.5" stroke="currentColor" stroke-width="1.5"
stroke-linecap="round" />
</svg>
</div>
</div>
</div>
<!-- 折叠时:展开按钮 -->
<t-tooltip v-else :content="t('menu.expandSidebar')" placement="right">
<div class="menu_item sidebar-toggle-item" @click="uiStore.toggleSidebar">
<div class="menu_item-box">
<div class="menu_icon">
<svg class="icon icon--toggle" viewBox="0 0 20 20" width="16" height="16" fill="none"
xmlns="http://www.w3.org/2000/svg">
<rect x="1.5" y="1.5" width="17" height="17" rx="3" stroke="currentColor"
stroke-width="1.5" />
<line x1="7.5" y1="1.5" x2="7.5" y2="18.5" stroke="currentColor" stroke-width="1.5" />
<line x1="5" y1="10" x2="3" y2="8" stroke="currentColor" stroke-width="1.5"
stroke-linecap="round" />
<line x1="5" y1="10" x2="3" y2="12" stroke="currentColor" stroke-width="1.5"
stroke-linecap="round" />
</svg>
</div>
</div>
</div>
</t-tooltip>
<!-- 空间选择器:仅在用户可切换空间时显示 -->
<TenantSelector v-if="canAccessAllTenants && !uiStore.sidebarCollapsed" />
<!-- 侧栏边缘拖拽调宽,拖窄时自动收缩 -->
<PanelResizeHandle edge="right" :label="t('knowledgeStages.resizeDrawer')"
:value="uiStore.sidebarDisplayWidth" :min="SIDEBAR_COLLAPSED_WIDTH" :max="SIDEBAR_MAX_WIDTH"
@start="startSidebarResize" @resize="resizeSidebar" @end="uiStore.sidebarResizing = false" />
<!-- 上半部分:导航菜单(概览/AI对话/AI助理/更多工具) -->
<div class="menu_top">
<!-- 全局搜索入口:点击打开命令面板(⌘K)。展开态移至顶部 logo_row 的图标按钮;
折叠态在此处保留为图标项 + 深色 tooltip。 -->
<div class="menu_box menu_box--cmdk" v-if="uiStore.sidebarCollapsed">
<t-tooltip placement="right">
<template #content>
<span class="cmdk-tip">
<span class="cmdk-tip-label">{{ t('menu.search') }}</span>
<span class="cmdk-tip-keys">{{ cmdModKeyLabel }}K</span>
</span>
</template>
<div class="menu_item menu_item--cmdk" @click="commandPaletteStore.openPalette('')">
<div class="menu_item-box">
<div class="menu_icon">
<img class="icon" :src="getImgSrc('search.svg')" alt="">
</div>
</div>
</div>
</t-tooltip>
</div>
<div class="menu_box" :class="{ 'menu_box--sticky': item.children && !uiStore.sidebarCollapsed }"
v-for="(item, index) in topMenuItems" :key="index">
<t-tooltip :content="item.title" placement="right" :disabled="!uiStore.sidebarCollapsed">
<div @click="handleMenuClick(item.path)" @mouseenter="mouseenteMenu(item.path)"
@mouseleave="mouseleaveMenu(item.path)" :data-guide="`nav-${item.path}`"
:class="['menu_item', item.childrenPath && item.childrenPath == currentpath ? 'menu_item_c_active' : isMenuItemActive(item.path) ? 'menu_item_active' : '']">
<div class="menu_item-box">
<div class="menu_icon" :class="`menu_icon--${item.icon}`">
<img class="icon" :src="getImgSrc(iconSrcFor(item.icon))" alt="">
</div>
<template v-if="!uiStore.sidebarCollapsed">
<span class="menu_title" :title="item.title">{{ item.title }}</span>
<span v-if="item.path === 'toolbox' && toolboxPreview.length" class="menu-toolbox-stack"
:title="toolboxPreview.map((tool) => tool.key === 'browserconnection' && browserStackStatus
? `${t(tool.title)} (${t(`localBrowser.${browserStackStatus}`)})` : t(tool.title)).join(' · ')">
<span v-for="tool in toolboxPreview" :key="tool.key" class="menu-toolbox-stack__item">
<template v-if="tool.key === 'browserconnection'">
<BrowserIcon width="12" height="12" />
<i v-if="browserStackStatus" class="menu-toolbox-stack__status"
:class="`is-${browserStackStatus}`" aria-hidden="true" />
</template>
<t-icon v-else :name="tool.icon" size="12px" />
</span>
</span>
</template>
</div>
</div>
</t-tooltip>
</div>
<!-- 更多工具:收纳低频入口(知识库/自动化/工具箱/对话产物/配置中心),可展开收起 -->
<div class="menu_box menu_box--moretools">
<t-tooltip :content="t('menu.moreTools')" placement="right" :disabled="!uiStore.sidebarCollapsed">
<div class="menu_item menu_item--moretools"
:class="{ 'menu_item_active': uiStore.sidebarCollapsed && moreToolsActive }"
data-guide="nav-moretools" @click="handleMoreToolsClick">
<div class="menu_item-box">
<div class="menu_icon menu_icon--moretools">
<img class="icon" :src="getImgSrc('moretools.svg')" alt="">
</div>
<template v-if="!uiStore.sidebarCollapsed">
<span class="menu_title" :title="t('menu.moreTools')">{{ t('menu.moreTools') }}</span>
</template>
</div>
<t-icon v-if="!uiStore.sidebarCollapsed" class="moretools-chevron"
:class="{ 'is-open': moreToolsOpen }" name="chevron-down" size="16px" />
</div>
</t-tooltip>
<div class="moretools_children" v-show="moreToolsOpen && !uiStore.sidebarCollapsed">
<t-tooltip v-for="child in moreToolItems" :key="child.path" :content="child.title"
placement="right" :disabled="!uiStore.sidebarCollapsed">
<div @click="handleMenuClick(child.path)" @mouseenter="mouseenteMenu(child.path)"
@mouseleave="mouseleaveMenu(child.path)" :data-guide="`nav-${child.path}`"
:class="['menu_item', 'menu_item--child', isMenuItemActive(child.path) ? 'menu_item_active' : '']">
<div class="menu_item-box">
<div class="menu_icon" :class="`menu_icon--${child.icon}`">
<img class="icon" :src="getImgSrc(iconSrcFor(child.icon))" alt="">
</div>
<span class="menu_title" :title="child.title">{{ child.title }}</span>
</div>
</div>
</t-tooltip>
</div>
</div>
<!-- 企业培训:培训管理子页分组,置于「更多工具」下方,可展开收起 -->
<div class="menu_box menu_box--moretools menu_box--training">
<t-tooltip :content="TRAINING_GROUP_TITLE" placement="right" :disabled="!uiStore.sidebarCollapsed">
<div class="menu_item menu_item--moretools"
:class="{ 'menu_item_active': uiStore.sidebarCollapsed && trainingActive }"
data-guide="nav-training" @click="handleTrainingClick">
<div class="menu_item-box">
<div class="menu_icon menu_icon--moretools">
<img class="icon" :src="getImgSrc(iconSrcFor('training'))" alt="">
</div>
<template v-if="!uiStore.sidebarCollapsed">
<span class="menu_title" :title="TRAINING_GROUP_TITLE">{{ TRAINING_GROUP_TITLE }}</span>
</template>
</div>
<t-icon v-if="!uiStore.sidebarCollapsed" class="moretools-chevron"
:class="{ 'is-open': trainingOpen }" name="chevron-down" size="16px" />
</div>
</t-tooltip>
<div class="moretools_children" v-show="trainingOpen && !uiStore.sidebarCollapsed">
<t-tooltip v-for="child in TRAINING_TABS" :key="child.key" :content="child.title"
placement="right" :disabled="!uiStore.sidebarCollapsed">
<div @click="handleMenuClick(`training/${child.key}`)" :data-guide="`nav-training-${child.key}`"
:class="['menu_item', 'menu_item--child', isMenuItemActive(`training/${child.key}`) ? 'menu_item_active' : '']">
<div class="menu_item-box">
<i class="training-child-dot" aria-hidden="true"></i>
<span class="menu_title" :title="child.title">{{ child.title }}</span>
</div>
</div>
</t-tooltip>
</div>
</div>
</div>
<!-- 下半部分:用户菜单(停靠面板打开时改由面板内渲染,避免重复实例) -->
<div class="menu_bottom" v-if="!chatDockOpen">
<UserMenu />
</div>
</div>
<!-- 「AI对话」停靠面板:点击「AI对话」侧栏收起为图标栏后,聊天记录停靠在其右侧 -->
<div class="chat_dock_panel" v-if="chatDockOpen">
<!-- 停靠态头部:分区标题 + 新对话按钮 + 聊天记录/搜索行 -->
<div class="history_section_title">{{ t('menu.newChat') }}</div>
<div class="history_new_chat_btn" @click="gotopage('creatChat')">
<t-icon name="add" size="16px" />
<span class="history_new_chat_text">{{ t('menu.startNewChat') }}</span>
</div>
<div class="history_header_row">
<span class="history_header_label">{{ t('menu.chatHistory') }}</span>
<t-tooltip :content="t('menu.search')" placement="bottom">
<div class="header-icon-btn" @click="commandPaletteStore.openPalette('')">
<img class="header-icon-img" :src="getImgSrc('search.svg')" alt="">
</div>
</t-tooltip>
</div>
<!-- 历史会话:按来源筛选后统一按日期分组展示 -->
<div class="submenu" ref="scrollContainer" @scroll="handleScroll">
<!-- Stable, always-mounted source filter: reserving its row here
(instead of embedding it in the first date group, which
appears/disappears while a bucket loads) prevents the
top-right control from jumping when switching session type. -->
<div v-if="showSessionSourceFilter && !batchMode" class="session-list-scope-header">
<SessionSourceFilter inline :emphasized="sessionScopeFilterPinned" :sources="sessionSourceOptions"
:current="activeSessionBucketKey" @select="switchSessionBucket" />
</div>
<template v-if="sessionListBooting && !hasAnySession">
<div v-for="n in 4" :key="'skel-' + n" class="submenu_item_p session-chat-row">
<div class="session-list-row session-list-row--flat">
<t-skeleton animation="gradient" class="session-list-row__body"
:row-col="[{ width: '100%', height: '14px' }]" />
</div>
</div>
</template>
<div v-else class="session-filtered-list">
<template
v-if="activeBucket?.loading && !activeBucket.loaded && filteredGroupedSessions.length === 0">
<div v-for="n in 4" :key="'bucket-skel-' + n" class="submenu_item_p session-chat-row">
<div class="session-list-row session-list-row--flat">
<t-skeleton animation="gradient" class="session-list-row__body"
:row-col="[{ width: '100%', height: '14px' }]" />
</div>
</div>
</template>
<template v-else-if="activeBucket?.loaded && filteredGroupedSessions.length === 0">
<div class="submenu_empty">{{ t('menu.noSessions') }}</div>
</template>
<template v-else>
<template v-for="group in filteredGroupedSessions" :key="group.key">
<div v-if="group.label" class="timeline_header session-list-row session-list-row--flat">
<span class="session-list-row__body">
<span class="timeline_header-label">{{ group.label }}</span>
</span>
</div>
<div v-for="subitem in group.items" :key="subitem.id"
class="submenu_item_p session-chat-row" :data-session-id="subitem.id" :class="{
'session-chat-row--active': !batchMode && subitem.path === currentSecondpath,
'session-chat-row--selected': batchMode && batchSelectedIds.includes(subitem.id),
'session-chat-row--revealed': revealedSessionId === subitem.id,
}">
<div class="session-list-row session-list-row--flat">
<div class="session-list-row__body">
<SessionSidebarRow :item="subitem" :batch-mode="batchMode"
:running="Boolean(sessionActivityEntries[subitem.id])"
:unread="Boolean(sessionUnread[subitem.id])"
:active-path="currentSecondpath" :selected-ids="batchSelectedIds"
:menu-options="buildSessionMenuOptions(subitem)"
@navigate="gotopage(subitem.path)"
@toggle-select="toggleBatchSelect(subitem.id)"
@menu-click="handleSessionMenuClick($event, subitem)"
@rename-submit="renameSessionTitle(subitem, $event.title)"
@hover-in="mouseenteBotDownr(subitem.id)" @hover-out="mouseleaveBotDown" />
</div>
</div>
</div>
</template>
<div v-if="activeBucket?.loading && filteredGroupedSessions.length > 0"
class="session-list-loading session-list-row session-list-row--flat">
<span class="session-list-row__body">
<t-loading size="small" />
</span>
</div>
</template>
</div>
</div>
<!-- 批量管理底部操作条:固定在面板底部、用户信息上方 -->
<div v-if="batchMode" class="batch-inline-footer">
<div class="batch-footer-left">
<t-checkbox :checked="isAllBatchSelected" :indeterminate="isBatchIndeterminate"
@change="toggleBatchSelectAll">
{{ t('batchManage.selectAll') }}
</t-checkbox>
</div>
<div class="batch-footer-right">
<t-button size="small" variant="text" @click="exitBatchMode">
{{ t('batchManage.cancel') }}
</t-button>
<t-button size="small" theme="danger" variant="base" :disabled="batchSelectedIds.length === 0"
:loading="batchDeleting" @click="handleInlineBatchDelete">
{{ t('batchManage.delete') }}{{ batchSelectedIds.length > 0 ? `(${batchDisplayCount})` : '' }}
</t-button>
</div>
</div>
<!-- 下半部分:用户信息(侧栏收起时仍按展开态布局渲染) -->
<div class="menu_bottom">
<UserMenu force-expanded />
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { onMounted, onUnmounted, watch, computed, ref, h, nextTick } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { getSessionsList, batchDelSessions, deleteAllSessions, getSession } from "@/api/chat/index";
import { useChatResourcesStore } from '@/stores/chatResources';
import { listAllIMChannels } from '@/api/agent/index';
import SessionSidebarRow from './SessionSidebarRow.vue';
import PanelResizeHandle from './PanelResizeHandle.vue';
import { SIDEBAR_COLLAPSED_WIDTH, SIDEBAR_MIN_WIDTH, SIDEBAR_MAX_WIDTH } from '@/utils/sidebarWidth';
import {
clearSession,
removeSession,
renameSession,
SESSION_MUTATION_EVENT,
setSessionPinned,
type SessionMutationDetail,
} from './sessionMutations';
import SessionSourceFilter from './SessionSourceFilter.vue';
import {
SIDEBAR_BUCKET_PAGE_SIZE,
applyBucketCountProbe,
buildBucketDefinitions,
bucketHasMore,
bucketVisible,
createEmptyBucket,
flattenBucketItems,
isChannelBucket,
isChannelBucketKey,
mergeBucketPage,
prependSessionToWebBucket,
removeSessionFromBuckets,
type SidebarSessionBucket,
} from './sessionSidebarBuckets';
import type { SessionForGrouping } from './sessionGrouping';
import { listAllEmbedChannels } from '@/api/embed/index';
import {
classifyDateBucket,
configuredPlatforms,
groupSessionsByDate,
originGroupKey,
resolveSessionOrigin,
type DateBucketKey,
} from './sessionGrouping';
import {
DEFAULT_SESSION_BUCKET_KEY,
buildSessionSourceOptions,
findSessionBucketKey,
shouldShowSessionSourceFilter,
} from './sessionSidebarSourceFilter';
import { logout as logoutApi } from '@/api/auth';
import { useMenuStore } from '@/stores/menu';
import { useSessionActivityStore } from '@/stores/sessionActivity';
import { useAuthStore } from '@/stores/auth';
import { useDeploymentCapabilitiesStore } from '@/stores/deploymentCapabilities';
import { TOOLBOX_ITEMS, canAccessToolboxSection } from '@/config/toolbox';
import BrowserIcon from '@/components/icons/BrowserIcon.vue';
import { useBrowserConnectionStore } from '@/stores/browserConnection';
import { useOrganizationStore } from '@/stores/organization';
import { useUIStore } from '@/stores/ui';
import { useCommandPaletteStore } from '@/stores/commandPalette';
import { MessagePlugin, DialogPlugin, Icon as TIcon } from "tdesign-vue-next";
import UserMenu from '@/components/UserMenu.vue';
import TenantSelector from '@/components/TenantSelector.vue';
import { useI18n } from 'vue-i18n';
import { useEditorResourcesStore } from '@/stores/editorResources';
const chatResources = useChatResourcesStore();
const editorResources = useEditorResourcesStore();
// Platform logos reused from IMChannelsOverviewPanel — keeps the session list
// visually consistent with the channels admin view.
import wecomLogo from '@/assets/img/im/wecom.svg';
import feishuLogo from '@/assets/img/im/feishu.svg';
import larkLogo from '@/assets/img/im/lark.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';
import qqbotLogo from '@/assets/img/im/qqbot.png';
const PLATFORM_LOGO: Record<string, string> = {
wecom: wecomLogo,
feishu: feishuLogo,
lark: larkLogo,
slack: slackLogo,
telegram: telegramLogo,
dingtalk: dingtalkLogo,
mattermost: mattermostLogo,
wechat: wechatLogo,
qqbot: qqbotLogo,
};
const platformLogo = (p: string): string => (p ? PLATFORM_LOGO[p] || '' : '');
const { t } = useI18n();
const usemenuStore = useMenuStore();
const sessionActivity = useSessionActivityStore();
const { entries: sessionActivityEntries, unread: sessionUnread } = storeToRefs(sessionActivity);
let sessionActivityTimer: ReturnType<typeof setInterval> | undefined;
const authStore = useAuthStore();
const deploymentCapabilities = useDeploymentCapabilitiesStore();
const toolboxPreview = computed(() => TOOLBOX_ITEMS.filter((item) => canAccessToolboxSection(item.key, {
currentTenantRole: authStore.currentTenantRole,
canAccessAllTenants: authStore.canAccessAllTenants,
hasRole: (role) => authStore.hasRole(role),
isSupported: (capability) => deploymentCapabilities.isSupported(capability),
})));
const orgStore = useOrganizationStore();
const uiStore = useUIStore();
const browserConnection = useBrowserConnectionStore();
const browserStackStatus = computed(() => {
if (!uiStore.sidebarBrowserStatus) return '';
if (!browserConnection.loaded || !browserConnection.enabled || !browserConnection.device) return '';
return browserConnection.connected ? 'connected' : 'offline';
});
watch(() => uiStore.sidebarBrowserStatus && toolboxPreview.value.some((tool) => tool.key === 'browserconnection'), (visible) => {
if (visible && !browserConnection.loaded) browserConnection.refresh().catch(() => {});
}, { immediate: true });
const commandPaletteStore = useCommandPaletteStore();
// Platform-aware label for the ⌘K hint. navigator.platform is deprecated but
// the alternatives (userAgentData.platform) aren't universally available yet;
// this check is good enough for Mac vs. non-Mac.
const isMacLike = typeof navigator !== 'undefined' && /Mac|iPod|iPhone|iPad/.test(navigator.platform || '');
const cmdModKeyLabel = isMacLike ? '⌘' : 'Ctrl';
const route = useRoute();
const router = useRouter();
const currentpath = ref('');
const total = ref(0);
const sessionBuckets = ref<Record<string, SidebarSessionBucket>>({});
const bucketOrder = ref<string[]>([]);
let bucketRequestToken = 0;
const sessionListBooting = ref(false);
const currentSecondpath = ref('');
const scrollContainer = ref<HTMLElement | null>(null);
const imPlatforms = ref<string[]>([]);
const embedChannelNames = ref<Record<string, string>>({});
const activeSessionBucketKey = ref(DEFAULT_SESSION_BUCKET_KEY);
const sessionListCanScroll = ref(false);
const visibleChannelBuckets = computed(() =>
bucketOrder.value
.map((key) => sessionBuckets.value[key])
.filter((bucket): bucket is SidebarSessionBucket => !!bucket && isChannelBucket(bucket) && bucketVisible(bucket)),
);
const showSessionSourceFilter = computed(() =>
shouldShowSessionSourceFilter(visibleChannelBuckets.value.length),
);
const sessionScopeFilterPinned = computed(() =>
activeSessionBucketKey.value !== DEFAULT_SESSION_BUCKET_KEY,
);
const sessionSourceOptions = computed(() =>
buildSessionSourceOptions(
t('menu.myChats'),
visibleChannelBuckets.value.map((bucket) => ({
key: bucket.key,
label: bucket.label,
platform: bucket.platform,
})),
(platform) => platformLogo(platform),
),
);
const activeBucket = computed(() => sessionBuckets.value[activeSessionBucketKey.value]);
const hasAnySession = computed(() =>
Object.values(sessionBuckets.value).some((bucket) => bucket.items.length > 0),
);
type MenuItem = { title: string; icon: string; path: string; childrenPath?: string; children?: any[] };
const { menuArr, visibleMenuArr } = storeToRefs(usemenuStore);
let activeSubmenu = ref<string>('');
const isLiteEdition = ref(false);
// 批量管理状态
const batchMode = ref(false)
const batchSelectedIds = ref<string[]>([])
const batchDeleting = ref(false)
const allSessionIds = computed(() => {
const chatMenu = (menuArr.value as unknown as MenuItem[]).find((item: MenuItem) => item.path === 'creatChat');
if (!chatMenu?.children) return [];
return (chatMenu.children as any[]).map((s: any) => s.id);
})
const isAllBatchSelected = computed(() =>
allSessionIds.value.length > 0 && batchSelectedIds.value.length === allSessionIds.value.length
)
const isBatchIndeterminate = computed(() =>
batchSelectedIds.value.length > 0 && batchSelectedIds.value.length < allSessionIds.value.length
)
const batchDisplayCount = computed(() =>
isAllBatchSelected.value ? total.value : batchSelectedIds.value.length
)
// 是否可以访问所有空间
const canAccessAllTenants = computed(() => authStore.canAccessAllTenants);
// 是否处于知识库详情页(不包括全局聊天)
const isInKnowledgeBase = computed<boolean>(() => {
return route.name === 'knowledgeBaseDetail' ||
route.name === 'kbCreatChat' ||
route.name === 'knowledgeBaseSettings';
});
// 是否在知识库列表页面
const isInKnowledgeBaseList = computed<boolean>(() => {
return route.name === 'knowledgeBaseList';
});
// 是否在创建聊天页面
const isInCreatChat = computed<boolean>(() => {
return route.name === 'globalCreatChat' || route.name === 'kbCreatChat';
});
// 是否在对话详情页
const isInChatDetail = computed<boolean>(() => route.name === 'chat');
// 是否在智能体列表页面
const isInAgentList = computed<boolean>(() => route.name === 'agentList');
// 是否在组织列表页面
const isInOrganizationList = computed<boolean>(() => route.name === 'organizationList');
// 统一的菜单项激活状态判断
const isMenuItemActive = (itemPath: string): boolean => {
const currentRoute = route.name;
switch (itemPath) {
case 'overview':
return currentRoute === 'overview';
case 'knowledge-bases':
return currentRoute === 'knowledgeBaseList' ||
currentRoute === 'knowledgeBaseDetail' ||
currentRoute === 'knowledgeBaseSettings';
case 'agents':
return currentRoute === 'agentList';
case 'toolbox':
return currentRoute === 'toolbox';
case 'artifacts':
return currentRoute === 'artifactLibrary';
case 'automations':
return currentRoute === 'automationList';
case 'organizations':
return currentRoute === 'organizationList';
case 'org-center':
// 「组织架构」独立路由页(/platform/org-center)
return currentRoute === 'orgCenter';
case 'creatChat':
return currentRoute === 'kbCreatChat' || currentRoute === 'globalCreatChat';
case 'settings':
return currentRoute === 'settings';
default:
// 「企业培训」子项:path 形如 training/<tab>,按路由 tab 参数判断
if (itemPath.startsWith('training/')) {
return isTrainingTabActive(itemPath.slice('training/'.length));
}
return itemPath === currentpath.value;
}
};
// 统一的图标激活状态判断
const getIconActiveState = (itemPath: string) => {
const currentRoute = route.name;
return {
isKbActive: itemPath === 'knowledge-bases' && (
currentRoute === 'knowledgeBaseList' ||
currentRoute === 'knowledgeBaseDetail' ||
currentRoute === 'knowledgeBaseSettings'
),
isCreatChatActive: itemPath === 'creatChat' && (currentRoute === 'kbCreatChat' || currentRoute === 'globalCreatChat'),
isSettingsActive: itemPath === 'settings' && currentRoute === 'settings',
isChatActive: itemPath === 'chat' && currentRoute === 'chat'
};
};
// 分离上下两部分菜单(使用 visibleMenuArr 以便 lite 模式过滤 logout)
// 顶层只保留高频入口;其余收纳进「更多工具」分组,子项按 MORE_TOOLS_ORDER 排列
// 「企业培训」独立为「更多工具」下方的可折叠分组(TRAINING_TABS),不再占用顶层入口
const TOP_MENU_PATHS = new Set(['overview', 'creatChat', 'agents']);
const MORE_TOOLS_ORDER = ['knowledge-bases', 'automations', 'toolbox', 'artifacts'];
const MORE_TOOLS_PATHS = new Set(MORE_TOOLS_ORDER);
// 「配置中心」(原「规则配置」):低频管理入口,收纳进「更多工具」末位(原「共享空间」位置)。
// 点击/高亮复用培训子页逻辑(path 形如 training/<tab>),页面内容仍由 Training 页按角色控制。
const RULES_TOOL_ITEM: MenuItem = { title: '配置中心', icon: 'setting', path: 'training/rules' };
// 「组织架构」:租户级共享组织架构(部门 + 员工档案),企业培训等业务模块按需引用,
// 收纳进「更多工具」末位;独立路由 /platform/org-center。
const ORG_CENTER_TOOL_ITEM: MenuItem = { title: '组织架构', icon: 'organization', path: 'org-center' };
const topMenuItems = computed<MenuItem[]>(() => {
return (visibleMenuArr.value as unknown as MenuItem[]).filter((item: MenuItem) => TOP_MENU_PATHS.has(item.path));
});
const moreToolItems = computed<MenuItem[]>(() => {
// 按 MORE_TOOLS_ORDER 的显式顺序输出;find 自 visibleMenuArr,保留能力/权限过滤
const all = visibleMenuArr.value as unknown as MenuItem[];
const items = MORE_TOOLS_ORDER
.map(path => all.find((item: MenuItem) => item.path === path))
.filter((item): item is MenuItem => !!item);
// 末位固定追加「配置中心」「职称角色」「组织架构」;「共享空间」还原至最底
// (入口定义与显隐规则仍在 menu store:仅空间 admin/owner 可见,随能力清单显隐)
// 职称角色(000159):自「企业培训」分组迁入,置于配置中心之后
const MEMBERS_TOOL_ITEM: MenuItem = { title: '职称角色', icon: 'training', path: 'training/members' };
const orgShareItem = all.find((item: MenuItem) => item.path === 'organizations');
return [...items, RULES_TOOL_ITEM, MEMBERS_TOOL_ITEM, ORG_CENTER_TOOL_ITEM, ...(orgShareItem ? [orgShareItem] : [])];
});
// 菜单图标统一映射:顶层项与「更多工具」子项共用
const iconSrcFor = (icon: string): string => {
switch (icon) {
case 'zhishiku': return knowledgeIcon.value;
case 'agent': return agentIcon.value;
case 'artifact': return artifactIcon.value;
case 'automation': return automationIcon.value;
case 'training': return trainingIcon.value;
case 'toolbox': return toolboxIcon.value;
case 'organization': return organizationIcon.value;
case 'overview': return overviewIcon.value;
case 'logout': return logoutIcon.value;
case 'setting': return settingIcon.value;
default: return prefixIcon.value;
}
};
// 「企业培训」分组:培训管理子页收纳为侧栏子项(与「更多工具」同款交互)。
// 文案与培训页内 tab 保持一致;组织成员由 Training 页内按角色控制内容。
// 「配置中心」已移入「更多工具」末位(RULES_TOOL_ITEM),不再出现在本分组。
const TRAINING_TABS: { key: string; title: string }[] = [
{ key: 'dashboard', title: '培训中心' },
{ key: 'plan', title: '年培训计划' },
{ key: 'course', title: '月培训计划' },
{ key: 'library', title: '课程管理' },
{ key: 'sign', title: '培训签到' },
// 数据驾驶舱(000158):自培训中心页头切换迁入侧栏
{ key: 'data-dashboard', title: '数据驾驶舱' },
// 职称角色(000159):迁至「更多工具」分组、配置中心之后(角色权限口径)
];
const TRAINING_GROUP_TITLE = '企业培训';
// 分组展开状态(记忆用户偏好,默认展开),交互与「更多工具」一致
const TRAINING_OPEN_KEY = 'academy_training_open';
const trainingOpen = ref(localStorage.getItem(TRAINING_OPEN_KEY) !== 'false');
const toggleTraining = () => {
trainingOpen.value = !trainingOpen.value;
localStorage.setItem(TRAINING_OPEN_KEY, String(trainingOpen.value));
};
const handleTrainingClick = () => {
// 折叠态下点击:先展开侧边栏再打开分组,避免子项无处显示
if (uiStore.sidebarCollapsed) {
if (!trainingOpen.value) toggleTraining();
uiStore.toggleSidebar();
return;
}
toggleTraining();
};
// 当前路由处于培训子页时,折叠态下高亮「企业培训」图标入口
const trainingActive = computed(() => route.name === 'training' || route.name === 'trainingTab');
// 培训子项激活判断:路由名 trainingTab 且 tab 参数一致;/platform/training 视为工作台
const isTrainingTabActive = (tab: string): boolean => {
if (route.name !== 'trainingTab' && route.name !== 'training') return false;
return (String(route.params.tab || 'dashboard')) === tab;
};
// 「更多工具」分组展开状态(记忆用户偏好,默认展开)
const MORE_TOOLS_OPEN_KEY = 'academy_moretools_open';
const moreToolsOpen = ref(localStorage.getItem(MORE_TOOLS_OPEN_KEY) !== 'false');
const toggleMoreTools = () => {
moreToolsOpen.value = !moreToolsOpen.value;
localStorage.setItem(MORE_TOOLS_OPEN_KEY, String(moreToolsOpen.value));
};
const handleMoreToolsClick = () => {
// 折叠态下点击:先展开侧边栏再打开分组,避免子项无处显示
if (uiStore.sidebarCollapsed) {
if (!moreToolsOpen.value) toggleMoreTools();
uiStore.toggleSidebar();
return;
}
toggleMoreTools();
};
// 分组内任一子项处于激活路由时,折叠态下高亮「更多工具」图标入口
const moreToolsActive = computed(() => moreToolItems.value.some((item: MenuItem) => isMenuItemActive(item.path)));
// 「AI对话」停靠模式(图二交互):进入对话相关路由即请求面板;侧栏收起为图标栏时,
// 面板停靠在其右侧。点击「AI对话」会同时收起侧栏(见 handleMenuClick),离开对话路由自动退出。
const CHAT_DOCK_ROUTE_NAMES = new Set(['globalCreatChat', 'kbCreatChat', 'chat']);
const chatDockRequested = ref(false);
watch(() => route.name, (name) => {
chatDockRequested.value = CHAT_DOCK_ROUTE_NAMES.has(String(name || ''));
}, { immediate: true });
const chatDockOpen = computed(() => chatDockRequested.value && uiStore.sidebarCollapsed);
watch(chatDockOpen, (open) => {
if (!open) return;
// 面板挂载后补一次滚动探测:列表未撑满视口时自动续页
void ensureBucketFillsViewport(activeSessionBucketKey.value);
void refreshSessionListScrollability();
});
const bottomMenuItems = computed<MenuItem[]>(() => {
return (visibleMenuArr.value as unknown as MenuItem[]).filter((item: MenuItem) => !TOP_MENU_PATHS.has(item.path));
});
// 当前知识库信息
const currentKbName = ref<string>('')
const currentKbInfo = ref<any>(null)
// 进行中的置顶/取消置顶请求,避免重复点击
const pinningIds = ref<Set<string>>(new Set())
// 「聊天」区内按日期分组(当前筛选来源)
const dateBucketLabels = computed<Record<DateBucketKey, string>>(() => ({
pinned: t('time.pinned'),
today: t('time.today'),
yesterday: t('time.yesterday'),
last7Days: t('time.last7Days'),
last30Days: t('time.last30Days'),
lastYear: t('time.lastYear'),
earlier: t('time.earlier'),
}));
const filteredGroupedSessions = computed(() => {
const bucket = activeBucket.value;
if (!bucket?.items.length) return [];
return groupSessionsByDate(
bucket.items.map((item) => ({
...item,
path: `chat/${item.id}`,
title: item.title || '',
})),
dateBucketLabels.value,
(session) => classifyDateBucket(session.updated_at || session.created_at),
);
});
// Only a locally created fork requests attention; loading history and switching
// between existing sessions must not replay the entrance animation.
const pendingForkRevealId = ref('');
const revealedSessionId = ref('');
let forkRevealTimer: ReturnType<typeof setTimeout> | undefined;
usemenuStore.$onAction(({ name, args, after }) => {
if (name !== 'updataMenuChildren' || !args[0]?.parent_session_id) return;
const sessionId = String(args[0].id);
after(() => { pendingForkRevealId.value = sessionId; });
});
watch(
() => {
const id = pendingForkRevealId.value;
return id && !uiStore.sidebarCollapsed && currentSecondpath.value === `chat/${id}`
&& filteredGroupedSessions.value.some((group) => group.items.some((item) => item.id === id))
? id : '';
},
(id) => {
if (!id) return;
const container = scrollContainer.value;
const row = Array.from(container?.querySelectorAll<HTMLElement>('[data-session-id]') ?? [])
.find((element) => element.dataset.sessionId === id);
if (!container || !row) return;
// Reveal within the sidebar only, without moving the conversation pane.
const bounds = container.getBoundingClientRect();
const rowBounds = row.getBoundingClientRect();
if (rowBounds.top < bounds.top) container.scrollTop += rowBounds.top - bounds.top;
else if (rowBounds.bottom > bounds.bottom) container.scrollTop += rowBounds.bottom - bounds.bottom;
clearTimeout(forkRevealTimer);
revealedSessionId.value = id;
pendingForkRevealId.value = '';
forkRevealTimer = setTimeout(() => { revealedSessionId.value = ''; }, 350);
},
{ flush: 'post' },
);
const refreshSessionListScrollability = async () => {
await nextTick();
const container = scrollContainer.value;
sessionListCanScroll.value = !!container && container.scrollHeight > container.clientHeight + 1;
};
/** 列表未撑满滚动区时自动续页(按当前可见 DOM 测量,避免折叠导致误判) */
const ensureBucketFillsViewport = async (key: string) => {
const MAX_ITERATIONS = 20;
for (let i = 0; i < MAX_ITERATIONS; i++) {
await nextTick();
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()));
const container = scrollContainer.value;
const bucket = sessionBuckets.value[key];
if (!container || !bucket || !bucketHasMore(bucket) || bucket.loading) break;
const hasOverflow = container.scrollHeight > container.clientHeight + 1;
if (hasOverflow) break;
const prevCount = bucket.items.length;
await loadBucketPage(key);
if ((sessionBuckets.value[key]?.items.length ?? 0) <= prevCount) break;
}
};
const mouseenteBotDownr = (val: string) => {
activeSubmenu.value = val;
}
const mouseleaveBotDown = () => {
activeSubmenu.value = '';
}
const enterBatchMode = () => {
batchMode.value = true
batchSelectedIds.value = []
}
const exitBatchMode = () => {
batchMode.value = false
batchSelectedIds.value = []
}
const toggleBatchSelect = (id: string) => {
const idx = batchSelectedIds.value.indexOf(id)
if (idx > -1) {
batchSelectedIds.value.splice(idx, 1)
} else {
batchSelectedIds.value.push(id)
}
}
const toggleBatchSelectAll = (checked: boolean) => {
batchSelectedIds.value = checked ? [...allSessionIds.value] : []
}
const handleInlineBatchDelete = () => {
if (batchSelectedIds.value.length === 0) return
const isDeleteAll = isAllBatchSelected.value
const displayCount = batchDisplayCount.value
const confirmDialog = DialogPlugin.confirm({
header: t('batchManage.deleteConfirmTitle'),
body: isDeleteAll
? t('batchManage.deleteAllConfirmBody') || t('batchManage.deleteConfirmBody', { count: displayCount })
: t('batchManage.deleteConfirmBody', { count: displayCount }),
confirmBtn: { content: t('batchManage.delete'), theme: 'danger' as const },
cancelBtn: t('batchManage.cancel'),
theme: 'warning',
onConfirm: async () => {
batchDeleting.value = true
try {
let res: any
if (isDeleteAll) {
res = await deleteAllSessions()
} else {
res = await batchDelSessions([...batchSelectedIds.value])
}
if (res && res.success === true) {
if (isDeleteAll) {
usemenuStore.clearMenuArr();
total.value = 0;
await getMessageList();
} else {
let next = sessionBuckets.value;
for (const id of batchSelectedIds.value) {
next = removeSessionFromBuckets(next, id);
}
sessionBuckets.value = next;
syncMenuStoreFromBuckets();
}
const currentChatId = route.params.chatid as string;
if (currentChatId && (isDeleteAll || batchSelectedIds.value.includes(currentChatId))) {
router.push('/platform/creatChat');
}
batchSelectedIds.value = []
MessagePlugin.success(t('batchManage.deleteSuccess'))
exitBatchMode()
} else {
MessagePlugin.error(t('batchManage.deleteFailed'))
}
} catch {
MessagePlugin.error(t('batchManage.deleteFailed'))
}
batchDeleting.value = false
confirmDialog.destroy()
},
})
}
const handleSessionMenuClick = (data: { value: string }, item: any) => {
if (data?.value === 'delete') {
delCard(item);
} else if (data?.value === 'clearMessages') {
clearMessages(item);
} else if (data?.value === 'batchManage') {
enterBatchMode()
} else if (data?.value === 'pin' || data?.value === 'unpin') {
togglePin(item, data.value === 'pin');
}
};
// 基于会话来源推导展示用的短标签已经被 platformLogo(<img>) 取代,Web 会话没有图标。
const buildSessionMenuOptions = (item: any) => {
const options: any[] = [];
if (item.is_pinned) {
options.push({
content: t('menu.unpin'),
value: 'unpin',
prefixIcon: () => h(TIcon, { name: 'pin-filled' }),
});
} else {
options.push({
content: t('menu.pin'),
value: 'pin',
prefixIcon: () => h(TIcon, { name: 'pin' }),
});
}
options.push(
{ content: t('menu.renameSession'), value: 'rename', prefixIcon: () => h(TIcon, { name: 'edit-1' }) },
{ content: t('menu.clearMessages'), value: 'clearMessages', prefixIcon: () => h(TIcon, { name: 'clear' }) },
{ content: t('menu.batchManage'), value: 'batchManage', prefixIcon: () => h(TIcon, { name: 'queue' }) },
{ content: t('upload.deleteRecord'), value: 'delete', theme: 'error', prefixIcon: () => h(TIcon, { name: 'delete' }) },
);
return options;
};
const updateSessionInBuckets = (
sessionId: string,
patch: Partial<{ is_pinned: boolean; pinned_at: string | null; title: string; isNoTitle?: boolean }>,
) => {
const next: Record<string, SidebarSessionBucket> = {};
for (const [key, bucket] of Object.entries(sessionBuckets.value)) {
next[key] = {
...bucket,
items: bucket.items.map((row) => (row.id === sessionId ? { ...row, ...patch } : row)),
};
}
sessionBuckets.value = next;
syncMenuStoreFromBuckets();
};
const renameSessionTitle = async (item: any, title: string) => {
try {
await renameSession(item.id, title, item.description || '');
MessagePlugin.success(t('menu.renameSessionSuccess'));
} catch {
MessagePlugin.error(t('menu.renameSessionFailed'));
}
};
const togglePin = (item: any, pin: boolean) => {
if (pinningIds.value.has(item.id)) return;
pinningIds.value.add(item.id);
setSessionPinned(item.id, pin).catch(() => {
MessagePlugin.error(pin ? t('menu.pinFailed') : t('menu.unpinFailed'));
}).finally(() => {
pinningIds.value.delete(item.id);
});
};
const clearMessages = (item: any) => {
clearSession(item.id).then(() => {
MessagePlugin.success(t('menu.clearMessagesSuccess'));
}).catch(() => {
MessagePlugin.error(t('menu.clearMessagesFailed'));
});
};
const delCard = (item: any) => {
removeSession(item.id).catch(() => MessagePlugin.error(t('chat.deleteSessionFailed')))
}
const debounce = (fn: (...args: any[]) => void, delay: number) => {
let timer: ReturnType<typeof setTimeout>
return (...args: any[]) => {
clearTimeout(timer)
timer = setTimeout(() => fn(...args), delay)
}
}
const mapSessionRow = (item: any) => ({
title: item.title ? item.title : t('menu.newSession'),
path: `chat/${item.id}`,
id: item.id,
isMore: false,
isNoTitle: item.title ? false : true,
created_at: item.created_at,
updated_at: item.updated_at,
is_pinned: !!item.is_pinned,
pinned_at: item.pinned_at || null,
im_platform: item.im_platform || '',
description: item.description || '',
user_id: item.user_id || '',
parent_session_id: item.parent_session_id || '',
});
const syncMenuStoreFromBuckets = () => {
usemenuStore.clearMenuArr();
const flat = flattenBucketItems(sessionBuckets.value, bucketOrder.value);
flat.forEach((item) => usemenuStore.updatemenuArr(item));
total.value = flat.length;
};
const menuChildToSessionRow = (item: Record<string, unknown>): SessionForGrouping & { path: string } => {
const id = String(item.id);
return {
id,
path: typeof item.path === 'string' ? item.path : `chat/${id}`,
title: typeof item.title === 'string' ? item.title : undefined,
is_pinned: !!item.is_pinned,
created_at: typeof item.created_at === 'string' ? item.created_at : undefined,
updated_at: typeof item.updated_at === 'string' ? item.updated_at : undefined,
im_platform: typeof item.im_platform === 'string' ? item.im_platform : '',
description: typeof item.description === 'string' ? item.description : '',
user_id: typeof item.user_id === 'string' ? item.user_id : '',
parent_session_id: typeof item.parent_session_id === 'string' ? item.parent_session_id : '',
};
};
const sessionExistsInBuckets = (sessionId: string) =>
Object.values(sessionBuckets.value).some((bucket) => bucket.items.some((row) => row.id === sessionId));
/** 创建会话后 menuStore 已乐观写入,但列表实际渲染自 sessionBuckets,需补齐。 */
const ensureSessionInSidebar = (sessionId: string) => {
if (!sessionId || sessionExistsInBuckets(sessionId)) return;
const web = sessionBuckets.value.web;
if (!web) return;
const chatMenu = (menuArr.value as unknown as MenuItem[]).find((item) => item.path === 'creatChat');
const fromStore = (chatMenu?.children as Record<string, unknown>[] | undefined)
?.find((item) => item.id === sessionId);
if (!fromStore) return;
sessionBuckets.value = {
...sessionBuckets.value,
web: prependSessionToWebBucket(web, menuChildToSessionRow(fromStore)),
};
total.value = flattenBucketItems(sessionBuckets.value, bucketOrder.value).length;
};
const rebuildBucketDefinitions = () => buildBucketDefinitions(
imPlatforms.value,
embedChannelNames.value,
{
web: t('menu.myChats'),
imPlatform: (platform) => t(`agentEditor.im.${platform}`),
embedChannel: (name) => name,
api: t('menu.apiChats'),
},
{ includeAdminChannelBuckets: authStore.hasRole('admin') },
);
/** 首屏轻量探测各渠道是否有会话(page_size=1 只取 total),避免展示空文件夹 */
const probeChannelBucketCounts = async (keys: string[], token: number) => {
const targets = keys.filter((key) => isChannelBucketKey(key));
await Promise.all(
targets.map(async (key) => {
const bucket = sessionBuckets.value[key];
if (!bucket) return;
try {
const res: any = await getSessionsList(1, 1, bucket.apiSource);
if (token !== bucketRequestToken) return;
sessionBuckets.value = {
...sessionBuckets.value,
[key]: applyBucketCountProbe(bucket, res?.total ?? 0),
};
} catch {
if (token !== bucketRequestToken) return;
sessionBuckets.value = {
...sessionBuckets.value,
[key]: applyBucketCountProbe(bucket, 0),
};
}
}),
);
};
const loadBucketPage = async (key: string, page?: number, token?: number) => {
const activeToken = token ?? bucketRequestToken;
const bucket = sessionBuckets.value[key];
if (!bucket || bucket.loading) return;
const nextPage = page ?? bucket.page + 1;
sessionBuckets.value = {
...sessionBuckets.value,
[key]: { ...bucket, loading: true },
};
try {
const res: any = await getSessionsList(nextPage, SIDEBAR_BUCKET_PAGE_SIZE, bucket.apiSource);
if (activeToken !== bucketRequestToken) return;
const rows = (res?.data || []).map((item: any) => mapSessionRow(item));
const current = sessionBuckets.value[key];
sessionBuckets.value = {
...sessionBuckets.value,
[key]: mergeBucketPage(current, rows, res?.total ?? rows.length, nextPage),
};
syncMenuStoreFromBuckets();
await refreshSessionListScrollability();
} catch {
if (activeToken !== bucketRequestToken) return;
const current = sessionBuckets.value[key];
sessionBuckets.value = {
...sessionBuckets.value,
[key]: { ...current, loading: false, loaded: true },
};
}
};
const switchSessionBucket = async (key: string) => {
if (key === activeSessionBucketKey.value) return;
activeSessionBucketKey.value = key;
const bucket = sessionBuckets.value[key];
if (bucket && !bucket.loaded && !bucket.loading) {
await loadBucketPage(key, 1);
}
await ensureBucketFillsViewport(key);
await refreshSessionListScrollability();
};
const syncActiveBucketFromChat = async (sessionId: string | undefined) => {
if (!sessionId) return;
let bucketKey = findSessionBucketKey(sessionBuckets.value, sessionId);
if (!bucketKey) {
const chatMenu = (menuArr.value as unknown as MenuItem[]).find((item) => item.path === 'creatChat');
const fromStore = (chatMenu?.children as Record<string, unknown>[] | undefined)
?.find((item) => item.id === sessionId);
if (fromStore) {
bucketKey = originGroupKey(resolveSessionOrigin(menuChildToSessionRow(fromStore)));
}
}
// On a hard refresh only the web bucket is loaded, so a session opened from
// any other folder (IM, embed, or the admin-only API folder) isn't in any
// bucket or the menu store. Fetch its detail and classify its origin folder
// so the sidebar stays in sync with the chat pane instead of snapping back
// to "my chats". Only switch when that folder is actually present.
if (!bucketKey) {
try {
const res: any = await getSession(sessionId);
const candidate = originGroupKey(resolveSessionOrigin({
id: sessionId,
im_platform: res?.data?.im_platform || '',
description: res?.data?.description || '',
user_id: res?.data?.user_id || '',
}));
if (sessionBuckets.value[candidate]) {
bucketKey = candidate;
}
} catch {
// Fall through: leave the default bucket active on lookup failure.
}
}
if (!bucketKey || bucketKey === activeSessionBucketKey.value) return;
activeSessionBucketKey.value = bucketKey;
const bucket = sessionBuckets.value[bucketKey];
if (bucket && !bucket.loaded && !bucket.loading) {
await loadBucketPage(bucketKey, 1);
}
};
const initSessionBuckets = async () => {
const token = ++bucketRequestToken;
sessionListBooting.value = true;
const defs = rebuildBucketDefinitions();
bucketOrder.value = defs.map((def) => def.key);
const buckets: Record<string, SidebarSessionBucket> = {};
for (const def of defs) {
buckets[def.key] = createEmptyBucket(def);
}
sessionBuckets.value = buckets;
// 首屏:拉 web 会话 + 轻量探测各渠道 count(不拉完整列表);有会话的渠道才展示文件夹
const channelKeys = defs.map((def) => def.key).filter((key) => isChannelBucketKey(key));
await Promise.all([
loadBucketPage('web', 1, token),
probeChannelBucketCounts(channelKeys, token),
]);
if (token === bucketRequestToken) {
sessionListBooting.value = false;
syncMenuStoreFromBuckets();
await ensureBucketFillsViewport('web');
await refreshSessionListScrollability();
}
};
const getMessageList = async () => {
await initSessionBuckets();
};
// 滚动到底时为当前筛选来源加载下一页
const checkScrollBottom = async () => {
const container = scrollContainer.value;
const key = activeSessionBucketKey.value;
const bucket = sessionBuckets.value[key];
if (!container || !bucket || !bucketHasMore(bucket) || bucket.loading) return;
const { scrollTop, scrollHeight, clientHeight } = container;
const hasOverflow = scrollHeight > clientHeight + 1;
if (!hasOverflow) {
await ensureBucketFillsViewport(key);
return;
}
const isNearBottom = scrollHeight - (scrollTop + clientHeight) < 100;
if (!isNearBottom) return;
await loadBucketPage(key);
};
const handleScroll = debounce(checkScrollBottom, 200);
async function loadCurrentKbInfo(kbId: string) {
if (!kbId || !isInKnowledgeBase.value) {
currentKbName.value = ''
currentKbInfo.value = null
return
}
const data = await chatResources.fetchKnowledgeBaseById(kbId)
if (data) {
currentKbName.value = data.name || ''
currentKbInfo.value = data
} else {
currentKbInfo.value = null
}
}
const loadSessionOriginMeta = async () => {
try {
const res: any = await listAllIMChannels();
imPlatforms.value = configuredPlatforms(res?.data || []);
} catch {
imPlatforms.value = [];
}
try {
const res: any = await listAllEmbedChannels();
const names: Record<string, string> = {};
for (const ch of res?.data || []) {
if (ch?.id && ch?.name) names[ch.id] = ch.name;
}
embedChannelNames.value = names;
} catch {
embedChannelNames.value = {};
}
};
const handleSessionMutation = (event: Event) => {
const detail = (event as CustomEvent<SessionMutationDetail>).detail;
if (!detail?.sessionId) return;
if (detail.removed || detail.messagesCleared) sessionActivity.dismiss(detail.sessionId);
if (detail.patch) {
updateSessionInBuckets(detail.sessionId, {
...detail.patch,
...(detail.patch.title ? { isNoTitle: false } : {}),
});
}
if (detail.removed) {
sessionBuckets.value = removeSessionFromBuckets(sessionBuckets.value, detail.sessionId);
syncMenuStoreFromBuckets();
if (detail.sessionId === route.params.chatid) {
router.push('/platform/creatChat');
}
}
};
onMounted(async () => {
sessionActivity.restore();
void sessionActivity.refresh();
sessionActivityTimer = setInterval(() => { void sessionActivity.refresh(); }, 5000);
const routeName = typeof route.name === 'string' ? route.name : (route.name ? String(route.name) : '')
currentpath.value = routeName;
if (route.params.chatid) {
currentSecondpath.value = `chat/${route.params.chatid}`;
}
window.addEventListener(SESSION_MUTATION_EVENT, handleSessionMutation);
isLiteEdition.value = authStore.isLiteMode
editorResources.ensureSystemInfo().then(() => {
if (editorResources.systemInfo?.edition === 'lite') {
isLiteEdition.value = true
authStore.setLiteMode(true)
}
}).catch(() => { })
await loadCurrentKbInfo((route.params as any)?.kbId as string)
await loadSessionOriginMeta();
await getMessageList();
const initialChatId = route.params.chatid as string | undefined;
if (initialChatId) {
ensureSessionInSidebar(initialChatId);
await syncActiveBucketFromChat(initialChatId);
}
// 若组织列表未加载则拉取一次,用于侧栏「待审批」角标
if (deploymentCapabilities.isSupported('organizations') && orgStore.organizations.length === 0) {
orgStore.fetchOrganizations();
}
});
onUnmounted(() => {
clearInterval(sessionActivityTimer);
clearTimeout(forkRevealTimer);
sessionActivity.clear();
window.removeEventListener(SESSION_MUTATION_EVENT, handleSessionMutation);
});
watch([() => route.name, () => route.params], (newvalue, oldvalue) => {
const nameStr = typeof newvalue[0] === 'string' ? (newvalue[0] as string) : (newvalue[0] ? String(newvalue[0]) : '')
currentpath.value = nameStr;
if (newvalue[1].chatid) {
currentSecondpath.value = `chat/${newvalue[1].chatid}`;
} else {
currentSecondpath.value = "";
}
// 创建新会话时 creatChat 会先 updataMenuChildren,再跳转 chat/:id。
// 侧栏实际渲染 sessionBuckets,需按 buckets 判断是否缺失,不能把 menuStore 当真相来源。
const newChatId = (newvalue[1] as any)?.chatid as string | undefined;
if (nameStr === 'chat' && newChatId) {
ensureSessionInSidebar(newChatId);
void syncActiveBucketFromChat(newChatId);
}
// 路由变化时更新图标状态和知识库信息(不涉及对话列表)
getIcon(nameStr);
// 如果切换了知识库,更新知识库名称但不重新加载对话列表
if (newvalue[1].kbId !== oldvalue?.[1]?.kbId) {
loadCurrentKbInfo((newvalue[1] as any)?.kbId as string);
}
});
let knowledgeIcon = ref('zhishiku-green.svg');
let prefixIcon = ref('prefixIcon.svg');
let logoutIcon = ref('logout.svg');
let settingIcon = ref('setting.svg');
let agentIcon = ref('agent.svg');
let artifactIcon = ref('artifact.svg');
let toolboxIcon = ref('toolbox.svg');
let automationIcon = ref('automation.svg');
let trainingIcon = ref('training.svg');
let organizationIcon = ref('organization.svg');
let overviewIcon = ref('overview.svg');
let pathPrefix = ref(route.name)
const getIcon = (path: string) => {
// 根据当前路由状态更新所有图标
const kbActiveState = getIconActiveState('knowledge-bases');
const creatChatActiveState = getIconActiveState('creatChat');
const settingsActiveState = getIconActiveState('settings');
const agentsActiveState = route.name === 'agentList';
const artifactsActiveState = route.name === 'artifactLibrary';
const organizationsActiveState = route.name === 'organizationList';
// 知识库图标:只在知识库页面显示绿色
knowledgeIcon.value = kbActiveState.isKbActive ? 'zhishiku-green.svg' : 'zhishiku.svg';
// 智能体图标:只在智能体页面显示绿色
agentIcon.value = agentsActiveState ? 'agent-green.svg' : 'agent.svg';
// 产物图标:只在产物页面显示绿色
artifactIcon.value = artifactsActiveState ? 'artifact-green.svg' : 'artifact.svg';
toolboxIcon.value = route.name === 'toolbox' ? 'toolbox-green.svg' : 'toolbox.svg';
automationIcon.value = route.name === 'automationList' ? 'automation-green.svg' : 'automation.svg';
// 组织图标:只在组织页面显示绿色
organizationIcon.value = organizationsActiveState ? 'organization-green.svg' : 'organization.svg';
// 对话图标:只在对话创建页面显示绿色,其他情况显示默认
prefixIcon.value = creatChatActiveState.isCreatChatActive ? 'prefixIcon-green.svg' : 'prefixIcon.svg';
// 设置图标:只在设置页面显示绿色
settingIcon.value = settingsActiveState.isSettingsActive ? 'setting-green.svg' : 'setting.svg';
// 退出图标:始终显示默认
logoutIcon.value = 'logout.svg';
}
getIcon(typeof route.name === 'string' ? route.name as string : (route.name ? String(route.name) : ''))
const handleMenuClick = async (path: string) => {
if (path === 'overview') {
// 概览页:汇总知识资产与使用概况
router.push('/platform/overview')
} else if (path === 'knowledge-bases') {
// 知识库菜单项:如果在知识库内部,跳转到当前知识库文件页;否则跳转到知识库列表
const kbId = await getCurrentKbId()
if (kbId) {
router.push(`/platform/knowledge-bases/${kbId}`)
} else {
router.push('/platform/knowledge-bases')
}
} else if (path === 'agents') {
router.push('/platform/agents')
} else if (path === 'organizations') {
// 组织菜单项:跳转到组织列表
router.push('/platform/organizations')
} else if (path === 'settings') {
// 设置菜单项:打开设置弹窗并跳转路由
uiStore.openSettings()
router.push('/platform/settings')
} else {
// 点击「AI对话」:侧栏收起为图标栏,聊天记录停靠面板在其右侧展开。
// 立即置位面板请求,让宽度从当前值一次过渡到「图标栏+面板」总宽,避免两次跳动。
if (path === 'creatChat') {
chatDockRequested.value = true;
if (!uiStore.sidebarCollapsed) {
uiStore.collapseSidebar();
}
}
gotopage(path);
}
}
// 处理退出登录确认
const handleLogout = () => {
gotopage('logout')
}
const getCurrentKbId = async (): Promise<string | null> => {
const kbId = (route.params as any)?.kbId as string
if (isInKnowledgeBase.value && kbId) {
return kbId
}
return null
}
const gotopage = async (path: string) => {
pathPrefix.value = path;
// 处理退出登录
if (path === 'logout') {
try {
// 调用后端API注销
await logoutApi();
} catch (error) {
// 即使API调用失败,也继续执行本地清理
console.error('注销API调用失败:', error);
}
// 清理所有状态和本地存储
authStore.logout();
MessagePlugin.success(t('menu.logoutSuccess'));
router.push('/login');
return;
} else {
if (path === 'creatChat') {
// 如果在知识库详情页,跳转到全局对话创建页
if (isInKnowledgeBase.value) {
router.push('/platform/creatChat')
} else {
// 如果不在知识库内,进入对话创建页
router.push(`/platform/creatChat`)
}
} else {
router.push(`/platform/${path}`);
}
}
getIcon(path)
}
const getImgSrc = (url: string) => {
return new URL(`/src/assets/img/${url}`, import.meta.url).href;
}
const mouseenteMenu = (path: string) => {
}
const mouseleaveMenu = (path: string) => {
}
let sidebarResizeStartWidth = 0
const startSidebarResize = () => {
sidebarResizeStartWidth = uiStore.sidebarDisplayWidth
uiStore.sidebarResizing = true
}
const resizeSidebar = (delta: number, keyboard: boolean) => {
if (keyboard && uiStore.sidebarCollapsed && delta > 0) {
uiStore.expandSidebar()
} else if (keyboard && uiStore.sidebarWidth === SIDEBAR_MIN_WIDTH && delta < 0) {
uiStore.collapseSidebar()
} else {
uiStore.resizeSidebar(sidebarResizeStartWidth + delta)
}
}
</script>
<style lang="less" scoped>
.aside_box {
// 侧栏水平栅格:图标列与文案列统一对齐(Logo / 菜单 / 会话分组 / 会话行)
--sidebar-inset-x: 10px;
--sidebar-icon-size: 18px;
--sidebar-channel-icon: 14px;
--sidebar-icon-gap: 8px;
--sidebar-text-inset: calc(var(--sidebar-inset-x) + var(--sidebar-icon-size) + var(--sidebar-icon-gap)); // 36px
min-width: 0;
width: var(--sidebar-width, 260px);
flex-shrink: 0;
// 内边距移到 .aside_rail / .chat_dock_panel,停靠面板不被根容器内边距挤占
padding: 0;
background: var(--td-bg-color-sidebar);
box-sizing: border-box;
/* Avoid 100vh because <html> carries a `zoom` multiplier for font-size
control; 100vh is evaluated against the unscaled viewport and then
scaled, so at "large" the sidebar would extend past the window. The
ancestor chain (html/body/#app/.main) is already height: 100%. */
height: 100%;
overflow: visible;
display: flex;
flex-direction: row;
border-right: 1px solid var(--td-component-stroke);
box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
transition: width 0.25s ease, min-width 0.25s ease;
position: relative;
// macOS Wails 桌面:红绿灯位于 HiddenInset 标题栏区域,需让出顶部空间
html.wails-desktop & {
padding-top: 30px;
}
// 左列:图标栏(收起态)/ 展开侧栏;「AI对话」停靠面板打开时固定为图标栏宽度
.aside_rail {
flex: 1 1 auto;
min-width: 0;
height: 100%;
display: flex;
flex-direction: column;
padding: 8px 4px 6px;
box-sizing: border-box;
}
&--resizing {
transition: none;
}
&.aside_box--collapsed {
min-width: 48px;
width: 48px;
overflow: visible;
.aside_rail {
padding: 8px 0;
}
.menu_box {
align-items: center;
}
.menu_item {
justify-content: center;
width: 32px;
height: 32px;
padding: 0;
margin: 0 auto 6px;
border-radius: var(--app-radius-sm);
.menu_item-box {
justify-content: center;
width: auto;
}
.menu_icon {
margin-right: 0;
justify-content: center;
}
}
.menu_item_active {
border-radius: var(--app-radius-sm);
}
.menu_bottom {
align-items: center;
}
.menu_top {
margin-right: 0;
padding-right: 0;
}
}
// 「AI对话」停靠模式:图标栏(48px) + 聊天记录面板(204px) 的总宽度;
// 需写在 --collapsed 之后以覆盖其宽度
&.aside_box--chat-dock {
min-width: 252px;
width: 252px;
}
.logo_row {
display: flex;
align-items: center;
justify-content: space-between;
// 保留侧栏顶部留白,让 Logo 和操作按钮与窗口顶边保持舒适间距
height: 39px;
margin: 0 0 4px;
flex-shrink: 0;
padding: 0 2px 0 var(--sidebar-inset-x);
}
.sidebar-toggle {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
flex-shrink: 0;
cursor: pointer;
color: var(--td-text-color-secondary);
border-radius: var(--app-radius-xs);
transition: background-color var(--app-motion-base) ease;
box-sizing: border-box;
&:hover {
background: var(--td-bg-color-container-hover);
color: var(--td-text-color-primary);
}
}
.logo_box {
display: flex;
align-items: center;
flex: 1;
min-width: 0;
overflow: hidden;
.logo {
width: 108px;
height: auto;
}
.lite-badge {
margin-left: 2px;
align-self: flex-start;
margin-top: 2px;
font-size: 9px;
font-weight: 600;
color: var(--td-text-color-placeholder);
user-select: none;
white-space: nowrap;
}
}
.menu_top {
// 导航区撑满剩余高度(聊天记录已移至「AI对话」停靠面板)
flex: 1 1 auto;
display: flex;
flex-direction: column;
overflow-y: auto;
overflow-x: hidden;
min-height: 0;
// 抵消 .aside_box 的右内边距,让滚动条贴近面板右缘;
// 等量 padding 补回,保证列表文字位置不变。
margin-right: -4px;
padding-right: 4px;
// Claude 风格细滚动条:默认透明,悬浮时显示一条圆角细灰条
scrollbar-width: thin;
scrollbar-color: transparent transparent;
transition: scrollbar-color var(--app-motion-base) ease;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background: transparent;
}
&::-webkit-scrollbar-thumb {
background-color: transparent;
border-radius: var(--app-radius-sm);
transition: background-color var(--app-motion-base) ease;
}
&:hover {
scrollbar-color: var(--td-scrollbar-color) transparent;
&::-webkit-scrollbar-thumb {
background-color: var(--td-scrollbar-color);
}
}
&::-webkit-scrollbar-thumb:hover {
background-color: var(--td-scrollbar-hover-color);
}
}
.menu_bottom {
flex-shrink: 0;
display: flex;
flex-direction: column;
}
// 「AI对话」停靠面板:图标栏右侧的聊天记录面板(独立滚动)
.chat_dock_panel {
flex: 0 0 204px;
width: 204px;
min-width: 0;
display: flex;
flex-direction: column;
box-sizing: border-box;
overflow: hidden;
border-left: 1px solid var(--td-component-stroke);
background: var(--td-bg-color-sidebar);
padding: 10px 6px 6px;
}
// 面板头部:分区标题(AI对话)+ 新对话按钮 + 聊天记录/搜索行
.history_section_title {
flex-shrink: 0;
padding: 0 2px 10px;
font-family: var(--app-font-family);
font-size: var(--app-text-md);
font-weight: 600;
color: var(--td-brand-color);
user-select: none;
}
.history_new_chat_btn {
flex-shrink: 0;
display: flex;
align-items: center;
gap: 4px;
height: 34px;
padding: 0 10px;
margin: 0 0 10px;
box-sizing: border-box;
border: 1px solid var(--td-component-stroke);
border-radius: var(--app-radius-sm);
background: var(--td-bg-color-container);
cursor: pointer;
transition: background-color var(--app-motion-base) ease;
&:hover {
background: var(--td-bg-color-container-hover);
}
.history_new_chat_text {
font-family: var(--app-font-family);
font-size: var(--app-text-base);
font-weight: 500;
color: var(--td-text-color-primary);
white-space: nowrap;
}
}
.history_header_row {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 0 6px;
.history_header_label {
font-family: var(--app-font-family);
font-size: var(--app-text-sm);
font-weight: 500;
color: var(--td-text-color-secondary);
user-select: none;
}
}
.menu_box {
display: flex;
flex-direction: column;
// 「新对话」吸顶:作为滚动容器(.menu_top)的直接子级,滚动时钉在顶部,
// 知识库/智能体/共享空间及历史列表一起从其下方滚走。背景遮挡滚动内容。
&--sticky {
position: sticky;
top: 0;
z-index: 2;
background: var(--td-bg-color-sidebar);
}
// 「更多工具」分组:父行 + 可展开子项
&--moretools {
.moretools-chevron {
flex-shrink: 0;
color: var(--td-text-color-secondary);
transition: transform var(--app-motion-base) ease;
&.is-open {
transform: rotate(180deg);
}
}
}
}
// 「更多工具」子项:相对父级缩进,视觉上归属分组
.moretools_children {
display: flex;
flex-direction: column;
padding-bottom: 2px;
.menu_item--child {
height: 32px;
padding-left: calc(var(--sidebar-inset-x) + 16px);
}
}
// 「企业培训」子项:无图标,用小圆点占位标记层级,文案缩进深于父级标题
.menu_box--training {
.training-child-dot {
flex: 0 0 auto;
width: 5px;
height: 5px;
margin-right: 12px;
border-radius: 50%;
background: var(--td-text-color-placeholder);
transition: background-color var(--app-motion-base) ease;
}
.menu_item:hover .training-child-dot,
.menu_item_active .training-child-dot {
background: var(--td-brand-color);
}
}
.active-upload {
color: var(--td-brand-color);
}
.menu_item_active {
border-radius: var(--app-radius-xs);
background: var(--td-bg-color-secondarycontainer) !important;
.menu_icon,
.menu_title {
color: var(--td-brand-color) !important;
}
}
.menu_item_c_active {
.menu_icon,
.menu_title {
color: var(--td-text-color-primary);
}
}
.menu_item {
cursor: pointer;
display: flex;
align-items: center;
justify-content: space-between;
height: 34px;
padding: 6px 8px 6px var(--sidebar-inset-x);
box-sizing: border-box;
margin-bottom: 1px;
border-radius: var(--app-radius-xs);
transition: background-color var(--app-motion-base) ease;
.menu_item-box {
display: flex;
align-items: center;
}
&:hover {
border-radius: var(--app-radius-xs);
background: var(--td-bg-color-container-hover);
.menu_icon,
.menu_title {
color: var(--td-text-color-primary);
}
}
}
.menu_icon {
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 var(--sidebar-icon-size);
width: var(--sidebar-icon-size);
height: var(--sidebar-icon-size);
margin-right: var(--sidebar-icon-gap);
color: var(--td-text-color-secondary);
.icon {
width: 18px;
height: 18px;
overflow: hidden;
}
// 图形几乎占满画布的图标缩小显示,否则会比其他图标大一圈
&.menu_icon--zhishiku .icon,
&.menu_icon--organization .icon,
.icon.icon--toggle {
width: 16px;
height: 16px;
}
}
.menu_title {
color: var(--td-text-color-primary);
text-overflow: ellipsis;
font-family: var(--app-font-family);
font-size: var(--app-text-base);
font-style: normal;
font-weight: 500;
line-height: 20px;
overflow: hidden;
white-space: nowrap;
max-width: 120px;
flex: 1;
}
.submenu {
position: relative;
font-family: var(--app-font-family);
font-size: var(--app-text-base);
font-style: normal;
min-width: 0;
min-height: 0;
flex: 1 1 auto;
overflow-y: auto;
overflow-x: hidden;
padding-top: 3px;
scrollbar-width: thin;
scrollbar-color: transparent transparent;
transition: scrollbar-color var(--app-motion-base) ease;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background: transparent;
}
&::-webkit-scrollbar-thumb {
background-color: transparent;
border-radius: var(--app-radius-sm);
transition: background-color var(--app-motion-base) ease;
}
&:hover {
scrollbar-color: var(--td-scrollbar-color) transparent;
&::-webkit-scrollbar-thumb {
background-color: var(--td-scrollbar-color);
}
}
&::-webkit-scrollbar-thumb:hover {
background-color: var(--td-scrollbar-hover-color);
}
}
:deep(.submenu_pin_icon) {
color: inherit;
font-size: var(--app-text-sm);
margin-right: 4px;
vertical-align: middle;
flex-shrink: 0;
}
.submenu_source_icon {
width: 14px;
height: 14px;
margin-right: 0px;
vertical-align: middle;
object-fit: contain;
flex-shrink: 0;
// 默认淡化处理,避免未选中状态下彩色图标与灰色标题不协调;
// 悬浮或选中时恢复彩色,交互时才引人注意。
filter: grayscale(1);
opacity: 0.55;
transition: filter var(--app-motion-fast) ease, opacity var(--app-motion-fast) ease;
}
:deep(.submenu_item:hover .submenu_source_icon),
:deep(.submenu_item_active .submenu_source_icon) {
filter: none;
opacity: 1;
}
// 列表行统一栅格:左缘 inset-x + 图标槽 18px + 间距 8px → 文案列与主菜单文字对齐
.session-list-row {
display: flex;
align-items: center;
gap: var(--sidebar-icon-gap);
padding: 0 8px 0 var(--sidebar-inset-x);
min-width: 0;
box-sizing: border-box;
}
.session-list-row__icon {
flex: 0 0 var(--sidebar-icon-size);
width: var(--sidebar-icon-size);
height: var(--sidebar-icon-size);
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.session-list-row__body {
flex: 1 1 auto;
min-width: 0;
overflow: hidden;
}
// 聊天区分组标题 / 会话行:与「聊天」节标题同列左对齐,不再预留图标槽
.session-list-row--flat {
padding-left: var(--sidebar-inset-x);
gap: 0;
}
.session-list-loading {
display: flex;
align-items: center;
min-height: 26px;
color: var(--td-text-color-placeholder);
}
.timeline_header {
font-family: var(--app-font-family);
font-size: var(--app-text-xs);
font-weight: 600;
color: var(--td-text-color-disabled);
padding-top: 4px;
padding-bottom: 1px;
margin-top: 0;
line-height: 16px;
user-select: none;
}
.timeline_header-label {
white-space: nowrap;
}
// Stable filter control: always mounted and absolutely pinned to the list's
// top-right so it visually sits on the first row (e.g. beside "近30天") and
// never jumps when switching session type reloads a bucket. It overlays the
// empty right side of the first header row, so it needs no reserved height.
.session-list-scope-header {
position: absolute;
top: 4px;
right: 8px;
z-index: 2;
display: flex;
justify-content: flex-end;
max-width: calc(100% - var(--sidebar-inset-x) - 8px);
:deep(.session-source-filter--inline) {
flex: 0 1 auto;
min-width: 0;
max-width: 100%;
opacity: 0;
transition: opacity var(--app-motion-fast) ease;
}
}
.submenu:hover .session-list-scope-header :deep(.session-source-filter--inline),
.session-list-scope-header:hover :deep(.session-source-filter--inline),
.session-list-scope-header:focus-within :deep(.session-source-filter--inline),
.session-list-scope-header :deep(.session-source-filter--inline.session-source-filter--emphasized) {
opacity: 1;
}
.submenu_item_p {
padding: 0;
box-sizing: border-box;
min-width: 0;
overflow: hidden;
&.session-chat-row {
margin-bottom: 1px;
}
&.session-chat-row .session-list-row {
height: 34px;
padding-right: 4px;
border-radius: var(--app-radius-sm);
transition: background var(--app-motion-fast) ease, color var(--app-motion-fast) ease;
}
&.session-chat-row--revealed {
animation: session-fork-enter 280ms ease-out both;
}
&.session-chat-row:hover .session-list-row {
background: var(--td-bg-color-container-hover);
:deep(.menu-more) {
color: var(--td-text-color-primary);
}
}
&.session-chat-row--active .session-list-row {
background: var(--td-bg-color-container-hover);
:deep(.submenu_item) {
color: var(--td-brand-color);
}
:deep(.menu-more) {
color: var(--td-text-color-primary);
}
}
&.session-chat-row--selected .session-list-row {
background: color-mix(in srgb, var(--td-brand-color) 5%, transparent);
}
}
// SessionSidebarRow 为子组件,需 :deep 才能让标题省略号生效
:deep(.submenu_item) {
cursor: pointer;
display: flex;
align-items: center;
color: var(--td-text-color-primary);
font-weight: 400;
font-size: var(--app-text-base);
line-height: 20px;
height: 100%;
width: 100%;
padding: 0;
position: relative;
min-width: 0;
background: transparent;
.submenu_title {
display: flex;
align-items: center;
flex: 1 1 auto;
min-width: 0;
overflow: hidden;
}
.submenu_title-text {
flex: 1 1 auto;
min-width: 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.menu-more-wrap {
transition: opacity var(--app-motion-base) ease;
flex-shrink: 0;
}
.menu-more {
display: inline-block;
font-weight: bold;
color: var(--td-brand-color);
}
.submenu_title--batch {
margin-left: 4px;
}
&.submenu_item_batch {
padding-left: 0;
}
}
:deep(.submenu_item_batch) {
cursor: pointer;
user-select: none;
}
.batch-checkbox {
flex-shrink: 0;
}
}
.batch-inline-footer {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: space-between;
padding: 6px 12px;
border-top: 1px solid var(--td-component-stroke);
background: var(--td-bg-color-container);
.batch-footer-left {
display: flex;
align-items: center;
font-size: var(--app-text-md);
color: var(--td-text-color-placeholder);
}
.batch-footer-right {
display: flex;
align-items: center;
gap: 6px;
}
}
.menu_item-box {
display: flex;
align-items: center;
width: 100%;
position: relative;
}
/* Empty state when there are no sessions. */
.submenu_empty {
padding: 24px 14px;
text-align: center;
font-size: var(--app-text-sm);
color: var(--td-text-color-placeholder);
user-select: none;
}
// 顶部 logo_row 右侧的图标按钮组(搜索 + 折叠),与折叠按钮风格一致
.logo_actions {
display: flex;
align-items: center;
gap: 2px;
flex-shrink: 0;
}
.header-icon-btn {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
flex-shrink: 0;
cursor: pointer;
border-radius: var(--app-radius-sm);
color: var(--td-text-color-secondary);
transition: background-color var(--app-motion-base) ease;
box-sizing: border-box;
&:hover {
background: var(--td-bg-color-container-hover);
}
&.is-active {
background: var(--td-bg-color-container-hover);
color: var(--td-brand-color);
}
.header-icon-img {
width: 18px;
height: 18px;
display: block;
}
}
// 深色 tooltip 内容:标签 + 浅灰快捷键内联
.cmdk-tip {
display: inline-flex;
align-items: center;
gap: 8px;
white-space: nowrap;
.cmdk-tip-label {
font-size: var(--app-text-md);
}
.cmdk-tip-keys {
font-size: var(--app-text-md);
opacity: 0.6;
letter-spacing: 0.5px;
}
}
.menu-toolbox-stack {
display: inline-flex;
align-items: center;
flex-shrink: 0;
margin-left: auto;
}
.menu-toolbox-stack__item {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
box-sizing: border-box;
border: 1px solid var(--td-component-stroke);
border-radius: 50%;
background: var(--td-bg-color-container);
color: var(--td-text-color-secondary);
rotate: var(--stack-rotate, 0deg);
--stack-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
animation: menu-toolbox-stack-in 420ms var(--stack-spring) both;
animation-delay: var(--stack-delay, 0ms);
transition:
margin var(--app-motion-slow) var(--stack-spring),
rotate var(--app-motion-slow) var(--stack-spring),
translate var(--app-motion-slow) var(--stack-spring),
color var(--app-motion-base) ease,
box-shadow var(--app-motion-base) ease;
transition-delay: var(--stack-delay, 0ms);
& + & {
margin-left: -6px;
}
&:nth-child(1) { z-index: 3; --stack-rotate: -10deg; }
&:nth-child(2) { z-index: 2; --stack-delay: 50ms; }
&:nth-child(3) { z-index: 1; --stack-rotate: 10deg; --stack-delay: 100ms; }
}
.menu-toolbox-stack__status {
position: absolute;
right: -1px;
bottom: -1px;
width: 6px;
height: 6px;
border-radius: var(--app-radius-pill);
box-shadow: 0 0 0 1.5px var(--td-bg-color-container);
&.is-connected {
background: var(--td-success-color);
}
&.is-offline {
background: var(--td-warning-color);
}
}
@keyframes menu-toolbox-stack-in {
from {
opacity: 0;
scale: 0.4;
}
}
.menu_item:hover .menu-toolbox-stack__item {
color: var(--td-text-color-primary);
rotate: 0deg;
translate: 0 -1px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.menu_item:hover .menu-toolbox-stack__item + .menu-toolbox-stack__item {
margin-left: 3px;
}
@media (prefers-reduced-motion: reduce) {
.menu-toolbox-stack__item {
animation: none;
transition: color var(--app-motion-base) ease;
}
}
.menu-pending-badge {
min-width: 18px;
height: 18px;
padding: 0 5px;
margin-left: 6px;
border-radius: 9px;
background: rgba(250, 173, 20, 0.2);
color: var(--td-warning-color);
font-size: var(--app-text-sm);
font-weight: 600;
line-height: 18px;
text-align: center;
flex-shrink: 0;
}
.menu_box {
position: relative;
}
@keyframes session-fork-enter {
from { opacity: 0; transform: translateX(-10px); }
to { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
.aside_box .submenu_item_p.session-chat-row--revealed {
animation: none;
}
}
</style>
<style lang="less">
// Dark mode: invert dark logo to light
html[theme-mode="dark"] .aside_box .logo_box .logo {
filter: invert(1) hue-rotate(180deg);
}
// Dark mode: 滚动条在深色背景下需要更亮的颜色才看得见
html[theme-mode="dark"] .aside_box .menu_top:hover {
scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}
html[theme-mode="dark"] .aside_box .menu_top:hover::-webkit-scrollbar-thumb {
background-color: rgba(255, 255, 255, 0.22);
}
html[theme-mode="dark"] .aside_box .menu_top::-webkit-scrollbar-thumb:hover {
background-color: rgba(255, 255, 255, 0.38);
}
// Dark mode: invert the top search icon button image to match text color
html[theme-mode="dark"] .aside_box .header-icon-img {
filter: invert(1);
opacity: 0.55;
}
html[theme-mode="dark"] .aside_box .header-icon-btn:hover .header-icon-img {
opacity: 0.9;
}
// Dark mode: make SVG icons match text color (loaded via <img>, currentColor won't work)
html[theme-mode="dark"] .aside_box .menu_icon img.icon {
filter: invert(1);
opacity: 0.55;
}
// Hover state: brighter icon like text
html[theme-mode="dark"] .aside_box .menu_item:hover .menu_icon img.icon {
opacity: 0.9;
}
// menu_item_c_active: text is primary, so icon should match
html[theme-mode="dark"] .aside_box .menu_item_c_active .menu_icon img.icon {
opacity: 0.9;
}
// Active (green) icons should not be inverted
html[theme-mode="dark"] .aside_box .menu_item_active .menu_icon img.icon {
filter: none;
opacity: 1;
}
// 下拉菜单样式已统一至 @/assets/dropdown-menu.less
// 退出登录确认框样式
:deep(.t-popconfirm) {
.t-popconfirm__content {
background: var(--td-bg-color-container);
border: 1px solid var(--td-component-stroke);
border-radius: var(--app-radius-sm);
box-shadow: var(--td-shadow-3);
padding: 12px 16px;
font-size: var(--app-text-base);
color: var(--td-text-color-primary);
max-width: 200px;
}
.t-popconfirm__arrow {
border-bottom-color: var(--td-component-stroke);
}
.t-popconfirm__arrow::after {
border-bottom-color: var(--td-bg-color-container);
}
.t-popconfirm__buttons {
margin-top: 8px;
display: flex;
justify-content: flex-end;
gap: 8px;
}
.t-button--variant-outline {
border-color: var(--td-component-border);
color: var(--td-text-color-secondary);
}
.t-button--theme-danger {
background-color: var(--td-error-color);
border-color: var(--td-error-color);
}
.t-button--theme-danger:hover {
background-color: var(--td-error-color);
border-color: var(--td-error-color);
}
}
</style>