feat: add organization management features

- Introduced a new API for organization management, including creation, updating, and deletion of organizations.
- Implemented organization sharing functionality for knowledge bases, allowing users to share knowledge bases with specific organizations and set permissions.
- Added UI components for organization selection and sharing dialogs.
- Enhanced existing components to support organization-related features, including shared knowledge base handling and organization role management.

This update enhances collaboration capabilities within the application by allowing users to manage and share knowledge bases across different organizations.
This commit is contained in:
wizardchen
2026-01-30 16:28:01 +08:00
committed by lyingbug
parent 548450c170
commit 4158773849
72 changed files with 14685 additions and 1419 deletions
+75 -22
View File
@@ -44,16 +44,23 @@
<TIcon name="app" size="14px" />
</div>
<span class="agent-option-name">{{ agent.name }}</span>
<svg
v-if="currentAgentId === agent.id"
width="14"
height="14"
viewBox="0 0 16 16"
fill="currentColor"
class="check-icon"
>
<path d="M13.5 4.5L6 12L2.5 8.5L3.5 7.5L6 10L12.5 3.5L13.5 4.5Z"/>
</svg>
<div class="agent-option-actions">
<t-tooltip :content="$t('agent.selector.goToSettings')" placement="top">
<div class="settings-btn" @click.stop="goToSettings(agent)">
<TIcon name="setting" size="14px" />
</div>
</t-tooltip>
<svg
v-if="currentAgentId === agent.id"
width="14"
height="14"
viewBox="0 0 16 16"
fill="currentColor"
class="check-icon"
>
<path d="M13.5 4.5L6 12L2.5 8.5L3.5 7.5L6 10L12.5 3.5L13.5 4.5Z"/>
</svg>
</div>
</div>
<template #content>
<div class="agent-tooltip-content">
@@ -103,16 +110,23 @@
>
<AgentAvatar :name="agent.name" size="small" />
<span class="agent-option-name">{{ agent.name }}</span>
<svg
v-if="currentAgentId === agent.id"
width="14"
height="14"
viewBox="0 0 16 16"
fill="currentColor"
class="check-icon"
>
<path d="M13.5 4.5L6 12L2.5 8.5L3.5 7.5L6 10L12.5 3.5L13.5 4.5Z"/>
</svg>
<div class="agent-option-actions">
<t-tooltip :content="$t('agent.selector.goToSettings')" placement="top">
<div class="settings-btn" @click.stop="goToSettings(agent)">
<TIcon name="setting" size="14px" />
</div>
</t-tooltip>
<svg
v-if="currentAgentId === agent.id"
width="14"
height="14"
viewBox="0 0 16 16"
fill="currentColor"
class="check-icon"
>
<path d="M13.5 4.5L6 12L2.5 8.5L3.5 7.5L6 10L12.5 3.5L13.5 4.5Z"/>
</svg>
</div>
</div>
<template #content>
<div class="agent-tooltip-content">
@@ -164,11 +178,13 @@
<script setup lang="ts">
import { ref, computed, watch, onMounted, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import { Icon as TIcon, Popup as TPopup } from 'tdesign-vue-next';
import { useRouter } from 'vue-router';
import { Icon as TIcon, Popup as TPopup, Tooltip as TTooltip } from 'tdesign-vue-next';
import { listAgents, type CustomAgent, BUILTIN_QUICK_ANSWER_ID, BUILTIN_SMART_REASONING_ID } from '@/api/agent';
import AgentAvatar from '@/components/AgentAvatar.vue';
const { t } = useI18n();
const router = useRouter();
const props = defineProps<{
visible: boolean;
@@ -242,6 +258,15 @@ const selectAgent = (agent: CustomAgent) => {
emit('select', agent);
};
// 跳转到智能体设置页面
const goToSettings = (agent: CustomAgent) => {
emit('close');
router.push({
path: '/platform/agents',
query: { edit: agent.id }
});
};
// 更新下拉框位置(与模型选择器一致)
const updateDropdownPosition = () => {
if (!props.anchorEl) return;
@@ -481,12 +506,40 @@ onMounted(() => {
background: var(--td-bg-color-secondarycontainer, #f5f5f5);
}
.agent-option-actions {
display: flex;
align-items: center;
gap: 4px;
flex-shrink: 0;
}
.settings-btn {
display: flex;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
border-radius: 4px;
color: var(--td-text-color-placeholder, #999);
cursor: pointer;
opacity: 0;
transition: all 0.15s ease;
&:hover {
background: var(--td-bg-color-secondarycontainer-hover, #e8e8e8);
color: var(--td-brand-color, #07c05f);
}
}
.agent-option:hover .settings-btn {
opacity: 1;
}
.check-icon {
width: 14px;
height: 14px;
color: #10b981;
flex-shrink: 0;
margin-left: 6px;
}
// Tooltip 内容样式
+110 -38
View File
@@ -7,6 +7,7 @@ import { useSettingsStore } from '@/stores/settings';
import { useUIStore } from '@/stores/ui';
import { listKnowledgeBases, searchKnowledge, batchQueryKnowledge } from '@/api/knowledge-base';
import { stopSession } from '@/api/chat';
import { useOrganizationStore } from '@/stores/organization';
import KnowledgeBaseSelector from './KnowledgeBaseSelector.vue';
import MentionSelector from './MentionSelector.vue';
import AgentSelector from './AgentSelector.vue';
@@ -21,6 +22,7 @@ const route = useRoute();
const router = useRouter();
const settingsStore = useSettingsStore();
const uiStore = useUIStore();
const orgStore = useOrganizationStore();
const { t } = useI18n();
let query = ref("");
@@ -143,7 +145,9 @@ const isModelLockedByAgent = computed(() => {
// Mention related state
const showMention = ref(false);
const mentionQuery = ref("");
const mentionItems = ref<Array<{ id: string; name: string; type: 'kb' | 'file'; kbType?: 'document' | 'faq'; count?: number; kbName?: string }>>([]);
const mentionItems = ref<Array<{ id: string; name: string; type: 'kb' | 'file'; kbType?: 'document' | 'faq'; count?: number; kbName?: string; orgName?: string; kbId?: string }>>([]);
/** 文件 ID -> 知识库 ID(用于批量查询时传 kb_id,支持共享知识库下的文档) */
const fileIdToKbId = ref<Record<string, string>>({});
const mentionActiveIndex = ref(0);
const mentionStyle = ref<Record<string, string>>({});
const textareaRef = ref<any>(null); // Ref to t-textarea component
@@ -180,8 +184,22 @@ const isWebSearchConfigured = ref(false);
const knowledgeBases = ref<Array<{ id: string; name: string; type?: 'document' | 'faq'; knowledge_count?: number; chunk_count?: number }>>([]);
const fileList = ref<Array<{ id: string; name: string }>>([]);
// 选中的知识库:包含自己的 + 别人共享的(用于展示已选列表)
const selectedKbs = computed(() => {
return knowledgeBases.value.filter(kb => selectedKbIds.value.includes(kb.id));
const own = knowledgeBases.value.filter(kb => selectedKbIds.value.includes(kb.id));
const sharedList = orgStore.sharedKnowledgeBases || [];
const sharedMapped = sharedList
.filter((s: any) => s.knowledge_base != null && selectedKbIds.value.includes(s.knowledge_base.id))
.map((s: any) => ({
id: s.knowledge_base.id,
name: s.knowledge_base.name,
type: s.knowledge_base.type || 'document',
knowledge_count: s.knowledge_base.knowledge_count,
chunk_count: s.knowledge_base.chunk_count
}));
const ownIds = new Set(own.map(kb => kb.id));
const sharedOnly = sharedMapped.filter((kb: any) => !ownIds.has(kb.id));
return [...own, ...sharedOnly];
});
const selectedFiles = computed(() => {
@@ -276,23 +294,30 @@ const inputPlaceholder = computed(() => {
}
});
// 加载知识库列表
// 加载知识库列表(自己的 + 共享的,用于 @ 提及等)
const loadKnowledgeBases = async () => {
try {
const response: any = await listKnowledgeBases();
if (response.data && Array.isArray(response.data)) {
const validKbs = response.data.filter((kb: any) =>
const validKbs = response.data.filter((kb: any) =>
kb.embedding_model_id && kb.embedding_model_id !== '' &&
kb.summary_model_id && kb.summary_model_id !== ''
);
knowledgeBases.value = validKbs;
// 清理无效的知识库ID(已删除或不存在于有效知识库列表中的)
// 拉取共享知识库(供 @ 提及与清理选中项时识别)
await orgStore.fetchSharedKnowledgeBases().catch(() => {});
// 清理无效的知识库ID:只移除既不在自己列表也不在共享列表中的 ID(保留共享 KB 的选中状态)
const validKbIds = new Set(validKbs.map((kb: any) => kb.id));
const sharedKbIds = new Set(
(orgStore.sharedKnowledgeBases || []).map((s: any) => s.knowledge_base?.id).filter(Boolean)
);
const currentSelectedIds = settingsStore.settings.selectedKnowledgeBases || [];
const validSelectedIds = currentSelectedIds.filter((id: string) => validKbIds.has(id));
// 如果有无效的ID,更新store
const validSelectedIds = currentSelectedIds.filter(
(id: string) => validKbIds.has(id) || sharedKbIds.has(id)
);
if (validSelectedIds.length !== currentSelectedIds.length) {
settingsStore.selectKnowledgeBases(validSelectedIds);
}
@@ -305,18 +330,42 @@ const loadKnowledgeBases = async () => {
const loadFiles = async () => {
const ids = selectedFileIds.value;
if (ids.length === 0) return;
// Filter out files we already have info for
const missingIds = ids.filter((id: string) => !fileList.value.find(f => f.id === id));
if (missingIds.length === 0) return;
try {
const query = new URLSearchParams();
missingIds.forEach((id: string) => query.append('ids', id));
const res: any = await batchQueryKnowledge(query.toString());
if (res.data) {
const newFiles = res.data.map((f: any) => ({ id: f.id, name: f.title || f.file_name }));
fileList.value = [...fileList.value, ...newFiles];
// 按 kb_id 分组:共享知识库下的文档需带 kb_id 才能正确查询
const byKbId = new Map<string, string[]>();
const noKbId: string[] = [];
missingIds.forEach((id: string) => {
const kbId = fileIdToKbId.value[id];
if (kbId) {
if (!byKbId.has(kbId)) byKbId.set(kbId, []);
byKbId.get(kbId)!.push(id);
} else {
noKbId.push(id);
}
});
const allNewFiles: Array<{ id: string; name: string }> = [];
const runBatch = async (batchIds: string[], kbId?: string) => {
const query = new URLSearchParams();
batchIds.forEach((id: string) => query.append('ids', id));
const res: any = await batchQueryKnowledge(query.toString(), kbId);
if (res.data && Array.isArray(res.data)) {
res.data.forEach((f: any) => allNewFiles.push({ id: f.id, name: f.title || f.file_name }));
}
};
for (const [kbId, batchIds] of byKbId) {
await runBatch(batchIds, kbId);
}
if (noKbId.length > 0) {
await runBatch(noKbId);
}
if (allNewFiles.length > 0) {
fileList.value = [...fileList.value, ...allNewFiles];
}
} catch (e) {
console.error("Failed to load files", e);
@@ -583,36 +632,54 @@ const loadMentionItems = async (q: string, resetIndex = true, append = false) =>
mentionOffset.value = 0;
}
// 根据智能体的 kb_selection_mode 过滤知识库
// 根据智能体的 kb_selection_mode 过滤知识库;合并「自己的」+「共享的」知识库
let kbItems: any[] = [];
if (!append) {
// 获取可选的知识库列表
let availableKbs = knowledgeBases.value;
// 自己的知识库(需有 embedding/summary 模型)
let availableKbs = [...knowledgeBases.value];
// 共享的知识库(有权限的),映射为与 knowledgeBases 同结构便于合并
const sharedList = orgStore.sharedKnowledgeBases || [];
const sharedKbsForMention = sharedList
.filter((s: any) => s.knowledge_base != null)
.map((s: any) => ({
id: s.knowledge_base.id,
name: s.knowledge_base.name,
type: s.knowledge_base.type || 'document',
knowledge_count: s.knowledge_base.knowledge_count,
chunk_count: s.knowledge_base.chunk_count,
org_name: s.org_name || ''
}));
// 去重:若某 KB 既在自己列表又在共享列表,只保留一份(自己的优先)
const ownIds = new Set(availableKbs.map((kb: any) => kb.id));
sharedKbsForMention.forEach((kb: any) => {
if (!ownIds.has(kb.id)) {
availableKbs.push(kb);
ownIds.add(kb.id);
}
});
// 如果智能体有配置,根据 kb_selection_mode 过滤
if (hasAgentConfig.value) {
const kbMode = agentKBSelectionMode.value;
if (kbMode === 'none') {
// 不使用知识库,不显示任何知识库
availableKbs = [];
} else if (kbMode === 'selected') {
// 仅显示智能体配置的知识库
const configuredKbIds = agentKnowledgeBases.value;
availableKbs = knowledgeBases.value.filter(kb => configuredKbIds.includes(kb.id));
availableKbs = availableKbs.filter((kb: any) => configuredKbIds.includes(kb.id));
}
// kbMode === 'all' 时显示全部知识库
}
// 按查询过滤
const kbs = availableKbs.filter(kb =>
!q || kb.name.toLowerCase().includes(q.toLowerCase())
const kbs = availableKbs.filter((kb: any) =>
!q || (kb.name && kb.name.toLowerCase().includes(q.toLowerCase()))
);
kbItems = kbs.map(kb => ({
id: kb.id,
name: kb.name,
type: 'kb' as const,
kbItems = kbs.map((kb: any) => ({
id: kb.id,
name: kb.name,
type: 'kb' as const,
kbType: kb.type || 'document',
count: kb.type === 'faq' ? (kb.chunk_count || 0) : (kb.knowledge_count || 0)
count: kb.type === 'faq' ? (kb.chunk_count || 0) : (kb.knowledge_count || 0),
orgName: kb.org_name || undefined
}));
}
@@ -637,11 +704,12 @@ const loadMentionItems = async (q: string, resetIndex = true, append = false) =>
files = files.filter((f: any) => configuredKbIds.includes(f.knowledge_base_id));
}
fileItems = files.map((f: any) => ({
id: f.id,
name: f.title || f.file_name,
fileItems = files.map((f: any) => ({
id: f.id,
name: f.title || f.file_name,
type: 'file' as const,
kbName: f.knowledge_base_name || ''
kbName: f.knowledge_base_name || '',
kbId: f.knowledge_base_id || undefined
}));
}
mentionHasMore.value = res.has_more || false;
@@ -868,9 +936,12 @@ const onMentionSelect = (item: any) => {
settingsStore.addKnowledgeBase(item.id);
} else if (item.type === 'file') {
settingsStore.addFile(item.id);
if (item.kbId) {
fileIdToKbId.value[item.id] = item.kbId;
}
// Add to local cache immediately
if (!fileList.value.find(f => f.id === item.id)) {
fileList.value.push(item);
fileList.value.push({ id: item.id, name: item.name });
}
}
@@ -911,6 +982,7 @@ const onMentionSelect = (item: any) => {
const removeFile = (id: string) => {
settingsStore.removeFile(id);
delete fileIdToKbId.value[id];
};
const toggleModelSelector = () => {
+30 -4
View File
@@ -14,8 +14,11 @@
<div class="icon" :class="item.kbType === 'faq' ? 'faq-icon' : 'kb-icon'">
<t-icon :name="item.kbType === 'faq' ? 'chat-bubble-help' : 'folder'" />
</div>
<span class="name">{{ item.name }}</span>
<span class="count">({{ item.count || 0 }})</span>
<div class="item-main">
<span class="name">{{ item.name }}</span>
<span class="count">({{ item.count || 0 }})</span>
</div>
<span v-if="item.orgName" class="org-name">{{ item.orgName }}</span>
</div>
</div>
@@ -54,7 +57,7 @@ import { computed, watch, ref, nextTick } from 'vue';
const props = defineProps<{
visible: boolean;
style: any;
items: Array<{ id: string; name: string; type: 'kb' | 'file'; kbType?: 'document' | 'faq'; count?: number; kbName?: string }>;
items: Array<{ id: string; name: string; type: 'kb' | 'file'; kbType?: 'document' | 'faq'; count?: number; kbName?: string; orgName?: string }>;
activeIndex: number;
hasMore?: boolean;
loading?: boolean;
@@ -205,19 +208,42 @@ const scrollToItem = (index: number) => {
color: inherit;
}
.name {
.item-main {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
gap: 4px;
}
.name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* 文件项中的 name 需要占据剩余空间,将 kb-name 推到右边 */
.mention-item > .name {
flex: 1;
min-width: 0;
}
.count {
flex-shrink: 0;
font-size: var(--td-font-size-mark-small, 12px);
color: var(--td-text-color-secondary, #999);
}
.org-name {
flex-shrink: 0;
max-width: 72px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: var(--td-font-size-mark-small, 12px);
color: var(--td-text-color-placeholder, #999);
}
.kb-name {
flex-shrink: 0;
max-width: 80px;
@@ -0,0 +1,394 @@
<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"
>
<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-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 v-if="org.description" class="org-option-desc">{{ org.description }}</div>
<div class="org-option-meta">
<span class="org-meta-item">
<t-icon name="usergroup" size="14px" />
{{ org.member_count || 0 }} {{ $t('organization.members') }}
</span>
<span v-if="org.share_count !== undefined" class="org-meta-item">
<t-icon name="share" size="14px" />
{{ org.share_count }} {{ $t('organization.share.sharedKBs') }}
</span>
</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 value="viewer">{{ $t('organization.share.permissionReadonly') }}</t-radio>
<t-radio value="editor">{{ $t('organization.share.permissionEditable') }}</t-radio>
</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">
<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>
<t-button
variant="text"
theme="danger"
size="small"
@click="handleUnshare(share)"
>
<t-icon name="close" />
</t-button>
</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 { useOrganizationStore } from '@/stores/organization'
import { shareKnowledgeBase, listKBShares, removeShare } from '@/api/organization'
import type { KnowledgeBaseShare } from '@/api/organization'
const { t } = useI18n()
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)
}
</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: 6px;
margin-top: 8px;
color: var(--td-text-color-secondary);
font-size: 13px;
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: 8px;
}
.share-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 16px;
background: var(--td-bg-color-container-hover);
border-radius: 6px;
}
.share-info {
display: flex;
align-items: center;
gap: 12px;
}
.share-org-name {
font-weight: 500;
}
// Custom option styles for organization select
:deep(.t-select-option) {
height: auto;
align-items: flex-start;
padding-top: 8px;
padding-bottom: 8px;
}
:deep(.t-select-option__content) {
white-space: normal;
width: 100%;
}
.org-option-content {
padding: 2px 0;
min-width: 280px;
width: 100%;
}
.org-option-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 4px;
.org-option-name {
font-family: "PingFang SC";
font-size: 14px;
font-weight: 500;
color: #000000e6;
}
}
.org-option-desc {
font-family: "PingFang SC";
font-size: 12px;
color: #00000066;
line-height: 18px;
margin-bottom: 6px;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.org-option-meta {
display: flex;
align-items: center;
gap: 16px;
font-family: "PingFang SC";
font-size: 12px;
color: #00000066;
.org-meta-item {
display: flex;
align-items: center;
gap: 4px;
}
}
</style>
<style lang="less">
// Global styles for select dropdown (outside scoped)
.t-select__dropdown .t-select-option {
height: auto;
align-items: flex-start;
padding-top: 8px;
padding-bottom: 8px;
}
.t-select__dropdown .t-select-option__content {
white-space: normal;
width: 100%;
}
</style>
+136
View File
@@ -0,0 +1,136 @@
<template>
<div
class="space-avatar"
:style="avatarStyle"
:class="{ 'space-avatar-small': size === 'small', 'space-avatar-large': size === 'large' }"
>
<!-- 无限符号:右下角周边点缀,不干扰中央文字 -->
<svg class="space-avatar-decoration" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 10 A4 4 0 0 1 11 10 A4 4 0 0 1 19 10 A4 4 0 0 1 11 10 A4 4 0 0 1 3 10" stroke="rgba(255,255,255,0.25)" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
</svg>
<span class="space-avatar-letter" :style="letterStyle">{{ letter }}</span>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue';
const props = withDefaults(defineProps<{
name: string;
size?: 'small' | 'medium' | 'large';
}>(), {
size: 'medium'
});
// 预定义渐变色(与项目绿色主色协调,偏空间/协作感)
const gradients = [
{ from: '#07c05f', to: '#059669' }, // 主绿
{ from: '#11998e', to: '#38ef7d' }, // 深绿渐变
{ from: '#43e97b', to: '#38f9d7' }, // 绿青
{ from: '#02aab0', to: '#00cdac' }, // 青绿
{ from: '#36d1dc', to: '#5b86e5' }, // 青蓝
{ from: '#4facfe', to: '#00f2fe' }, // 蓝青
{ from: '#667eea', to: '#764ba2' }, // 紫蓝
{ from: '#4776e6', to: '#8e54e9' }, // 蓝紫
{ from: '#56ab2f', to: '#a8e063' }, // 草绿
{ from: '#00b09b', to: '#96c93d' }, // 青绿
{ from: '#5ee7df', to: '#b490ca' }, // 青紫
{ from: '#614385', to: '#516395' }, // 深紫蓝
];
const hashCode = (str: string): number => {
let hash = 0;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash;
}
return Math.abs(hash);
};
const letter = computed(() => {
const name = props.name?.trim() || '';
if (!name) return '?';
const firstChar = name.charAt(0);
if (/[a-zA-Z]/.test(firstChar)) return firstChar.toUpperCase();
return firstChar;
});
const gradient = computed(() => {
const hash = hashCode(props.name || '');
return gradients[hash % gradients.length];
});
const avatarStyle = computed(() => {
const g = gradient.value;
return {
background: `linear-gradient(135deg, ${g.from} 0%, ${g.to} 100%)`
};
});
const letterStyle = computed(() => {
const g = gradient.value;
return {
textShadow: `0 1px 2px ${g.to}80, 0 0 8px ${g.from}30`
};
});
</script>
<style scoped lang="less">
.space-avatar {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border-radius: 8px;
flex-shrink: 0;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
overflow: hidden;
&.space-avatar-small {
width: 22px;
height: 22px;
border-radius: 5px;
box-shadow: none;
.space-avatar-letter {
font-size: 11px;
}
.space-avatar-decoration {
display: none;
}
}
&.space-avatar-large {
width: 48px;
height: 48px;
border-radius: 12px;
.space-avatar-letter {
font-size: 20px;
}
}
}
.space-avatar-decoration {
position: absolute;
right: 2px;
bottom: 2px;
width: 40%;
height: 40%;
opacity: 0.85;
pointer-events: none;
}
.space-avatar-letter {
position: relative;
z-index: 1;
color: #fff;
font-size: 14px;
font-weight: 600;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
</style>
File diff suppressed because it is too large Load Diff