refactor(ui): 清理资源列表废弃组件和无效样式
parent
eec236b27f
commit
e986579731
|
|
@ -1,550 +0,0 @@
|
|||
<template>
|
||||
<div ref="sidebarRef" class="list-space-sidebar" :class="{ expanded: isExpanded, dragging: isDragging }"
|
||||
:style="{ width: isDragging ? `${dragWidth}px` : undefined }">
|
||||
<!-- Collapsed: icon strip -->
|
||||
<div v-if="!isExpanded" class="icon-strip">
|
||||
<template v-if="mode === 'resource'">
|
||||
<t-tooltip v-if="!hideAll" :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 v-if="showFavorites" :content="tooltipText($t('listSpaceSidebar.favorites'), countFavorites)"
|
||||
placement="right" :show-arrow="false">
|
||||
<div class="icon-item-labeled" :class="{ active: selected === 'favorites' }" @click="select('favorites')">
|
||||
<t-icon name="star" size="16px" />
|
||||
<span class="icon-label">{{ $t('listSpaceSidebar.favorites') }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip v-if="showRecents" :content="tooltipText($t('listSpaceSidebar.recents'), countRecents)"
|
||||
placement="right" :show-arrow="false">
|
||||
<div class="icon-item-labeled" :class="{ active: selected === 'recents' }" @click="select('recents')">
|
||||
<t-icon name="history" size="16px" />
|
||||
<span class="icon-label">{{ $t('listSpaceSidebar.recents') }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip :content="tooltipText(workspaceLabel, countMine)" placement="right" :show-arrow="false">
|
||||
<div class="icon-item-labeled workspace-item" :class="{ active: selected === 'mine' }"
|
||||
@click="select('mine')">
|
||||
<t-icon name="system-sum" size="16px" />
|
||||
<span class="icon-label">{{ workspaceLabel }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<!-- Shared spaces group: per-org/space entries only. We dropped
|
||||
the aggregate "协作" / shared-with-me entry — its meaning
|
||||
oscillated between "everything shared to me" and "things I
|
||||
can edit", and either reading duplicated information already
|
||||
visible on the per-space entries below. -->
|
||||
<template v-if="organizationsWithCount.length">
|
||||
<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">
|
||||
<div class="icon-item-labeled" :class="{ active: selected === org.id }" @click="select(org.id)">
|
||||
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" />
|
||||
<span class="icon-label">{{ truncateLabel(org.name) }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<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">
|
||||
<div class="icon-item-labeled" :class="{ active: selected === 'created' }" @click="select('created')">
|
||||
<t-icon name="usergroup-add" size="16px" />
|
||||
<span class="icon-label">{{ $t('organization.createdByMe') }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip :content="tooltipText($t('organization.joinedByMe'), countJoined)" placement="right"
|
||||
:show-arrow="false">
|
||||
<div class="icon-item-labeled" :class="{ active: selected === 'joined' }" @click="select('joined')">
|
||||
<t-icon name="usergroup" size="16px" />
|
||||
<span class="icon-label">{{ $t('organization.joinedByMe') }}</span>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- Expanded: full nav panel -->
|
||||
<nav v-else class="expanded-panel">
|
||||
<div v-if="!hideAll" class="sidebar-item" :class="{ active: selected === 'all' }" @click="select('all')">
|
||||
<div class="item-left">
|
||||
<t-icon name="layers" class="item-icon" />
|
||||
<span class="item-label">{{ $t('listSpaceSidebar.all') }}</span>
|
||||
</div>
|
||||
<span v-if="countAll !== undefined" class="item-count">{{ countAll }}</span>
|
||||
</div>
|
||||
|
||||
<template v-if="mode === 'resource'">
|
||||
<div v-if="showFavorites" class="sidebar-item" :class="{ active: selected === 'favorites' }"
|
||||
@click="select('favorites')">
|
||||
<div class="item-left">
|
||||
<t-icon name="star" class="item-icon" />
|
||||
<span class="item-label">{{ $t('listSpaceSidebar.favorites') }}</span>
|
||||
</div>
|
||||
<span v-if="countFavorites > 0" class="item-count">{{ countFavorites }}</span>
|
||||
</div>
|
||||
<div v-if="showRecents" class="sidebar-item" :class="{ active: selected === 'recents' }"
|
||||
@click="select('recents')">
|
||||
<div class="item-left">
|
||||
<t-icon name="history" class="item-icon" />
|
||||
<span class="item-label">{{ $t('listSpaceSidebar.recents') }}</span>
|
||||
</div>
|
||||
<span v-if="countRecents > 0" class="item-count">{{ countRecents }}</span>
|
||||
</div>
|
||||
<div v-if="(showFavorites || showRecents)" class="sidebar-divider" />
|
||||
<div class="sidebar-item" :class="{ active: selected === 'mine' }" @click="select('mine')">
|
||||
<div class="item-left">
|
||||
<t-icon name="system-sum" class="item-icon" />
|
||||
<span class="item-label">{{ workspaceLabel }}</span>
|
||||
</div>
|
||||
<span v-if="countMine !== undefined" class="item-count">{{ countMine }}</span>
|
||||
</div>
|
||||
<!-- Shared spaces group — per-org entries only; the aggregate
|
||||
entry was removed (see collapsed strip for rationale). -->
|
||||
<template v-if="organizationsWithCount.length">
|
||||
<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>
|
||||
<div class="sidebar-item" :class="{ active: selected === 'created' }" @click="select('created')">
|
||||
<div class="item-left">
|
||||
<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>
|
||||
|
||||
<!-- Drag handle on the right edge -->
|
||||
<div class="resize-handle" @mousedown.prevent="onDragStart">
|
||||
<div class="resize-handle-line" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { Icon as TIcon } from 'tdesign-vue-next'
|
||||
import SpaceAvatar from './SpaceAvatar.vue'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
|
||||
const COLLAPSED_WIDTH = 56
|
||||
const EXPANDED_WIDTH = 208
|
||||
const SNAP_THRESHOLD = 120
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
mode?: 'resource' | 'organization'
|
||||
modelValue: string
|
||||
collapsedKey?: string
|
||||
countAll?: number
|
||||
countMine?: number
|
||||
countByOrg?: Record<string, number>
|
||||
countCreated?: number
|
||||
countJoined?: number
|
||||
hideAll?: boolean
|
||||
/** Favorites entry. Only meaningful in resource mode. */
|
||||
countFavorites?: number
|
||||
showFavorites?: boolean
|
||||
/** Recents entry. Only meaningful in resource mode. */
|
||||
countRecents?: number
|
||||
showRecents?: boolean
|
||||
}>(),
|
||||
{
|
||||
mode: 'resource',
|
||||
collapsedKey: 'sidebar-collapsed-list',
|
||||
countAll: undefined,
|
||||
countMine: undefined,
|
||||
countByOrg: () => ({}),
|
||||
countCreated: undefined,
|
||||
countJoined: undefined,
|
||||
hideAll: false,
|
||||
countFavorites: 0,
|
||||
showFavorites: true,
|
||||
countRecents: 0,
|
||||
showRecents: true,
|
||||
}
|
||||
)
|
||||
|
||||
const storageKey = props.collapsedKey + '-expanded'
|
||||
const sidebarRef = ref<HTMLElement | null>(null)
|
||||
const isExpanded = ref(localStorage.getItem(storageKey) === 'true')
|
||||
const isDragging = ref(false)
|
||||
const dragWidth = ref(isExpanded.value ? EXPANDED_WIDTH : COLLAPSED_WIDTH)
|
||||
|
||||
let startX = 0
|
||||
let startWidth = 0
|
||||
|
||||
function onDragStart(e: MouseEvent) {
|
||||
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 onDragMove(e: MouseEvent) {
|
||||
const delta = e.clientX - startX
|
||||
const newWidth = Math.max(COLLAPSED_WIDTH, Math.min(EXPANDED_WIDTH + 20, startWidth + delta))
|
||||
dragWidth.value = newWidth
|
||||
}
|
||||
|
||||
function onDragEnd() {
|
||||
document.removeEventListener('mousemove', onDragMove)
|
||||
document.removeEventListener('mouseup', onDragEnd)
|
||||
document.body.style.cursor = ''
|
||||
document.body.style.userSelect = ''
|
||||
|
||||
const shouldExpand = dragWidth.value >= SNAP_THRESHOLD
|
||||
isExpanded.value = shouldExpand
|
||||
localStorage.setItem(storageKey, String(shouldExpand))
|
||||
isDragging.value = false
|
||||
dragWidth.value = shouldExpand ? EXPANDED_WIDTH : COLLAPSED_WIDTH
|
||||
}
|
||||
|
||||
function tooltipText(name: string, count?: number): string {
|
||||
return count !== undefined ? `${name} (${count})` : name
|
||||
}
|
||||
|
||||
// truncateLabel keeps the collapsed-strip label visually balanced (~44px
|
||||
// wide). 4 CJK chars fits; ASCII can stretch further. Callers that want
|
||||
// the full label should pass it as :title= on the same element for hover.
|
||||
function truncateLabel(text: string, max = 4): string {
|
||||
if (!text) return ''
|
||||
return text.length > max ? text.slice(0, max) + '…' : text
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: string]
|
||||
}>()
|
||||
|
||||
const orgStore = useOrganizationStore()
|
||||
const { t } = useI18n()
|
||||
const selected = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v: string) => emit('update:modelValue', v)
|
||||
})
|
||||
|
||||
// workspaceLabel is the unified label for the tenant-owned bucket.
|
||||
// Earlier iterations rendered the active tenant's display name here, but
|
||||
// long names (e.g. "wizardlab Test Team") got truncated to unreadable
|
||||
// stubs ("wiza…") in the collapsed strip and competed visually with the
|
||||
// org/space entries below. A constant i18n label sidesteps both issues;
|
||||
// the tenant identity is already conveyed by the dedicated TenantSelector
|
||||
// in the global header, so we don't lose information.
|
||||
const workspaceLabel = computed(() => t('listSpaceSidebar.workspace'))
|
||||
|
||||
const organizations = computed(() => orgStore.organizations || [])
|
||||
|
||||
const organizationsWithCount = computed(() => {
|
||||
if (props.mode !== 'resource') return organizations.value
|
||||
return organizations.value.filter((org) => (props.countByOrg?.[org.id] ?? 0) > 0)
|
||||
})
|
||||
|
||||
function select(value: string) {
|
||||
selected.value = value
|
||||
}
|
||||
|
||||
function getOrgCount(orgId: string): number | undefined {
|
||||
const n = props.countByOrg?.[orgId]
|
||||
return n === undefined ? undefined : n
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
orgStore.fetchOrganizations()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('mousemove', onDragMove)
|
||||
document.removeEventListener('mouseup', onDragEnd)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.list-space-sidebar {
|
||||
width: 56px;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
z-index: 10;
|
||||
transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
&.expanded {
|
||||
width: 208px;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&.dragging {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ========== Drag handle ========== */
|
||||
.resize-handle {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: -6px;
|
||||
bottom: 0;
|
||||
width: 12px;
|
||||
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: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
.resize-handle-line {
|
||||
width: 2px;
|
||||
height: 40px;
|
||||
border-radius: 1px;
|
||||
background: var(--td-bg-color-component-disabled);
|
||||
opacity: 0.45;
|
||||
transition: opacity var(--app-motion-base) ease, background var(--app-motion-base) ease;
|
||||
}
|
||||
|
||||
/* ========== Icon strip (collapsed) ========== */
|
||||
.icon-strip {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
width: 56px;
|
||||
padding: 12px 0 6px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
scrollbar-width: none;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.icon-item-labeled {
|
||||
width: 46px;
|
||||
padding: 5px 0 2px;
|
||||
border-radius: var(--app-radius-md);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 2px;
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
transition: all var(--app-motion-fast) ease;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-brand-color);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
}
|
||||
|
||||
.icon-label {
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.space-avatar) {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: var(--app-text-2xs);
|
||||
}
|
||||
}
|
||||
|
||||
.icon-label {
|
||||
font-size: var(--app-text-xs);
|
||||
line-height: 1.25;
|
||||
color: var(--td-text-color-secondary);
|
||||
max-width: 52px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
transition: color var(--app-motion-fast) ease;
|
||||
}
|
||||
|
||||
|
||||
.icon-strip-divider {
|
||||
width: 24px;
|
||||
height: 1px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
margin: 3px 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ========== Expanded panel ========== */
|
||||
.expanded-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: 12px 8px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
scrollbar-width: none;
|
||||
border-right: 1px solid var(--td-component-stroke);
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* ========== Nav items inside expanded panel ========== */
|
||||
.sidebar-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 6px 8px;
|
||||
border-radius: 7px;
|
||||
color: var(--td-text-color-primary);
|
||||
cursor: pointer;
|
||||
transition: all var(--app-motion-fast) ease;
|
||||
font-family: var(--app-font-family);
|
||||
font-size: var(--app-text-base);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
||||
.item-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.item-icon {
|
||||
flex-shrink: 0;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: var(--app-text-base);
|
||||
transition: color var(--app-motion-fast) ease;
|
||||
}
|
||||
|
||||
.item-avatar {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.item-label {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: var(--app-text-md);
|
||||
font-weight: 430;
|
||||
line-height: 1.4;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
|
||||
.item-count {
|
||||
font-size: var(--app-text-sm);
|
||||
color: var(--td-text-color-secondary);
|
||||
font-weight: 500;
|
||||
padding: 2px 7px;
|
||||
border-radius: var(--app-radius-md);
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
margin-left: 6px;
|
||||
flex-shrink: 0;
|
||||
transition: all var(--app-motion-fast) ease;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
color: var(--td-text-color-primary);
|
||||
|
||||
.item-icon {
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.item-count {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-brand-color);
|
||||
|
||||
.item-icon {
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
.item-count {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-divider {
|
||||
height: 1px;
|
||||
margin: 6px 4px;
|
||||
background: var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.sidebar-section {
|
||||
padding: 8px 6px 2px;
|
||||
margin-top: 2px;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
|
||||
.section-title {
|
||||
font-size: var(--app-text-sm);
|
||||
color: var(--td-text-color-secondary);
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,488 +0,0 @@
|
|||
<template>
|
||||
<t-dialog
|
||||
v-model:visible="dialogVisible"
|
||||
:header="$t('organization.share.title')"
|
||||
width="520px"
|
||||
:footer="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<!-- Share form -->
|
||||
<div class="share-form" v-if="!showShareList">
|
||||
<t-form :data="shareForm" ref="shareFormRef">
|
||||
<t-form-item
|
||||
:label="$t('organization.share.selectOrg')"
|
||||
name="organization_id"
|
||||
:rules="[{ required: true, message: $t('organization.share.selectOrgPlaceholder') }]"
|
||||
>
|
||||
<t-select
|
||||
v-model="shareForm.organization_id"
|
||||
:placeholder="$t('organization.share.selectOrgPlaceholder')"
|
||||
:loading="loadingOrgs"
|
||||
class="org-select-dropdown"
|
||||
:popup-props="{ overlayClassName: 'org-select-dropdown-popup' }"
|
||||
>
|
||||
<t-option
|
||||
v-for="org in availableOrganizations"
|
||||
:key="org.id"
|
||||
:value="org.id"
|
||||
:label="org.name"
|
||||
>
|
||||
<div class="org-option-content">
|
||||
<div class="org-option-icon-wrap">
|
||||
<SpaceAvatar :name="org.name" :avatar="org.avatar" size="small" />
|
||||
</div>
|
||||
<div class="org-option-body">
|
||||
<div class="org-option-header">
|
||||
<span class="org-option-name">{{ org.name }}</span>
|
||||
<t-tag v-if="org.is_owner" theme="primary" size="small" variant="light">
|
||||
{{ $t('organization.owner') }}
|
||||
</t-tag>
|
||||
<t-tag v-else-if="org.my_role" :theme="org.my_role === 'admin' ? 'warning' : 'default'" size="small" variant="light">
|
||||
{{ $t(`organization.role.${org.my_role}`) }}
|
||||
</t-tag>
|
||||
</div>
|
||||
<div class="org-option-meta">
|
||||
<span class="org-meta-tag">
|
||||
<t-icon name="user" class="org-meta-icon org-meta-icon-user" />
|
||||
{{ org.member_count ?? 0 }}
|
||||
</span>
|
||||
<span class="org-meta-tag">
|
||||
<img src="@/assets/img/zhishiku.svg" class="org-meta-icon org-meta-icon-kb" alt="" aria-hidden="true" />
|
||||
{{ org.share_count ?? 0 }}
|
||||
</span>
|
||||
<span class="org-meta-tag">
|
||||
<t-icon name="control-platform" class="org-meta-icon org-meta-icon-agent" />
|
||||
{{ org.agent_share_count ?? 0 }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t-option>
|
||||
</t-select>
|
||||
</t-form-item>
|
||||
<t-form-item :label="$t('organization.share.permission')" name="permission">
|
||||
<t-radio-group v-model="shareForm.permission">
|
||||
<t-radio-button value="viewer">{{ $t('organization.share.permissionReadonly') }}</t-radio-button>
|
||||
<t-radio-button value="editor">{{ $t('organization.share.permissionEditable') }}</t-radio-button>
|
||||
</t-radio-group>
|
||||
</t-form-item>
|
||||
<div class="permission-tip">
|
||||
<t-icon name="info-circle" size="14px" />
|
||||
<span>{{ $t('organization.share.permissionTip') }}</span>
|
||||
</div>
|
||||
</t-form>
|
||||
<div class="share-actions">
|
||||
<t-button theme="default" @click="showShareList = true" v-if="shares.length > 0">
|
||||
{{ $t('organization.share.sharedTo') }} ({{ shares.length }})
|
||||
</t-button>
|
||||
<div class="spacer"></div>
|
||||
<t-button theme="default" @click="handleClose">{{ $t('common.cancel') }}</t-button>
|
||||
<t-button theme="primary" :loading="submitting" @click="handleShare">
|
||||
{{ $t('common.confirm') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Share list -->
|
||||
<div class="share-list" v-else>
|
||||
<div class="share-list-header">
|
||||
<t-button variant="text" @click="showShareList = false">
|
||||
<template #icon><t-icon name="chevron-left" /></template>
|
||||
{{ $t('common.back') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<div v-if="loadingShares" class="share-list-loading">
|
||||
<t-loading />
|
||||
</div>
|
||||
<div v-else-if="shares.length === 0" class="share-list-empty">
|
||||
{{ $t('organization.share.noShares') }}
|
||||
</div>
|
||||
<div v-else class="share-items">
|
||||
<div v-for="share in shares" :key="share.id" class="share-item">
|
||||
<div class="share-info">
|
||||
<SpaceAvatar
|
||||
:name="share.organization_name || ''"
|
||||
:avatar="orgStore.organizations.find(o => o.id === share.organization_id)?.avatar"
|
||||
size="small"
|
||||
/>
|
||||
<span class="share-org-name">{{ share.organization_name }}</span>
|
||||
<t-tag :theme="share.permission === 'editor' ? 'warning' : 'default'" size="small">
|
||||
{{ share.permission === 'editor' ? $t('organization.share.permissionEditable') : $t('organization.share.permissionReadonly') }}
|
||||
</t-tag>
|
||||
</div>
|
||||
<div class="share-actions">
|
||||
<t-tooltip :content="$t('organization.settings.editTitle')" placement="top">
|
||||
<t-button variant="text" theme="default" size="small" @click="handleGoToOrgSettings(share.organization_id)">
|
||||
<t-icon name="setting" />
|
||||
</t-button>
|
||||
</t-tooltip>
|
||||
<t-button
|
||||
variant="text"
|
||||
theme="danger"
|
||||
size="small"
|
||||
@click="handleUnshare(share)"
|
||||
>
|
||||
<t-icon name="close" />
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
import { shareKnowledgeBase, listKBShares, removeShare } from '@/api/organization'
|
||||
import type { KnowledgeBaseShare } from '@/api/organization'
|
||||
import SpaceAvatar from '@/components/SpaceAvatar.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const router = useRouter()
|
||||
const orgStore = useOrganizationStore()
|
||||
|
||||
interface Props {
|
||||
visible: boolean
|
||||
knowledgeBaseId: string
|
||||
knowledgeBaseName?: string
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void
|
||||
(e: 'shared'): void
|
||||
}>()
|
||||
|
||||
const dialogVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: (val) => emit('update:visible', val)
|
||||
})
|
||||
|
||||
const shareFormRef = ref()
|
||||
const loadingOrgs = ref(false)
|
||||
const loadingShares = ref(false)
|
||||
const submitting = ref(false)
|
||||
const showShareList = ref(false)
|
||||
const shares = ref<(KnowledgeBaseShare & { organization_name?: string })[]>([])
|
||||
|
||||
const shareForm = ref({
|
||||
organization_id: '',
|
||||
permission: 'viewer' as 'admin' | 'editor' | 'viewer'
|
||||
})
|
||||
|
||||
// Only show organizations where user can share (editor or admin); exclude viewer-only orgs and already shared
|
||||
const availableOrganizations = computed(() => {
|
||||
const sharedOrgIds = new Set(shares.value.map(s => s.organization_id))
|
||||
return orgStore.organizations.filter(
|
||||
(org) =>
|
||||
!sharedOrgIds.has(org.id) &&
|
||||
(org.is_owner === true || org.my_role === 'admin' || org.my_role === 'editor')
|
||||
)
|
||||
})
|
||||
|
||||
watch(() => props.visible, async (newVal) => {
|
||||
if (newVal) {
|
||||
showShareList.value = false
|
||||
shareForm.value = { organization_id: '', permission: 'viewer' }
|
||||
await Promise.all([
|
||||
loadOrganizations(),
|
||||
loadShares()
|
||||
])
|
||||
}
|
||||
})
|
||||
|
||||
async function loadOrganizations() {
|
||||
loadingOrgs.value = true
|
||||
try {
|
||||
await orgStore.fetchOrganizations()
|
||||
} finally {
|
||||
loadingOrgs.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function loadShares() {
|
||||
if (!props.knowledgeBaseId) return
|
||||
loadingShares.value = true
|
||||
try {
|
||||
const result = await listKBShares(props.knowledgeBaseId)
|
||||
if (result.success && result.data) {
|
||||
// Enrich shares with organization names
|
||||
shares.value = result.data.shares.map((share: KnowledgeBaseShare) => ({
|
||||
...share,
|
||||
organization_name: orgStore.organizations.find(o => o.id === share.organization_id)?.name || share.organization_id
|
||||
}))
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load shares:', e)
|
||||
} finally {
|
||||
loadingShares.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleShare() {
|
||||
const valid = await shareFormRef.value?.validate()
|
||||
if (valid !== true) return
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const result = await shareKnowledgeBase(
|
||||
props.knowledgeBaseId,
|
||||
{ organization_id: shareForm.value.organization_id, permission: shareForm.value.permission }
|
||||
)
|
||||
if (result.success) {
|
||||
MessagePlugin.success(t('organization.share.shareSuccess'))
|
||||
await loadShares()
|
||||
shareForm.value = { organization_id: '', permission: 'viewer' }
|
||||
emit('shared')
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.share.shareFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.share.shareFailed'))
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleUnshare(share: KnowledgeBaseShare) {
|
||||
try {
|
||||
const result = await removeShare(props.knowledgeBaseId, share.id)
|
||||
if (result.success) {
|
||||
MessagePlugin.success(t('organization.share.unshareSuccess'))
|
||||
await loadShares()
|
||||
emit('shared')
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.share.unshareFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.share.unshareFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
// Navigate to organization settings
|
||||
function handleGoToOrgSettings(orgId: string) {
|
||||
router.push({
|
||||
path: '/platform/organizations',
|
||||
query: { orgId }
|
||||
})
|
||||
// 关闭当前弹窗
|
||||
emit('update:visible', false)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.share-form {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.permission-tip {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
background: var(--td-bg-color-container-hover);
|
||||
border-radius: var(--app-radius-sm);
|
||||
margin-top: 8px;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: var(--app-text-md);
|
||||
line-height: 1.5;
|
||||
|
||||
.t-icon {
|
||||
flex-shrink: 0;
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.share-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 24px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--td-component-stroke);
|
||||
|
||||
.spacer {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.share-list-header {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.share-list-loading,
|
||||
.share-list-empty {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 32px;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.share-items {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
max-height: 280px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.share-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 14px 16px;
|
||||
background: var(--td-bg-color-container-hover);
|
||||
border: 1px solid var(--td-component-stroke);
|
||||
border-radius: var(--app-radius-md);
|
||||
transition: background var(--app-motion-base), border-color var(--app-motion-base);
|
||||
}
|
||||
|
||||
.share-item:hover {
|
||||
background: var(--td-bg-color-container-active);
|
||||
border-color: var(--td-component-stroke);
|
||||
}
|
||||
|
||||
.share-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.share-org-name {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.share-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
// Custom option styles for organization select (compact)
|
||||
:deep(.t-select-option) {
|
||||
height: auto;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
border-radius: var(--app-radius-xs);
|
||||
margin: 1px 6px;
|
||||
transition: background var(--app-motion-fast) ease;
|
||||
}
|
||||
|
||||
:deep(.t-select-option:hover),
|
||||
:deep(.t-select-option.t-is-selected) {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
}
|
||||
|
||||
:deep(.t-select-option__content) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.org-option-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0;
|
||||
min-width: 260px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.org-option-icon-wrap {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.org-option-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.org-option-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 2px;
|
||||
|
||||
.org-option-name {
|
||||
font-family: var(--app-font-family);
|
||||
font-size: var(--app-text-md);
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.org-option-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-family: var(--app-font-family);
|
||||
font-size: var(--app-text-sm);
|
||||
color: var(--td-text-color-placeholder);
|
||||
|
||||
.org-meta-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 0px 4px;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: var(--app-radius-xs);
|
||||
}
|
||||
|
||||
.org-meta-icon {
|
||||
flex-shrink: 0;
|
||||
vertical-align: middle;
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
.org-meta-icon-user {
|
||||
font-size: var(--app-text-sm);
|
||||
}
|
||||
|
||||
.org-meta-icon-kb {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.org-meta-icon-agent {
|
||||
font-size: var(--app-text-sm);
|
||||
color: var(--td-text-color-secondary);
|
||||
opacity: 0.75;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
// Global styles for organization select dropdown (compact)
|
||||
.org-select-dropdown-popup.t-select__dropdown {
|
||||
padding: 4px 0;
|
||||
max-height: 320px;
|
||||
overflow-y: auto;
|
||||
border-radius: var(--app-radius-sm);
|
||||
box-shadow: var(--td-shadow-2);
|
||||
}
|
||||
|
||||
.org-select-dropdown-popup .t-select-option {
|
||||
height: auto;
|
||||
align-items: center;
|
||||
padding: 6px 12px;
|
||||
border-radius: var(--app-radius-xs);
|
||||
margin: 1px 6px;
|
||||
}
|
||||
|
||||
.org-select-dropdown-popup .t-select-option__content {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -56,7 +56,6 @@
|
|||
}
|
||||
.card-title:has(.card-title-text) { display: flex; align-items: center; gap: 6px; }
|
||||
.card-title-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
||||
.permission-tag { flex-shrink: 0; }
|
||||
.card-content {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
|
@ -86,7 +85,6 @@
|
|||
border-top: 1px solid color-mix(in srgb, var(--td-component-stroke) 60%, transparent);
|
||||
}
|
||||
.feature-badges { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
|
||||
.card-time { color: var(--td-text-color-placeholder); font-size: var(--app-text-sm); }
|
||||
|
||||
.builtin-avatar,
|
||||
.org-avatar,
|
||||
|
|
@ -100,7 +98,6 @@
|
|||
}
|
||||
|
||||
.more-wrap,
|
||||
.card-more-btn,
|
||||
.shared-detail-trigger {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
|
|
|
|||
|
|
@ -73,8 +73,7 @@
|
|||
:key="agent.isMine ? agent.id : `shared-${agent.share_id}`">
|
||||
<!-- 内置:始终置顶。filteredAgents 在 all 视图里已经把
|
||||
builtin 排到最前;这里只在第一张 builtin 之前打一次标题。 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& agent.isMine
|
||||
<div v-if="agent.isMine
|
||||
&& agent.is_builtin
|
||||
&& (index === 0
|
||||
|| !filteredAgents[index - 1].isMine
|
||||
|
|
@ -91,8 +90,7 @@
|
|||
<!-- 我创建的:当前 agent 是本空间 + 非内置 + 我亲手创建,且前一张
|
||||
要么不存在、要么不是本空间、要么是内置(builtin → mine 过渡)、
|
||||
要么是同事创建。与 KB 列表对齐。 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& agent.isMine
|
||||
<div v-if="agent.isMine
|
||||
&& !agent.is_builtin
|
||||
&& isMyAgent(agent)
|
||||
&& (index === 0
|
||||
|
|
@ -109,8 +107,7 @@
|
|||
:name="isAgentSectionCollapsed('mine') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 本空间 · 仅查看 / 其他成员:本空间里非内置且非我创建的同事 agent。 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& agent.isMine
|
||||
<div v-if="agent.isMine
|
||||
&& !agent.is_builtin
|
||||
&& !isMyAgent(agent)
|
||||
&& (index === 0
|
||||
|
|
@ -127,8 +124,7 @@
|
|||
:name="isAgentSectionCollapsed('tenantOthers') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 共享给我 · 可编辑:仅在「全部」视图过渡处显示分组标题 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !agent.isMine
|
||||
<div v-if="!agent.isMine
|
||||
&& isSharedAgentEditable((agent as any).permission)
|
||||
&& (index === 0 || filteredAgents[index - 1].isMine)" class="agent-section-header" role="button"
|
||||
tabindex="0" :aria-expanded="!isAgentSectionCollapsed('sharedEditable')" @click="toggleAgentSection('sharedEditable')"
|
||||
|
|
@ -142,8 +138,7 @@
|
|||
:name="isAgentSectionCollapsed('sharedEditable') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 共享给我 · 仅查看 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !agent.isMine
|
||||
<div v-if="!agent.isMine
|
||||
&& !isSharedAgentEditable((agent as any).permission)
|
||||
&& (index === 0
|
||||
|| filteredAgents[index - 1].isMine
|
||||
|
|
@ -299,8 +294,7 @@
|
|||
<div v-if="spaceSelection === 'mine' && sortedMineAgents.length > 0" class="agent-card-wrap">
|
||||
<template v-for="(agent, index) in sortedMineAgents" :key="agent.id">
|
||||
<!-- 内置:始终置顶。sortedMineAgents 已按 内置→我→同事 排序。 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& agent.is_builtin
|
||||
<div v-if="agent.is_builtin
|
||||
&& (index === 0 || !sortedMineAgents[index - 1].is_builtin)" class="agent-section-header" role="button"
|
||||
tabindex="0" :aria-expanded="!isAgentSectionCollapsed('builtin')" @click="toggleAgentSection('builtin')"
|
||||
@keydown.enter.prevent="toggleAgentSection('builtin')"
|
||||
|
|
@ -312,8 +306,7 @@
|
|||
:name="isAgentSectionCollapsed('builtin') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 我创建的:第一张非内置且我亲手创建的卡片前打标题 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !agent.is_builtin
|
||||
<div v-if="!agent.is_builtin
|
||||
&& isMyAgent(agent)
|
||||
&& (index === 0
|
||||
|| sortedMineAgents[index - 1].is_builtin
|
||||
|
|
@ -328,8 +321,7 @@
|
|||
:name="isAgentSectionCollapsed('mine') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 本空间 · 仅查看 / 其他成员:非内置且非我创建的同事 agent -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !agent.is_builtin
|
||||
<div v-if="!agent.is_builtin
|
||||
&& !isMyAgent(agent)
|
||||
&& (index === 0
|
||||
|| sortedMineAgents[index - 1].is_builtin
|
||||
|
|
@ -472,7 +464,7 @@
|
|||
<div v-else-if="spaceSelectionOrgId && sortedSpaceAgentsList.length > 0" class="agent-card-wrap">
|
||||
<template v-for="(shared, index) in sortedSpaceAgentsList" :key="'shared-' + shared.share_id">
|
||||
<!-- 我共享的:当前用户共享进本空间的智能体,只在首条 is_mine 上挂标题 -->
|
||||
<div v-if="showShareGroupHeaders && shared.is_mine && index === 0" class="agent-section-header"
|
||||
<div v-if="shared.is_mine && index === 0" class="agent-section-header"
|
||||
role="button" tabindex="0" :aria-expanded="!isAgentSectionCollapsed('sharedByMe')" @click="toggleAgentSection('sharedByMe')"
|
||||
@keydown.enter.prevent="toggleAgentSection('sharedByMe')"
|
||||
@keydown.space.prevent="toggleAgentSection('sharedByMe')">
|
||||
|
|
@ -483,8 +475,7 @@
|
|||
:name="isAgentSectionCollapsed('sharedByMe') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 共享给我 · 可编辑:首次从 is_mine 进入共享 + editable -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !shared.is_mine
|
||||
<div v-if="!shared.is_mine
|
||||
&& isSharedAgentEditable(shared.permission)
|
||||
&& (index === 0 || sortedSpaceAgentsList[index - 1].is_mine)" class="agent-section-header" role="button"
|
||||
tabindex="0" :aria-expanded="!isAgentSectionCollapsed('sharedEditable')" @click="toggleAgentSection('sharedEditable')"
|
||||
|
|
@ -498,8 +489,7 @@
|
|||
:name="isAgentSectionCollapsed('sharedEditable') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 共享给我 · 仅查看:首次从可编辑 / is_mine 进入 viewer -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !shared.is_mine
|
||||
<div v-if="!shared.is_mine
|
||||
&& !isSharedAgentEditable(shared.permission)
|
||||
&& (index === 0
|
||||
|| sortedSpaceAgentsList[index - 1].is_mine
|
||||
|
|
@ -744,7 +734,6 @@ import EmptyState from '@/components/EmptyState.vue'
|
|||
import { useConfirmDelete } from '@/components/settings/useConfirmDelete'
|
||||
import { deleteAgent, copyAgent, type CustomAgent } from '@/api/agent'
|
||||
import { useChatResourcesStore } from '@/stores/chatResources'
|
||||
import { formatStringDate } from '@/utils/index'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { createSessions } from '@/api/chat/index'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
|
|
@ -822,12 +811,6 @@ const spaceSelectionOrgId = computed(() => {
|
|||
return !!s && !RESERVED_SCOPES.has(s)
|
||||
})
|
||||
|
||||
const sharedAgentsByOrg = computed(() => {
|
||||
const orgId = spaceSelection.value
|
||||
if (orgId === 'all' || orgId === 'mine') return []
|
||||
return sharedAgents.value.filter(s => s.organization_id === orgId)
|
||||
})
|
||||
|
||||
// 空间视角:该空间内全部智能体(含我共享的),选中空间时请求新接口
|
||||
const spaceAgentsList = ref<OrganizationSharedAgentItem[]>([])
|
||||
const spaceAgentsLoading = ref(false)
|
||||
|
|
@ -1177,7 +1160,6 @@ onUnmounted(() => {
|
|||
window.removeEventListener('openAgentEditor', handleOpenAgentEditor as EventListener)
|
||||
})
|
||||
|
||||
|
||||
const handleCardClick = (agent: DisplayAgent | AgentWithUI) => {
|
||||
if (openMoreAgentId.value === agent.id) return
|
||||
// Track recency before any branch — Recents should reflect what the
|
||||
|
|
@ -1295,7 +1277,7 @@ function showAgentOriginBadge(agent: { created_by?: string; creator_name?: strin
|
|||
section: agentSectionOf(agent),
|
||||
variant: agentOriginVariant(agent),
|
||||
creatorName: (agent as any).creator_name,
|
||||
showSectionHeaders: showShareGroupHeaders.value,
|
||||
showSectionHeaders: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -1304,20 +1286,15 @@ function showAgentBuiltinBadge(agent: { is_builtin?: boolean }): boolean {
|
|||
return shouldShowResourceOriginBadge({
|
||||
section: agentSectionOf(agent),
|
||||
variant: 'mine',
|
||||
showSectionHeaders: showShareGroupHeaders.value,
|
||||
showSectionHeaders: true,
|
||||
})
|
||||
}
|
||||
|
||||
// 共享 agent 的可编辑/只读分组开关,与 KB 列表逻辑保持一致:仅对
|
||||
// contributor / editor 中间档展示分组标题。Viewer / Admin+ 不分组。
|
||||
// 按共享资源的实际权限划分可编辑和只读分组。
|
||||
const AGENT_EDITABLE_PERMS = new Set(['admin', 'editor'])
|
||||
function isSharedAgentEditable(perm: string | undefined): boolean {
|
||||
return !!perm && AGENT_EDITABLE_PERMS.has(perm)
|
||||
}
|
||||
// 与 KnowledgeBaseList 同理:分组标题对所有角色生效,依据"创建者 + 来源"
|
||||
// 这种客观信息分段,不再按当前用户的可写权限筛掉。
|
||||
const showShareGroupHeaders = computed(() => true)
|
||||
|
||||
// 同空间、非当前用户创建的 Agent 分组标题。
|
||||
// contributor / viewer 在本空间里对这些 Agent 没有写权限,所以打"仅查看";
|
||||
// admin / owner 对整个空间都有编辑权限,"仅查看"反而误导,统一改成
|
||||
|
|
@ -1497,11 +1474,6 @@ const handleEditorSuccess = (agent?: CustomAgent) => {
|
|||
fetchList(true)
|
||||
}
|
||||
|
||||
const formatDate = (dateStr: string) => {
|
||||
if (!dateStr) return ''
|
||||
return formatStringDate(new Date(dateStr))
|
||||
}
|
||||
|
||||
// 暴露创建方法供外部调用
|
||||
const openCreateModal = () => {
|
||||
editingAgent.value = null
|
||||
|
|
@ -1554,17 +1526,6 @@ watch(keyword, () => { collapsedAgentSections.value = new Set() })
|
|||
background: var(--td-bg-color-container);
|
||||
}
|
||||
|
||||
.shared-by-me-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 6px;
|
||||
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
|
||||
border-radius: var(--app-radius-xs);
|
||||
font-size: var(--app-text-sm);
|
||||
color: var(--td-brand-color);
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
@ -1642,39 +1603,6 @@ watch(keyword, () => { collapsedAgentSections.value = new Set() })
|
|||
}
|
||||
}
|
||||
|
||||
.agent-tabs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
margin-bottom: 20px;
|
||||
|
||||
.tab-item {
|
||||
padding: 12px 0;
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-family: var(--app-font-family);
|
||||
font-size: var(--app-text-base);
|
||||
font-weight: 400;
|
||||
transition: color var(--app-motion-base);
|
||||
|
||||
&:hover {
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 600;
|
||||
border-bottom: 2px solid var(--td-brand-color);
|
||||
margin-bottom: -1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.shared-badge {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.card-bottom-source {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
|
@ -1699,38 +1627,11 @@ watch(keyword, () => { collapsedAgentSections.value = new Set() })
|
|||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.custom-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 3px;
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--app-radius-lg);
|
||||
background: var(--td-bg-color-container-hover);
|
||||
color: var(--td-text-color-secondary);
|
||||
font-family: var(--app-font-family);
|
||||
font-size: var(--app-text-xs);
|
||||
font-weight: 500;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// 共享给我 · 可编辑 / 仅查看 分组标题,与 KB 列表 .kb-section-header 对齐。
|
||||
.agent-section-header {
|
||||
.resource-section-header();
|
||||
}
|
||||
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(6px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.agent-card-wrap {
|
||||
.resource-card-grid();
|
||||
}
|
||||
|
|
@ -1740,22 +1641,8 @@ watch(keyword, () => { collapsedAgentSections.value = new Set() })
|
|||
.resource-card();
|
||||
|
||||
.agent-favorite-star { .resource-favorite-button(); }
|
||||
|
||||
.builtin-avatar {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: var(--app-radius-md);
|
||||
}
|
||||
|
||||
.edit-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: var(--app-radius-md);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.builtin-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
|
@ -1771,13 +1658,7 @@ watch(keyword, () => { collapsedAgentSections.value = new Set() })
|
|||
}
|
||||
|
||||
.builtin-avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: var(--app-radius-md);
|
||||
flex-shrink: 0;
|
||||
|
||||
&.agent-emoji {
|
||||
font-size: var(--app-text-2xl);
|
||||
|
|
@ -1796,24 +1677,6 @@ watch(keyword, () => { collapsedAgentSections.value = new Set() })
|
|||
}
|
||||
}
|
||||
|
||||
.edit-btn {
|
||||
display: flex;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: var(--app-radius-md);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: all var(--app-motion-base) ease;
|
||||
color: var(--td-text-color-disabled);
|
||||
|
||||
&:hover {
|
||||
background: var(--td-bg-color-container-hover);
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
/* 与知识库卡片内容区一致 */
|
||||
/* 三个列表卡片统一:描述字体 */
|
||||
.bottom-left {
|
||||
|
|
@ -1880,17 +1743,12 @@ watch(keyword, () => { collapsedAgentSections.value = new Set() })
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// 删除确认对话框样式
|
||||
:deep(.t-dialog__position.t-dialog--top) {
|
||||
padding-top: 40vh !important;
|
||||
}
|
||||
|
||||
|
||||
.resource-list-header();
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.agent-card-wrap { animation: none; }
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
|
|
|||
|
|
@ -77,12 +77,9 @@
|
|||
仅查看 / 共享给我)各自打自己的标题;原本的「其他」过渡标题
|
||||
在 per-user 置顶模型下已无意义,删除以免和具体子段标题叠加。 -->
|
||||
<template v-for="(kb, index) in filteredKnowledgeBases" :key="kb.id">
|
||||
<!-- 我创建的:第一张「我创建」非置顶卡片前打标题,统一展示
|
||||
不管上方是否存在「已置顶」段。与「本空间 · 仅查看」同样
|
||||
仅在 contributor 视图下出现——admin/owner 视图原本就没有
|
||||
任何分段标题,单独冒一个反而失衡。 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& kb.isMine
|
||||
<!-- 我创建的:第一张「我创建」非置顶卡片前打标题,
|
||||
对所有角色显示,不受上方是否存在「已置顶」分组影响。 -->
|
||||
<div v-if="kb.isMine
|
||||
&& isMyKb(kb as KB)
|
||||
&& !kb.is_pinned
|
||||
&& (index === 0
|
||||
|
|
@ -100,8 +97,7 @@
|
|||
当前卡片必须是非置顶(否则归在「已置顶」),且前一张要么
|
||||
不存在、要么是「共享给我」、要么是我创建、要么是置顶卡片
|
||||
(置顶→非置顶的过渡同样要打这个标题)。 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& kb.isMine
|
||||
<div v-if="kb.isMine
|
||||
&& !isMyKb(kb as KB)
|
||||
&& !kb.is_pinned
|
||||
&& (index === 0
|
||||
|
|
@ -118,8 +114,7 @@
|
|||
:name="isKbSectionCollapsed('tenantOthers') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 共享给我 · 可编辑:从「我的(含同事)」首次过渡到共享 + 可编辑 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !kb.isMine
|
||||
<div v-if="!kb.isMine
|
||||
&& isSharedKbEditable((kb as any).permission)
|
||||
&& (index === 0 || filteredKnowledgeBases[index - 1].isMine)" class="kb-section-header" role="button"
|
||||
tabindex="0" :aria-expanded="!isKbSectionCollapsed('sharedEditable')" @click="toggleKbSection('sharedEditable')"
|
||||
|
|
@ -133,8 +128,7 @@
|
|||
:name="isKbSectionCollapsed('sharedEditable') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 共享给我 · 仅查看:从「可编辑共享 / 我的」过渡到 viewer 共享 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !kb.isMine
|
||||
<div v-if="!kb.isMine
|
||||
&& !isSharedKbEditable((kb as any).permission)
|
||||
&& (index === 0
|
||||
|| filteredKnowledgeBases[index - 1].isMine
|
||||
|
|
@ -356,8 +350,7 @@
|
|||
<!-- 我创建的:第一张非置顶的我创建卡片前打标题,无论上方是否
|
||||
有「已置顶」段都要显示,和「本空间 · 仅查看」对齐——见
|
||||
「全部」tab 同处注释。 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& isMyKb(kb)
|
||||
<div v-if="isMyKb(kb)
|
||||
&& !kb.is_pinned
|
||||
&& (index === 0 || sortedMineKbs[index - 1].is_pinned)" class="kb-section-header" role="button"
|
||||
tabindex="0" :aria-expanded="!isKbSectionCollapsed('mine')" @click="toggleKbSection('mine')"
|
||||
|
|
@ -371,8 +364,7 @@
|
|||
</div>
|
||||
<!-- 本空间 · 仅查看:当前非置顶的同事 KB,且前一张要么不存在、
|
||||
要么是我创建、要么是置顶卡片(置顶→非置顶过渡)。 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !isMyKb(kb)
|
||||
<div v-if="!isMyKb(kb)
|
||||
&& !kb.is_pinned
|
||||
&& (index === 0
|
||||
|| isMyKb(sortedMineKbs[index - 1])
|
||||
|
|
@ -505,7 +497,7 @@
|
|||
<template v-for="(shared, index) in sortedSpaceKbsList"
|
||||
:key="'shared-' + (shared.share_id || `agent-${shared.knowledge_base?.id}-${shared.source_from_agent?.agent_id || ''}`)">
|
||||
<!-- 我共享的:本空间下我自己创建并共享进来的条目,只在第一条 is_mine 上挂标题 -->
|
||||
<div v-if="showShareGroupHeaders && shared.is_mine && index === 0" class="kb-section-header"
|
||||
<div v-if="shared.is_mine && index === 0" class="kb-section-header"
|
||||
role="button" tabindex="0" :aria-expanded="!isKbSectionCollapsed('sharedByMe')" @click="toggleKbSection('sharedByMe')"
|
||||
@keydown.enter.prevent="toggleKbSection('sharedByMe')"
|
||||
@keydown.space.prevent="toggleKbSection('sharedByMe')">
|
||||
|
|
@ -516,8 +508,7 @@
|
|||
:name="isKbSectionCollapsed('sharedByMe') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 共享给我 · 可编辑:从「我的」首次进入「共享 + 可编辑」 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !shared.is_mine
|
||||
<div v-if="!shared.is_mine
|
||||
&& isSharedKbEditable(shared.permission)
|
||||
&& (index === 0 || sortedSpaceKbsList[index - 1].is_mine)" class="kb-section-header"
|
||||
role="button" tabindex="0" :aria-expanded="!isKbSectionCollapsed('sharedEditable')" @click="toggleKbSection('sharedEditable')"
|
||||
|
|
@ -531,8 +522,7 @@
|
|||
:name="isKbSectionCollapsed('sharedEditable') ? 'chevron-right' : 'chevron-down'" size="14px" />
|
||||
</div>
|
||||
<!-- 共享给我 · 仅查看:从「可编辑共享 / 我的」首次进入「viewer」 -->
|
||||
<div v-if="showShareGroupHeaders
|
||||
&& !shared.is_mine
|
||||
<div v-if="!shared.is_mine
|
||||
&& !isSharedKbEditable(shared.permission)
|
||||
&& (index === 0
|
||||
|| sortedSpaceKbsList[index - 1].is_mine
|
||||
|
|
@ -635,10 +625,6 @@
|
|||
:kb-id="uiStore.currentKBId || undefined" :initial-type="uiStore.kbEditorType"
|
||||
@update:visible="(val) => val ? null : uiStore.closeKBEditor()" @success="handleKBEditorSuccess" />
|
||||
|
||||
<!-- 共享知识库对话框 -->
|
||||
<ShareKnowledgeBaseDialog v-model:visible="shareDialogVisible" :knowledge-base-id="sharingKbId"
|
||||
:knowledge-base-name="sharingKbName" @shared="handleShareSuccess" />
|
||||
|
||||
<!-- 右侧:共享知识库详情面板 -->
|
||||
<Teleport to="body">
|
||||
<Transition name="shared-detail-drawer">
|
||||
|
|
@ -727,7 +713,6 @@ import { listOrganizationSharedKnowledgeBases, type SharedKnowledgeBase, type Or
|
|||
import { mergeAllScopeKnowledgeBases, type OwnedKnowledgeBase, type SharedKnowledgeBaseLike } from './kbListMerge'
|
||||
import KnowledgeBaseEditorModal from './KnowledgeBaseEditorModal.vue'
|
||||
import KbWikiBadge from './components/KbWikiBadge.vue'
|
||||
import ShareKnowledgeBaseDialog from '@/components/ShareKnowledgeBaseDialog.vue'
|
||||
import ResourceListToolbar from '@/components/ResourceListToolbar.vue'
|
||||
import { matchesResourceQuery } from '@/utils/resourceListSearch'
|
||||
import ResourceOriginBadge from '@/components/ResourceOriginBadge.vue'
|
||||
|
|
@ -811,11 +796,6 @@ const highlightedKbId = ref<string | null>(null)
|
|||
const highlightedCardRef = ref<HTMLElement | null>(null)
|
||||
let uploadRefreshTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
// Share dialog state
|
||||
const shareDialogVisible = ref(false)
|
||||
const sharingKbId = ref('')
|
||||
const sharingKbName = ref('')
|
||||
|
||||
// Shared knowledge bases (everything cross-tenant shared to me, including
|
||||
// viewer-only). Used by the per-space views and the "all" aggregate so
|
||||
// readers still see read-only shares — those are valid resources, just
|
||||
|
|
@ -835,13 +815,6 @@ const spaceSelectionOrgId = computed(() => {
|
|||
return !!s && !RESERVED_SCOPES.has(s)
|
||||
})
|
||||
|
||||
// 当前空间下共享给我的知识库(旧:仅他人共享;保留用于兼容)
|
||||
const sharedKbsByOrg = computed(() => {
|
||||
const orgId = spaceSelection.value
|
||||
if (orgId === 'all' || orgId === 'mine') return []
|
||||
return sharedKbs.value.filter(s => s.organization_id === orgId)
|
||||
})
|
||||
|
||||
// 空间视角:该空间内全部知识库(含我共享的),选中空间时请求新接口
|
||||
const spaceKbsList = ref<OrganizationSharedKnowledgeBaseItem[]>([])
|
||||
const spaceKbsLoading = ref(false)
|
||||
|
|
@ -994,17 +967,6 @@ function isSharedKbEditable(perm: string | undefined): boolean {
|
|||
return !!perm && EDITABLE_PERMS.has(perm)
|
||||
}
|
||||
|
||||
// 是否在共享区展示「可编辑 / 仅查看」二级分组:仅对中间档(contributor / editor)
|
||||
// 有意义。viewer 反正都是只读,admin / owner 视角统一管理,分组反而碎。
|
||||
// 这里只是 UI 呈现,权限由后端兜底,不要把它当成安全边界。
|
||||
// 分组标题对所有角色生效——置顶 / 我创建的 / 本空间 · 仅查看 / 共享给我
|
||||
// 都是基于"创建者 + 来源"的客观信息,不依赖当前用户的可写权限。
|
||||
// 原本只对 contributor 显示是为了在 admin/owner 那里隐藏"仅查看"这个权限
|
||||
// 暗示——但实际上 admin/owner 也会想区分自己创建 vs 同事创建的卡片,所以
|
||||
// 现在统一打开。如果哪天需要把权限色彩从标题里拿掉,就改 i18n 文案即可,
|
||||
// 不需要再回头碰这个 computed。
|
||||
const showShareGroupHeaders = computed(() => true)
|
||||
|
||||
// 同空间、非当前用户创建的 KB 分组标题。
|
||||
// contributor / viewer 在本空间里对这些 KB 没有写权限,所以打"仅查看";
|
||||
// admin / owner 反而对整个空间都有编辑权限,"仅查看"会反复误导他们以为
|
||||
|
|
@ -1293,7 +1255,7 @@ function showKbOriginBadge(kb: { creator_id?: string; creator_name?: string }):
|
|||
section: kbSectionOf(kb),
|
||||
variant: kbOriginVariant(kb),
|
||||
creatorName: kb.creator_name,
|
||||
showSectionHeaders: showShareGroupHeaders.value,
|
||||
showSectionHeaders: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -1364,19 +1326,6 @@ const duplicateKB = async (id: string) => {
|
|||
}
|
||||
}
|
||||
|
||||
const handleShare = (kb: KB) => {
|
||||
// 手动关闭弹窗
|
||||
kb.showMore = false
|
||||
sharingKbId.value = kb.id
|
||||
sharingKbName.value = kb.name
|
||||
shareDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleShareSuccess = () => {
|
||||
// 共享成功后可刷新列表
|
||||
fetchList(true)
|
||||
}
|
||||
|
||||
const handleSharedKbClick = (sharedKb: SharedKnowledgeBase) => {
|
||||
pins.touchRecent('kb', sharedKb.knowledge_base.id)
|
||||
// 跳转到共享知识库详情页
|
||||
|
|
@ -1621,17 +1570,6 @@ watch(keyword, () => { collapsedKbSections.value = new Set() })
|
|||
background: var(--td-bg-color-container);
|
||||
}
|
||||
|
||||
.shared-by-me-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 6px;
|
||||
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
|
||||
border-radius: var(--app-radius-xs);
|
||||
font-size: var(--app-text-sm);
|
||||
color: var(--td-brand-color);
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
margin: 0;
|
||||
color: var(--td-text-color-placeholder);
|
||||
|
|
@ -1669,68 +1607,6 @@ watch(keyword, () => { collapsedKbSections.value = new Set() })
|
|||
}
|
||||
}
|
||||
|
||||
// Tab 切换样式(已由左侧菜单替代,保留以备兼容)
|
||||
.kb-tabs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
margin-bottom: 20px;
|
||||
|
||||
.tab-item {
|
||||
padding: 12px 0;
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-family: var(--app-font-family);
|
||||
font-size: var(--app-text-base);
|
||||
font-weight: 400;
|
||||
user-select: none;
|
||||
position: relative;
|
||||
transition: color var(--app-motion-base) ease;
|
||||
|
||||
&:hover {
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 500;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -1px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 2px;
|
||||
background: var(--td-brand-color);
|
||||
border-radius: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 共享知识库卡片样式
|
||||
// 共享标识(文档类型默认绿色,位置贴右上角)
|
||||
.shared-badge {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 2px 8px;
|
||||
background: color-mix(in srgb, var(--td-brand-color) 10%, transparent);
|
||||
border-radius: var(--app-radius-xs);
|
||||
font-size: var(--app-text-sm);
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 500;
|
||||
|
||||
.t-icon {
|
||||
color: var(--td-brand-color);
|
||||
}
|
||||
}
|
||||
|
||||
// 来源组织(空间图标 + 空间名)
|
||||
.org-source {
|
||||
display: inline-flex;
|
||||
|
|
@ -1765,30 +1641,6 @@ watch(keyword, () => { collapsedKbSections.value = new Set() })
|
|||
}
|
||||
}
|
||||
|
||||
// 「我的」知识库标签(与 .org-source 同套样式:灰字 + 绿标 + 浅绿底)
|
||||
.personal-source {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 3px 8px;
|
||||
background: color-mix(in srgb, var(--td-brand-color) 6%, transparent);
|
||||
border-radius: var(--app-radius-sm);
|
||||
font-size: var(--app-text-xs);
|
||||
line-height: 1.4;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-weight: 500;
|
||||
transition: background-color var(--app-motion-fast) ease;
|
||||
|
||||
span {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.t-icon {
|
||||
color: var(--td-brand-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.shared-kb-card {
|
||||
position: relative;
|
||||
|
||||
|
|
@ -1826,18 +1678,6 @@ watch(keyword, () => { collapsedKbSections.value = new Set() })
|
|||
}
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(6px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.kb-card-wrap {
|
||||
.resource-card-grid();
|
||||
}
|
||||
|
|
@ -2013,17 +1853,12 @@ watch(keyword, () => { collapsedKbSections.value = new Set() })
|
|||
box-shadow: 0 0 12px color-mix(in srgb, var(--td-brand-color) 30%, transparent) !important;
|
||||
}
|
||||
|
||||
|
||||
// 删除确认对话框样式
|
||||
:deep(.t-dialog__position.t-dialog--top) {
|
||||
padding-top: 40vh !important;
|
||||
}
|
||||
|
||||
|
||||
.resource-list-header();
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.kb-card-wrap { animation: none; }
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
|
@ -2194,19 +2029,4 @@ watch(keyword, () => { collapsedKbSections.value = new Set() })
|
|||
}
|
||||
}
|
||||
|
||||
// 创建对话框样式优化
|
||||
.create-kb-dialog {
|
||||
.t-form-item__label {
|
||||
font-family: var(--app-font-family);
|
||||
font-size: var(--app-text-base);
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.t-input,
|
||||
.t-textarea {
|
||||
font-family: var(--app-font-family);
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<ResourceListToolbar mode="organization" :model-value="spaceSelection" @update:model-value="value => spaceSelection = value === 'created' || value === 'joined' ? value : 'all'" v-model:query="keyword" :count-all="organizations.length"
|
||||
:count-created="createdCount" :count-joined="joinedCount" />
|
||||
<div class="org-list-main">
|
||||
<EmptyState v-if="keyword.trim() && !(loading) && visibleResultCount === 0" icon="search"
|
||||
<EmptyState v-if="keyword.trim() && !loading && filteredOrganizations.length === 0" icon="search"
|
||||
:title="$t('common.noResult')">
|
||||
<t-button variant="outline" @click="keyword = ''">{{ $t('common.clear') }}</t-button>
|
||||
</EmptyState>
|
||||
|
|
@ -81,7 +81,6 @@
|
|||
<div v-show="!isOrgRowHidden(org)" class="org-card"
|
||||
:class="{ 'joined-org': !org.is_owner }" role="link" tabindex="0" @keydown.enter.self.prevent="handleCardClick(org)" @keydown.space.self.prevent="handleCardClick(org)" @click="handleCardClick(org)">
|
||||
|
||||
|
||||
<!-- 卡片头部 -->
|
||||
<div class="card-header">
|
||||
<div class="card-header-left">
|
||||
|
|
@ -650,7 +649,7 @@ const handleOrganizationDialogEvent = ((event: CustomEvent<{ type: 'create' | 'j
|
|||
}
|
||||
}) as EventListener
|
||||
|
||||
// 左侧筛选:'all' | 'created' | 'joined'
|
||||
// 分类筛选:'all' | 'created' | 'joined'
|
||||
const spaceSelection = ref<'all' | 'created' | 'joined'>('all')
|
||||
const keyword = ref('')
|
||||
|
||||
|
|
@ -712,14 +711,6 @@ const emptyStateDesc = computed(() => {
|
|||
})
|
||||
|
||||
// Methods
|
||||
function getRoleTheme(role: string) {
|
||||
switch (role) {
|
||||
case 'admin': return 'primary'
|
||||
case 'editor': return 'warning'
|
||||
default: return 'default'
|
||||
}
|
||||
}
|
||||
|
||||
const onVisibleChange = (visible: boolean, org: OrgWithUI) => {
|
||||
if (!visible) {
|
||||
organizationMenuVisibility[org.id] = false
|
||||
|
|
@ -977,13 +968,6 @@ function previewSearchableOrg(org: SearchableOrganizationItem) {
|
|||
inviteCode.value = ''
|
||||
}
|
||||
|
||||
// 查看搜索到的空间(已是成员时,打开空间设置;不关闭加入弹窗,关闭设置后仍回到搜索)
|
||||
function viewSearchableOrg(org: SearchableOrganizationItem) {
|
||||
settingsOrgId.value = org.id
|
||||
settingsMode.value = 'edit'
|
||||
showSettingsModal.value = true
|
||||
}
|
||||
|
||||
// 从预览弹框中查看空间(已是成员时;不关闭加入弹窗,关闭设置后仍回到搜索)
|
||||
function viewOrganizationFromPreview() {
|
||||
if (!invitePreviewData.value) return
|
||||
|
|
@ -1067,7 +1051,6 @@ onUnmounted(() => {
|
|||
window.removeEventListener('openOrganizationDialog', handleOrganizationDialogEvent)
|
||||
teardownInviteBodyResizeObserver()
|
||||
})
|
||||
const visibleResultCount = computed(() => filteredOrganizations.value.length)
|
||||
// A new search reveals matching rows even if their group was previously collapsed.
|
||||
watch(keyword, () => { collapsedOrgSections.value = new Set() })
|
||||
</script>
|
||||
|
|
@ -1193,59 +1176,6 @@ watch(keyword, () => { collapsedOrgSections.value = new Set() })
|
|||
}
|
||||
}
|
||||
|
||||
// Tab 切换样式(下划线式,与整体协作感一致)
|
||||
.org-tabs {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 28px;
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
margin-bottom: 24px;
|
||||
|
||||
.tab-item {
|
||||
padding: 12px 0;
|
||||
cursor: pointer;
|
||||
color: var(--td-text-color-secondary);
|
||||
font-family: var(--app-font-family);
|
||||
font-size: var(--app-text-base);
|
||||
font-weight: 400;
|
||||
user-select: none;
|
||||
position: relative;
|
||||
transition: color var(--app-motion-base) ease;
|
||||
|
||||
&:hover {
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
&.active {
|
||||
color: var(--td-brand-color);
|
||||
font-weight: 500;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -1px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 2px;
|
||||
background: var(--td-brand-color);
|
||||
border-radius: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes contentFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(6px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.org-card-wrap {
|
||||
.resource-card-grid();
|
||||
}
|
||||
|
|
@ -1260,8 +1190,6 @@ watch(keyword, () => { collapsedOrgSections.value = new Set() })
|
|||
.resource-card();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 空间头像容器(SpaceAvatar 自带样式)
|
||||
.org-avatar {
|
||||
display: flex;
|
||||
|
|
@ -1412,40 +1340,18 @@ watch(keyword, () => { collapsedOrgSections.value = new Set() })
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// 删除/离开确认对话框样式
|
||||
:deep(.t-dialog__position.t-dialog--top) {
|
||||
padding-top: 40vh !important;
|
||||
}
|
||||
|
||||
|
||||
.resource-list-header();
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.org-card-wrap { animation: none; }
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
/* 下拉菜单样式已统一至 @/assets/dropdown-menu.less */
|
||||
|
||||
// 创建对话框样式优化
|
||||
.create-org-dialog,
|
||||
.join-org-dialog {
|
||||
.t-form-item__label {
|
||||
font-family: var(--app-font-family);
|
||||
font-size: var(--app-text-base);
|
||||
font-weight: 500;
|
||||
color: var(--td-text-color-primary);
|
||||
}
|
||||
|
||||
.t-input,
|
||||
.t-textarea {
|
||||
font-family: var(--app-font-family);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 邀请预览弹框 - 参考 FAQ 导入弹窗风格,更紧凑
|
||||
.invite-preview-overlay {
|
||||
position: fixed;
|
||||
|
|
@ -1666,10 +1572,6 @@ watch(keyword, () => { collapsedOrgSections.value = new Set() })
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.search-input-wrap {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
// 搜索空间列表容器(与主列表一致:无外框,卡片间距)
|
||||
.searchable-list-wrap {
|
||||
max-height: 320px;
|
||||
|
|
|
|||
|
|
@ -860,7 +860,6 @@ function clearAvatarEmoji() {
|
|||
|
||||
// Computed
|
||||
const isCreateMode = computed(() => props.mode === 'create')
|
||||
const isEditMode = computed(() => props.mode === 'edit' || props.mode === 'create')
|
||||
// 后端组织相关变更接口(保存设置、邀请、搜索用户、改/删成员、审核加入申请、
|
||||
// 升级申请、刷新邀请码、移除共享等)在路由层都要求当前空间角色 ≥ admin(见
|
||||
// internal/router/router.go 的 RegisterOrganizationRoutes)。跨空间超管可绕过。
|
||||
|
|
|
|||
Loading…
Reference in New Issue