feat: enhance ListSpaceSidebar with improved UI elements and functionality

- Updated ListSpaceSidebar to include new icon-label structure for better accessibility and clarity.
- Added hide-all and hide-shared props in AgentList for conditional rendering of sidebar items.
- Adjusted placeholder text in ParserEngineSettings for clearer user guidance.

These changes improve the user experience by enhancing the visual layout and providing clearer instructions within the settings.
This commit is contained in:
wizardchen
2026-03-02 20:33:17 +08:00
committed by lyingbug
parent 88d5b303b8
commit 5ba42633ba
3 changed files with 237 additions and 220 deletions
+234 -219
View File
@@ -1,148 +1,156 @@
<template> <template>
<div <div
ref="sidebarRef"
class="list-space-sidebar" class="list-space-sidebar"
:class="{ pinned }" :class="{ expanded: isExpanded, dragging: isDragging }"
@mouseenter="onMouseEnter" :style="{ width: isDragging ? `${dragWidth}px` : undefined }"
@mouseleave="onMouseLeave"
> >
<!-- Icon strip: hidden when pinned (panel takes over) --> <!-- Collapsed: icon strip -->
<div v-show="!pinned" class="icon-strip"> <div v-if="!isExpanded" class="icon-strip">
<template v-if="mode !== 'resource'">
<t-tooltip :content="tooltipText($t('listSpaceSidebar.all'), countAll)" placement="right" :show-arrow="false">
<div class="icon-item" :class="{ active: selected === 'all' }" @click="select('all')">
<t-icon name="layers" size="16px" />
</div>
</t-tooltip>
</template>
<template v-if="mode === 'resource'"> <template v-if="mode === 'resource'">
<t-tooltip :content="tooltipText($t('listSpaceSidebar.mine'), countMine)" placement="right" :show-arrow="false"> <t-tooltip v-if="!hideAll" :content="tooltipText($t('listSpaceSidebar.all'), countAll)" placement="right" :show-arrow="false">
<div class="icon-item" :class="{ active: selected === 'mine' }" @click="select('mine')"> <div class="icon-item-labeled" :class="{ active: selected === 'all' }" @click="select('all')">
<t-icon name="user" size="16px" /> <t-icon name="layers" size="16px" />
<span class="icon-label">{{ $t('listSpaceSidebar.all') }}</span>
</div> </div>
</t-tooltip> </t-tooltip>
<t-tooltip v-if="countShared !== undefined && countShared > 0" :content="tooltipText($t('listSpaceSidebar.sharedToMe'), countShared)" placement="right" :show-arrow="false"> <t-tooltip :content="tooltipText($t('listSpaceSidebar.mine'), countMine)" placement="right" :show-arrow="false">
<div class="icon-item" :class="{ active: selected === 'shared' }" @click="select('shared')"> <div class="icon-item-labeled" :class="{ active: selected === 'mine' }" @click="select('mine')">
<t-icon name="user" size="16px" />
<span class="icon-label">{{ $t('listSpaceSidebar.mine') }}</span>
</div>
</t-tooltip>
<t-tooltip v-if="!hideShared" :content="tooltipText($t('listSpaceSidebar.sharedToMe'), countShared)" placement="right" :show-arrow="false">
<div class="icon-item-labeled" :class="{ active: selected === 'shared' }" @click="select('shared')">
<t-icon name="share" size="16px" /> <t-icon name="share" size="16px" />
<span class="icon-label">{{ $t('listSpaceSidebar.sharedToMe') }}</span>
</div> </div>
</t-tooltip> </t-tooltip>
<template v-if="organizationsWithCount.length"> <template v-if="organizationsWithCount.length">
<div class="icon-strip-divider" /> <div class="icon-strip-divider" />
<t-tooltip v-for="org in organizationsWithCount" :key="org.id" :content="tooltipText(org.name, getOrgCount(org.id))" placement="right" :show-arrow="false"> <t-tooltip v-for="org in organizationsWithCount" :key="org.id" :content="tooltipText(org.name, getOrgCount(org.id))" placement="right" :show-arrow="false">
<div class="icon-item" :class="{ active: selected === org.id }" @click="select(org.id)"> <div class="icon-item-labeled" :class="{ active: selected === org.id }" @click="select(org.id)">
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" /> <SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" />
<span class="icon-label">{{ truncateLabel(org.name) }}</span>
</div> </div>
</t-tooltip> </t-tooltip>
</template> </template>
</template> </template>
<template v-else> <template v-else>
<t-tooltip :content="tooltipText($t('listSpaceSidebar.all'), countAll)" placement="right" :show-arrow="false">
<div class="icon-item-labeled" :class="{ active: selected === 'all' }" @click="select('all')">
<t-icon name="layers" size="16px" />
<span class="icon-label">{{ $t('listSpaceSidebar.all') }}</span>
</div>
</t-tooltip>
<t-tooltip :content="tooltipText($t('organization.createdByMe'), countCreated)" placement="right" :show-arrow="false"> <t-tooltip :content="tooltipText($t('organization.createdByMe'), countCreated)" placement="right" :show-arrow="false">
<div class="icon-item" :class="{ active: selected === 'created' }" @click="select('created')"> <div class="icon-item-labeled" :class="{ active: selected === 'created' }" @click="select('created')">
<t-icon name="usergroup-add" size="16px" /> <t-icon name="usergroup-add" size="16px" />
<span class="icon-label">{{ $t('organization.createdByMe') }}</span>
</div> </div>
</t-tooltip> </t-tooltip>
<t-tooltip :content="tooltipText($t('organization.joinedByMe'), countJoined)" placement="right" :show-arrow="false"> <t-tooltip :content="tooltipText($t('organization.joinedByMe'), countJoined)" placement="right" :show-arrow="false">
<div class="icon-item" :class="{ active: selected === 'joined' }" @click="select('joined')"> <div class="icon-item-labeled" :class="{ active: selected === 'joined' }" @click="select('joined')">
<t-icon name="usergroup" size="16px" /> <t-icon name="usergroup" size="16px" />
<span class="icon-label">{{ $t('organization.joinedByMe') }}</span>
</div> </div>
</t-tooltip> </t-tooltip>
</template> </template>
</div> </div>
<!-- Expanded panel: floats over content on hover, or stays when pinned --> <!-- Expanded: full nav panel -->
<Transition name="sb-expand"> <nav v-else class="expanded-panel">
<aside v-if="expanded || pinned" class="expanded-panel" :class="{ pinned }"> <div
<div class="panel-pin" @click.stop="togglePin"> v-if="!hideAll"
<t-tooltip :content="pinned ? $t('listSpaceSidebar.unpin', 'Unpin') : $t('listSpaceSidebar.pin', 'Pin')" placement="right" :show-arrow="false"> class="sidebar-item"
<t-icon :name="pinned ? 'pin-filled' : 'pin'" size="14px" /> :class="{ active: selected === 'all' }"
</t-tooltip> @click="select('all')"
>
<div class="item-left">
<t-icon name="layers" class="item-icon" />
<span class="item-label">{{ $t('listSpaceSidebar.all') }}</span>
</div> </div>
<nav class="sidebar-nav"> <span v-if="countAll !== undefined" class="item-count">{{ countAll }}</span>
</div>
<template v-if="mode === 'resource'">
<div
class="sidebar-item"
:class="{ active: selected === 'mine' }"
@click="select('mine')"
>
<div class="item-left">
<t-icon name="user" class="item-icon" />
<span class="item-label">{{ $t('listSpaceSidebar.mine') }}</span>
</div>
<span v-if="countMine !== undefined" class="item-count">{{ countMine }}</span>
</div>
<div
v-if="!hideShared"
class="sidebar-item"
:class="{ active: selected === 'shared' }"
@click="select('shared')"
>
<div class="item-left">
<t-icon name="share" class="item-icon" />
<span class="item-label">{{ $t('listSpaceSidebar.sharedToMe') }}</span>
</div>
<span v-if="countShared !== undefined && countShared > 0" class="item-count">{{ countShared }}</span>
</div>
<template v-if="organizationsWithCount.length">
<div class="sidebar-section">
<span class="section-title">{{ $t('listSpaceSidebar.spaces') }}</span>
</div>
<div <div
v-if="mode !== 'resource'" v-for="org in organizationsWithCount"
class="sidebar-item" :key="org.id"
:class="{ active: selected === 'all' }" class="sidebar-item org-item"
@click="select('all')" :class="{ active: selected === org.id }"
@click="select(org.id)"
> >
<div class="item-left"> <div class="item-left">
<t-icon name="layers" class="item-icon" /> <SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" class="item-avatar" />
<span class="item-label">{{ $t('listSpaceSidebar.all') }}</span> <span class="item-label" :title="org.name">{{ org.name }}</span>
</div> </div>
<span v-if="countAll !== undefined" class="item-count">{{ countAll }}</span> <span v-if="getOrgCount(org.id) !== undefined" class="item-count">{{ getOrgCount(org.id) }}</span>
</div> </div>
</template>
</template>
<template v-if="mode === 'resource'"> <template v-else>
<div <div
class="sidebar-item" class="sidebar-item"
:class="{ active: selected === 'mine' }" :class="{ active: selected === 'created' }"
@click="select('mine')" @click="select('created')"
> >
<div class="item-left"> <div class="item-left">
<t-icon name="user" class="item-icon" /> <t-icon name="usergroup-add" class="item-icon" />
<span class="item-label">{{ $t('listSpaceSidebar.mine') }}</span> <span class="item-label">{{ $t('organization.createdByMe') }}</span>
</div> </div>
<span v-if="countMine !== undefined" class="item-count">{{ countMine }}</span> <span v-if="countCreated !== undefined" class="item-count">{{ countCreated }}</span>
</div> </div>
<div <div
v-if="countShared !== undefined && countShared > 0" class="sidebar-item"
class="sidebar-item" :class="{ active: selected === 'joined' }"
:class="{ active: selected === 'shared' }" @click="select('joined')"
@click="select('shared')" >
> <div class="item-left">
<div class="item-left"> <t-icon name="usergroup" class="item-icon" />
<t-icon name="share" class="item-icon" /> <span class="item-label">{{ $t('organization.joinedByMe') }}</span>
<span class="item-label">{{ $t('listSpaceSidebar.sharedToMe') }}</span> </div>
</div> <span v-if="countJoined !== undefined" class="item-count">{{ countJoined }}</span>
<span class="item-count">{{ countShared }}</span> </div>
</div> </template>
<template v-if="organizationsWithCount.length"> </nav>
<div class="sidebar-section">
<span class="section-title">{{ $t('listSpaceSidebar.spaces') }}</span>
</div>
<div
v-for="org in organizationsWithCount"
:key="org.id"
class="sidebar-item org-item"
:class="{ active: selected === org.id }"
@click="select(org.id)"
>
<div class="item-left">
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" class="item-avatar" />
<span class="item-label" :title="org.name">{{ org.name }}</span>
</div>
<span v-if="getOrgCount(org.id) !== undefined" class="item-count">{{ getOrgCount(org.id) }}</span>
</div>
</template>
</template>
<template v-else> <!-- Drag handle on the right edge -->
<div <div
class="sidebar-item" class="resize-handle"
:class="{ active: selected === 'created' }" @mousedown.prevent="onDragStart"
@click="select('created')" >
> <div class="resize-handle-line" />
<div class="item-left"> </div>
<t-icon name="usergroup-add" class="item-icon" />
<span class="item-label">{{ $t('organization.createdByMe') }}</span>
</div>
<span v-if="countCreated !== undefined" class="item-count">{{ countCreated }}</span>
</div>
<div
class="sidebar-item"
:class="{ active: selected === 'joined' }"
@click="select('joined')"
>
<div class="item-left">
<t-icon name="usergroup" class="item-icon" />
<span class="item-label">{{ $t('organization.joinedByMe') }}</span>
</div>
<span v-if="countJoined !== undefined" class="item-count">{{ countJoined }}</span>
</div>
</template>
</nav>
</aside>
</Transition>
</div> </div>
</template> </template>
@@ -152,6 +160,10 @@ import { Icon as TIcon } from 'tdesign-vue-next'
import SpaceAvatar from './SpaceAvatar.vue' import SpaceAvatar from './SpaceAvatar.vue'
import { useOrganizationStore } from '@/stores/organization' import { useOrganizationStore } from '@/stores/organization'
const COLLAPSED_WIDTH = 56
const EXPANDED_WIDTH = 208
const SNAP_THRESHOLD = 120
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
mode?: 'resource' | 'organization' mode?: 'resource' | 'organization'
@@ -163,45 +175,59 @@ const props = withDefaults(
countByOrg?: Record<string, number> countByOrg?: Record<string, number>
countCreated?: number countCreated?: number
countJoined?: number countJoined?: number
hideAll?: boolean
hideShared?: boolean
}>(), }>(),
{ mode: 'resource', collapsedKey: 'sidebar-collapsed-list', countAll: undefined, countMine: undefined, countShared: undefined, countByOrg: () => ({}), countCreated: undefined, countJoined: undefined } { mode: 'resource', collapsedKey: 'sidebar-collapsed-list', countAll: undefined, countMine: undefined, countShared: undefined, countByOrg: () => ({}), countCreated: undefined, countJoined: undefined, hideAll: false, hideShared: false }
) )
const pinStorageKey = props.collapsedKey + '-pinned' const storageKey = props.collapsedKey + '-expanded'
const pinned = ref(localStorage.getItem(pinStorageKey) === 'true') const sidebarRef = ref<HTMLElement | null>(null)
const expanded = ref(pinned.value) const isExpanded = ref(localStorage.getItem(storageKey) === 'true')
let enterTimer: ReturnType<typeof setTimeout> | null = null const isDragging = ref(false)
let leaveTimer: ReturnType<typeof setTimeout> | null = null const dragWidth = ref(isExpanded.value ? EXPANDED_WIDTH : COLLAPSED_WIDTH)
function togglePin() { let startX = 0
pinned.value = !pinned.value let startWidth = 0
localStorage.setItem(pinStorageKey, String(pinned.value))
if (pinned.value) { function onDragStart(e: MouseEvent) {
expanded.value = true isDragging.value = true
} startX = e.clientX
startWidth = isExpanded.value ? EXPANDED_WIDTH : COLLAPSED_WIDTH
dragWidth.value = startWidth
document.addEventListener('mousemove', onDragMove)
document.addEventListener('mouseup', onDragEnd)
document.body.style.cursor = 'col-resize'
document.body.style.userSelect = 'none'
} }
function onMouseEnter() { function onDragMove(e: MouseEvent) {
if (pinned.value) return const delta = e.clientX - startX
if (leaveTimer) { clearTimeout(leaveTimer); leaveTimer = null } const newWidth = Math.max(COLLAPSED_WIDTH, Math.min(EXPANDED_WIDTH + 20, startWidth + delta))
enterTimer = setTimeout(() => { expanded.value = true }, 180) dragWidth.value = newWidth
} }
function onMouseLeave() { function onDragEnd() {
if (pinned.value) return document.removeEventListener('mousemove', onDragMove)
if (enterTimer) { clearTimeout(enterTimer); enterTimer = null } document.removeEventListener('mouseup', onDragEnd)
leaveTimer = setTimeout(() => { expanded.value = false }, 250) document.body.style.cursor = ''
} document.body.style.userSelect = ''
onBeforeUnmount(() => { const shouldExpand = dragWidth.value >= SNAP_THRESHOLD
if (enterTimer) clearTimeout(enterTimer) isExpanded.value = shouldExpand
if (leaveTimer) clearTimeout(leaveTimer) localStorage.setItem(storageKey, String(shouldExpand))
}) isDragging.value = false
dragWidth.value = shouldExpand ? EXPANDED_WIDTH : COLLAPSED_WIDTH
}
function tooltipText(name: string, count?: number): string { function tooltipText(name: string, count?: number): string {
return count !== undefined ? `${name} (${count})` : name return count !== undefined ? `${name} (${count})` : name
} }
function truncateLabel(text: string, max = 4): string {
return text.length > max ? text.slice(0, max) : text
}
const emit = defineEmits<{ const emit = defineEmits<{
'update:modelValue': [value: string] 'update:modelValue': [value: string]
}>() }>()
@@ -231,11 +257,16 @@ function getOrgCount(orgId: string): number | undefined {
onMounted(() => { onMounted(() => {
orgStore.fetchOrganizations() orgStore.fetchOrganizations()
}) })
onBeforeUnmount(() => {
document.removeEventListener('mousemove', onDragMove)
document.removeEventListener('mouseup', onDragEnd)
})
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.list-space-sidebar { .list-space-sidebar {
width: 44px; width: 56px;
flex-shrink: 0; flex-shrink: 0;
position: relative; position: relative;
display: flex; display: flex;
@@ -244,20 +275,53 @@ onMounted(() => {
z-index: 10; z-index: 10;
transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1); transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
&.pinned { &.expanded {
width: 208px; width: 208px;
margin-right: 16px; margin-right: 0;
}
&.dragging {
transition: none;
} }
} }
/* ========== Icon strip (always visible, 44px) ========== */ /* ========== Drag handle ========== */
.resize-handle {
position: absolute;
top: 0;
right: -4px;
bottom: 0;
width: 8px;
cursor: col-resize;
z-index: 12;
display: flex;
align-items: center;
justify-content: center;
&:hover .resize-handle-line,
.dragging & .resize-handle-line {
opacity: 1;
background: #07c05f;
}
}
.resize-handle-line {
width: 2px;
height: 32px;
border-radius: 1px;
background: #c5cad1;
opacity: 0;
transition: opacity 0.2s ease, background 0.2s ease;
}
/* ========== Icon strip (collapsed) ========== */
.icon-strip { .icon-strip {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
gap: 2px; gap: 4px;
width: 44px; width: 56px;
padding: 20px 0 8px; padding: 16px 0 8px;
flex: 1; flex: 1;
min-height: 0; min-height: 0;
overflow-y: auto; overflow-y: auto;
@@ -269,13 +333,15 @@ onMounted(() => {
} }
} }
.icon-item { .icon-item-labeled {
width: 32px; width: 46px;
height: 32px; padding: 6px 0 3px;
border-radius: 7px; border-radius: 8px;
display: flex; display: flex;
flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 2px;
cursor: pointer; cursor: pointer;
color: #6b7482; color: #6b7482;
transition: all 0.15s ease; transition: all 0.15s ease;
@@ -293,6 +359,11 @@ onMounted(() => {
&:hover { &:hover {
background: #e4f5ea; background: #e4f5ea;
} }
.icon-label {
color: #07c05f;
font-weight: 520;
}
} }
:deep(.space-avatar) { :deep(.space-avatar) {
@@ -302,101 +373,45 @@ onMounted(() => {
} }
} }
.icon-label {
font-size: 10px;
line-height: 1.2;
color: #86909c;
max-width: 44px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
transition: color 0.15s ease;
}
.icon-strip-divider { .icon-strip-divider {
width: 18px; width: 24px;
height: 1px; height: 1px;
background: #e7ebf0; background: #e7ebf0;
margin: 4px 0; margin: 4px 0;
flex-shrink: 0; flex-shrink: 0;
} }
/* ========== Expanded floating panel ========== */ /* ========== Expanded panel ========== */
.expanded-panel { .expanded-panel {
position: absolute; display: flex;
top: 0; flex-direction: column;
left: 0; gap: 2px;
bottom: 0; padding: 16px 10px;
width: 208px; flex: 1;
background: #fff; min-height: 0;
box-shadow: 3px 0 18px rgba(0, 0, 0, 0.07), 1px 0 0 #e7ebf0;
border-radius: 0 10px 10px 0;
padding: 30px 10px 16px 10px;
z-index: 11;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
scrollbar-width: none; scrollbar-width: none;
border-right: 1px solid #eef1f5;
&::-webkit-scrollbar { &::-webkit-scrollbar {
display: none; display: none;
} }
&.pinned {
position: relative;
width: 100%;
flex: 1;
box-shadow: none;
border-right: 1px solid #eef1f5;
border-radius: 0;
}
}
/* Pin button */
.panel-pin {
position: absolute;
top: 8px;
right: 8px;
width: 24px;
height: 24px;
border-radius: 5px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
color: #b0b7c0;
transition: all 0.15s ease;
z-index: 1;
&:hover {
background: #f5f7fa;
color: #4e5662;
}
.pinned & {
color: #07c05f;
&:hover {
background: #eef9f2;
color: #059b4c;
}
}
}
/* ========== Transition ========== */
.sb-expand-enter-active {
transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.sb-expand-leave-active {
transition: opacity 0.15s ease, transform 0.15s ease;
}
.sb-expand-enter-from {
opacity: 0;
transform: translateX(-8px);
}
.sb-expand-leave-to {
opacity: 0;
transform: translateX(-6px);
} }
/* ========== Nav items inside expanded panel ========== */ /* ========== Nav items inside expanded panel ========== */
.sidebar-nav {
display: flex;
flex-direction: column;
gap: 2px;
}
.sidebar-item { .sidebar-item {
display: flex; display: flex;
align-items: center; align-items: center;
+2
View File
@@ -5,6 +5,8 @@
:count-all="allAgentsCount" :count-all="allAgentsCount"
:count-mine="agents.length" :count-mine="agents.length"
:count-by-org="effectiveSharedCountByOrg" :count-by-org="effectiveSharedCountByOrg"
hide-all
hide-shared
/> />
<div class="agent-list-content"> <div class="agent-list-content">
<div class="header"> <div class="header">
@@ -145,7 +145,7 @@
<label>API 地址</label> <label>API 地址</label>
<t-input <t-input
v-model="config.mineru_api_base_url" v-model="config.mineru_api_base_url"
placeholder="如 https://api.mineru.net" placeholder="默认 https://mineru.net/api/v4"
clearable clearable
/> />
</div> </div>