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:
@@ -97,8 +97,10 @@ export function downKnowledgeDetails(id: string) {
|
||||
return getDown(`/api/v1/knowledge/${id}/download`);
|
||||
}
|
||||
|
||||
export function batchQueryKnowledge(idsQueryString: string) {
|
||||
return get(`/api/v1/knowledge/batch?${idsQueryString}`);
|
||||
/** @param idsQueryString - query string with ids (e.g. ids=xxx&ids=yyy) */
|
||||
export function batchQueryKnowledge(idsQueryString: string, kbId?: string) {
|
||||
const qs = kbId ? `${idsQueryString}&kb_id=${encodeURIComponent(kbId)}` : idsQueryString;
|
||||
return get(`/api/v1/knowledge/batch?${qs}`);
|
||||
}
|
||||
|
||||
export function getKnowledgeDetailsCon(id: string, page: number) {
|
||||
|
||||
@@ -0,0 +1,491 @@
|
||||
import { get, post, put, del } from '@/utils/request'
|
||||
|
||||
// Organization types
|
||||
export interface Organization {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
avatar?: string
|
||||
owner_id: string
|
||||
invite_code?: string
|
||||
invite_code_expires_at?: string | null
|
||||
invite_code_validity_days?: number
|
||||
require_approval?: boolean
|
||||
member_count?: number
|
||||
share_count?: number
|
||||
pending_join_request_count?: number
|
||||
is_owner?: boolean
|
||||
my_role?: string
|
||||
has_pending_upgrade?: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface OrganizationMember {
|
||||
id: string
|
||||
user_id: string
|
||||
username: string
|
||||
email: string
|
||||
avatar?: string
|
||||
role: 'admin' | 'editor' | 'viewer'
|
||||
tenant_id: number
|
||||
joined_at: string
|
||||
}
|
||||
|
||||
export interface KnowledgeBaseShare {
|
||||
id: string
|
||||
knowledge_base_id: string
|
||||
knowledge_base_name?: string
|
||||
knowledge_base_type?: string
|
||||
knowledge_count?: number
|
||||
chunk_count?: number
|
||||
organization_id: string
|
||||
organization_name?: string
|
||||
shared_by_user_id: string
|
||||
shared_by_username?: string
|
||||
source_tenant_id: number
|
||||
/** Share permission: what the space was granted (viewer/editor) */
|
||||
permission: 'admin' | 'editor' | 'viewer'
|
||||
/** Current user's role in this organization (admin/editor/viewer) */
|
||||
my_role_in_org?: 'admin' | 'editor' | 'viewer'
|
||||
/** Effective permission for current user = min(permission, my_role_in_org) */
|
||||
my_permission?: 'admin' | 'editor' | 'viewer'
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface SharedKnowledgeBase {
|
||||
knowledge_base: {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
type: string
|
||||
knowledge_count?: number
|
||||
chunk_count?: number
|
||||
}
|
||||
share_id: string
|
||||
organization_id: string
|
||||
org_name: string
|
||||
permission: 'admin' | 'editor' | 'viewer'
|
||||
source_tenant_id: number
|
||||
shared_at: string
|
||||
}
|
||||
|
||||
export interface OrganizationPreview {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
avatar?: string
|
||||
member_count: number
|
||||
share_count: number
|
||||
is_already_member: boolean
|
||||
require_approval: boolean
|
||||
created_at: string
|
||||
}
|
||||
|
||||
// Request types
|
||||
export interface CreateOrganizationRequest {
|
||||
name: string
|
||||
description?: string
|
||||
avatar?: string
|
||||
invite_code_validity_days?: number // 0=never, 1, 7, 30; default 7
|
||||
}
|
||||
|
||||
export interface UpdateOrganizationRequest {
|
||||
name?: string
|
||||
description?: string
|
||||
avatar?: string
|
||||
require_approval?: boolean
|
||||
invite_code_validity_days?: number // 0=never, 1, 7, 30
|
||||
}
|
||||
|
||||
export interface UpdateMemberRoleRequest {
|
||||
role: 'admin' | 'editor' | 'viewer'
|
||||
}
|
||||
|
||||
export interface JoinOrganizationRequest {
|
||||
invite_code: string
|
||||
}
|
||||
|
||||
export interface ShareKnowledgeBaseRequest {
|
||||
organization_id: string
|
||||
permission: 'admin' | 'editor' | 'viewer'
|
||||
}
|
||||
|
||||
export interface UpdateSharePermissionRequest {
|
||||
permission: 'admin' | 'editor' | 'viewer'
|
||||
}
|
||||
|
||||
// Response types
|
||||
export interface ApiResponse<T> {
|
||||
success: boolean
|
||||
data?: T
|
||||
message?: string
|
||||
}
|
||||
|
||||
export interface ListOrganizationsResponse {
|
||||
organizations: Organization[]
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface ListMembersResponse {
|
||||
members: OrganizationMember[]
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface JoinRequestResponse {
|
||||
id: string
|
||||
user_id: string
|
||||
username: string
|
||||
email: string
|
||||
message: string
|
||||
request_type: 'join' | 'upgrade' // 'join' for new member, 'upgrade' for role upgrade
|
||||
prev_role?: string // Previous role (only for upgrade requests)
|
||||
requested_role: string // Role applicant requested: admin, editor, viewer
|
||||
status: string
|
||||
created_at: string
|
||||
reviewed_at?: string
|
||||
}
|
||||
|
||||
export interface ListJoinRequestsResponse {
|
||||
requests: JoinRequestResponse[]
|
||||
total: number
|
||||
}
|
||||
|
||||
export interface SubmitJoinRequestRequest {
|
||||
invite_code: string
|
||||
message?: string
|
||||
role?: 'admin' | 'editor' | 'viewer' // Optional: role applicant requests; default viewer
|
||||
}
|
||||
|
||||
export interface ReviewJoinRequestRequest {
|
||||
approved: boolean
|
||||
message?: string
|
||||
role?: 'admin' | 'editor' | 'viewer' // Optional: role to assign when approving; overrides applicant's requested role
|
||||
}
|
||||
|
||||
export interface RequestRoleUpgradeRequest {
|
||||
requested_role: 'admin' | 'editor' | 'viewer' // The role user wants to upgrade to
|
||||
message?: string // Optional message explaining the reason
|
||||
}
|
||||
|
||||
export interface InviteMemberRequest {
|
||||
user_id: string // User ID to invite
|
||||
role: 'admin' | 'editor' | 'viewer' // Role to assign
|
||||
}
|
||||
|
||||
export interface UserSearchResult {
|
||||
id: string
|
||||
username: string
|
||||
email: string
|
||||
avatar?: string
|
||||
}
|
||||
|
||||
export interface ListSharesResponse {
|
||||
shares: KnowledgeBaseShare[]
|
||||
total: number
|
||||
}
|
||||
|
||||
// Organization API functions
|
||||
|
||||
/**
|
||||
* Create a new organization
|
||||
*/
|
||||
export async function createOrganization(req: CreateOrganizationRequest): Promise<ApiResponse<Organization>> {
|
||||
try {
|
||||
const response = await post('/api/v1/organizations', req)
|
||||
return response as unknown as ApiResponse<Organization>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to create organization' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get organization by ID
|
||||
*/
|
||||
export async function getOrganization(id: string): Promise<ApiResponse<Organization>> {
|
||||
try {
|
||||
const response = await get(`/api/v1/organizations/${id}`)
|
||||
return response as unknown as ApiResponse<Organization>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to get organization' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List my organizations
|
||||
*/
|
||||
export async function listMyOrganizations(): Promise<ApiResponse<ListOrganizationsResponse>> {
|
||||
try {
|
||||
const response = await get('/api/v1/organizations')
|
||||
return response as unknown as ApiResponse<ListOrganizationsResponse>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to list organizations' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update organization
|
||||
*/
|
||||
export async function updateOrganization(id: string, req: UpdateOrganizationRequest): Promise<ApiResponse<Organization>> {
|
||||
try {
|
||||
const response = await put(`/api/v1/organizations/${id}`, req)
|
||||
return response as unknown as ApiResponse<Organization>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to update organization' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete organization
|
||||
*/
|
||||
export async function deleteOrganization(id: string): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await del(`/api/v1/organizations/${id}`)
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to delete organization' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Join organization by invite code
|
||||
*/
|
||||
export async function joinOrganization(req: JoinOrganizationRequest): Promise<ApiResponse<Organization>> {
|
||||
try {
|
||||
const response = await post('/api/v1/organizations/join', req)
|
||||
return response as unknown as ApiResponse<Organization>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to join organization' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a join request (for organizations that require approval).
|
||||
* Optional role: applicant's requested role (admin/editor/viewer); default viewer.
|
||||
*/
|
||||
export async function submitJoinRequest(req: SubmitJoinRequestRequest): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await post('/api/v1/organizations/join-request', req)
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to submit join request' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview organization by invite code (without joining)
|
||||
*/
|
||||
export async function previewOrganization(inviteCode: string): Promise<ApiResponse<OrganizationPreview>> {
|
||||
try {
|
||||
const response = await get(`/api/v1/organizations/preview/${inviteCode}`)
|
||||
return response as unknown as ApiResponse<OrganizationPreview>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to preview organization' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave organization
|
||||
*/
|
||||
export async function leaveOrganization(id: string): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await post(`/api/v1/organizations/${id}/leave`, {})
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to leave organization' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request role upgrade in an organization
|
||||
*/
|
||||
export async function requestRoleUpgrade(
|
||||
orgId: string,
|
||||
request: RequestRoleUpgradeRequest
|
||||
): Promise<ApiResponse<JoinRequestResponse>> {
|
||||
try {
|
||||
const response = await post(`/api/v1/organizations/${orgId}/request-upgrade`, request)
|
||||
return response as unknown as ApiResponse<JoinRequestResponse>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to submit upgrade request' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate new invite code
|
||||
*/
|
||||
export async function generateInviteCode(id: string): Promise<ApiResponse<{ invite_code: string }>> {
|
||||
try {
|
||||
const response = await post(`/api/v1/organizations/${id}/invite-code`, {})
|
||||
return response as unknown as ApiResponse<{ invite_code: string }>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to generate invite code' }
|
||||
}
|
||||
}
|
||||
|
||||
// Member management
|
||||
|
||||
/**
|
||||
* List organization members
|
||||
*/
|
||||
export async function listMembers(orgId: string): Promise<ApiResponse<ListMembersResponse>> {
|
||||
try {
|
||||
const response = await get(`/api/v1/organizations/${orgId}/members`)
|
||||
return response as unknown as ApiResponse<ListMembersResponse>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to list members' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update member role
|
||||
*/
|
||||
export async function updateMemberRole(orgId: string, userId: string, req: UpdateMemberRoleRequest): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await put(`/api/v1/organizations/${orgId}/members/${userId}`, req)
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to update member role' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove member
|
||||
*/
|
||||
export async function removeMember(orgId: string, userId: string): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await del(`/api/v1/organizations/${orgId}/members/${userId}`)
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to remove member' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List join requests (pending) for an organization (admin only)
|
||||
*/
|
||||
export async function listJoinRequests(orgId: string): Promise<ApiResponse<ListJoinRequestsResponse>> {
|
||||
try {
|
||||
const response = await get(`/api/v1/organizations/${orgId}/join-requests`)
|
||||
return response as unknown as ApiResponse<ListJoinRequestsResponse>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to list join requests' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Review join request (approve or reject) - admin only
|
||||
*/
|
||||
export async function reviewJoinRequest(orgId: string, requestId: string, req: ReviewJoinRequestRequest): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await put(`/api/v1/organizations/${orgId}/join-requests/${requestId}/review`, req)
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to review join request' }
|
||||
}
|
||||
}
|
||||
|
||||
// Knowledge base sharing
|
||||
|
||||
/**
|
||||
* Share knowledge base to organization
|
||||
*/
|
||||
export async function shareKnowledgeBase(kbId: string, req: ShareKnowledgeBaseRequest): Promise<ApiResponse<KnowledgeBaseShare>> {
|
||||
try {
|
||||
const response = await post(`/api/v1/knowledge-bases/${kbId}/shares`, req)
|
||||
return response as unknown as ApiResponse<KnowledgeBaseShare>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to share knowledge base' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List shares for a knowledge base
|
||||
*/
|
||||
export async function listKBShares(kbId: string): Promise<ApiResponse<ListSharesResponse>> {
|
||||
try {
|
||||
const response = await get(`/api/v1/knowledge-bases/${kbId}/shares`)
|
||||
return response as unknown as ApiResponse<ListSharesResponse>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to list shares' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update share permission
|
||||
*/
|
||||
export async function updateSharePermission(kbId: string, shareId: string, req: UpdateSharePermissionRequest): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await put(`/api/v1/knowledge-bases/${kbId}/shares/${shareId}`, req)
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to update share permission' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove share
|
||||
*/
|
||||
export async function removeShare(kbId: string, shareId: string): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await del(`/api/v1/knowledge-bases/${kbId}/shares/${shareId}`)
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to remove share' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List shared knowledge bases (shared to me through organizations)
|
||||
*/
|
||||
export async function listSharedKnowledgeBases(): Promise<ApiResponse<SharedKnowledgeBase[]>> {
|
||||
try {
|
||||
const response = await get('/api/v1/shared-knowledge-bases')
|
||||
return response as unknown as ApiResponse<SharedKnowledgeBase[]>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to list shared knowledge bases' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List knowledge bases shared to a specific organization
|
||||
*/
|
||||
export async function listOrgShares(orgId: string): Promise<ApiResponse<ListSharesResponse>> {
|
||||
try {
|
||||
const response = await get(`/api/v1/organizations/${orgId}/shares`)
|
||||
return response as unknown as ApiResponse<ListSharesResponse>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to list organization shares' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search users for inviting to organization (excludes existing members)
|
||||
*/
|
||||
export async function searchUsersForInvite(
|
||||
orgId: string,
|
||||
query: string,
|
||||
limit: number = 10
|
||||
): Promise<ApiResponse<UserSearchResult[]>> {
|
||||
try {
|
||||
const response = await get(`/api/v1/organizations/${orgId}/search-users?q=${encodeURIComponent(query)}&limit=${limit}`)
|
||||
return response as unknown as ApiResponse<UserSearchResult[]>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to search users' }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invite a user to organization directly (admin only)
|
||||
*/
|
||||
export async function inviteMember(
|
||||
orgId: string,
|
||||
req: InviteMemberRequest
|
||||
): Promise<ApiResponse<void>> {
|
||||
try {
|
||||
const response = await post(`/api/v1/organizations/${orgId}/invite`, req)
|
||||
return response as unknown as ApiResponse<void>
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message || 'Failed to invite member' }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg width="20" height="20" 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="#07C05F" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 285 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="20" height="20" 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="#000000" stroke-opacity=".9" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 305 B |
@@ -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 内容样式
|
||||
|
||||
@@ -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 = () => {
|
||||
|
||||
@@ -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>
|
||||
@@ -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
@@ -2,6 +2,7 @@ export default {
|
||||
menu: {
|
||||
knowledgeBase: 'Knowledge Base',
|
||||
agents: 'Agents',
|
||||
organizations: 'Shared Spaces',
|
||||
chat: 'Chat',
|
||||
createChat: 'Create Chat',
|
||||
tenant: 'Account Info',
|
||||
@@ -18,6 +19,17 @@ export default {
|
||||
list: 'Knowledge Base List',
|
||||
fileContent: 'File Content',
|
||||
detail: 'Knowledge Base Details',
|
||||
accessInfo: {
|
||||
myRole: 'My role',
|
||||
roleOwner: 'Owner',
|
||||
permissionOwner: 'Edit, manage settings, delete knowledge base',
|
||||
permissionAdmin: 'Edit, manage sharing',
|
||||
permissionEditor: 'Edit documents and categories',
|
||||
permissionViewer: 'View and search only',
|
||||
fromOrg: 'From space',
|
||||
sharedAt: 'Shared at',
|
||||
lastUpdated: 'Last updated',
|
||||
},
|
||||
create: 'Create Knowledge Base',
|
||||
edit: 'Edit Knowledge Base',
|
||||
delete: 'Delete Knowledge Base',
|
||||
@@ -71,6 +83,7 @@ export default {
|
||||
uploadFile: 'Upload File',
|
||||
uploadFileDesc: 'Supports PDF, Word, TXT, etc.',
|
||||
importURL: 'Import from URL',
|
||||
addDocument: 'Add Document',
|
||||
importURLDesc: 'Import via URL link',
|
||||
importURLTitle: 'Import from URL',
|
||||
manualCreate: 'Manual Create',
|
||||
@@ -386,6 +399,7 @@ export default {
|
||||
customSection: 'My Agents',
|
||||
addNew: 'Add New Agent',
|
||||
current: 'Current',
|
||||
goToSettings: 'Settings',
|
||||
},
|
||||
// Built-in agent information
|
||||
builtinInfo: {
|
||||
@@ -808,12 +822,14 @@ export default {
|
||||
}
|
||||
},
|
||||
common: {
|
||||
me: 'Me',
|
||||
confirm: 'Confirm',
|
||||
cancel: 'Cancel',
|
||||
save: 'Save',
|
||||
delete: 'Delete',
|
||||
edit: 'Edit',
|
||||
copy: 'Copy',
|
||||
copied: 'Copied',
|
||||
default: 'Default',
|
||||
create: 'Create',
|
||||
search: 'Search',
|
||||
@@ -1038,16 +1054,35 @@ export default {
|
||||
create: 'Create Knowledge Base',
|
||||
createFAQ: 'Create FAQ Knowledge Base',
|
||||
subtitle: 'Manage and organize your knowledge bases, supporting document-based and FAQ-based knowledge bases',
|
||||
myKnowledgeBases: 'My Knowledge Bases',
|
||||
sharedKnowledgeBases: 'Shared Knowledge Bases',
|
||||
sharedToOrgs: 'Shared to {count} space(s)',
|
||||
sharedLabel: 'Shared',
|
||||
tabs: {
|
||||
all: 'All',
|
||||
myKnowledgeBases: 'My Knowledge Bases',
|
||||
sharedToMe: 'Shared with me',
|
||||
},
|
||||
uninitializedBanner: 'Some knowledge bases are not initialized. Configure model information in settings before adding documents.',
|
||||
empty: {
|
||||
title: 'No knowledge bases yet',
|
||||
description: 'Click "Create Knowledge Base" in the top-right corner to add your first one.'
|
||||
description: 'Click "Create Knowledge Base" in the top-right corner to add your first one.',
|
||||
sharedTitle: 'No shared knowledge bases',
|
||||
sharedDescription: 'You can join a shared space or request others to share knowledge bases with you'
|
||||
},
|
||||
delete: {
|
||||
confirmTitle: 'Delete Confirmation',
|
||||
confirmMessage: 'Are you sure you want to delete the knowledge base "{name}"? This action cannot be undone.',
|
||||
confirmButton: 'Delete'
|
||||
},
|
||||
menu: {
|
||||
viewDetails: 'View Details',
|
||||
},
|
||||
detail: {
|
||||
sourceOrg: 'Source Space',
|
||||
role: 'My Permission',
|
||||
sharedAt: 'Shared At',
|
||||
},
|
||||
messages: {
|
||||
deleted: 'Knowledge base deleted',
|
||||
deleteFailed: 'Failed to delete knowledge base'
|
||||
@@ -1057,6 +1092,27 @@ export default {
|
||||
multimodal: 'Multimodal Enabled',
|
||||
questionGeneration: 'Question Generation Enabled'
|
||||
},
|
||||
detail: {
|
||||
title: 'Shared Knowledge Base',
|
||||
overview: 'Overview',
|
||||
overviewDesc: 'View knowledge base information and source',
|
||||
permission: 'Permission',
|
||||
permissionDesc: 'View your permissions for this knowledge base',
|
||||
sourceOrg: 'Source Space',
|
||||
sharedAt: 'Shared At',
|
||||
myPermission: 'My Permission',
|
||||
canEdit: 'Can edit knowledge base content',
|
||||
canView: 'Can view knowledge base content',
|
||||
canSearch: 'Can search and use knowledge base',
|
||||
goToKb: 'Go to Knowledge Base',
|
||||
enabled: 'Enabled',
|
||||
disabled: 'Disabled',
|
||||
},
|
||||
features: {
|
||||
knowledgeGraph: 'Knowledge Graph',
|
||||
multimodal: 'Multimodal',
|
||||
questionGeneration: 'Question Generation',
|
||||
},
|
||||
processing: 'Processing import task',
|
||||
processingDocuments: 'Processing {count} documents',
|
||||
stats: {
|
||||
@@ -1084,7 +1140,8 @@ export default {
|
||||
chunking: 'Chunking Settings',
|
||||
advanced: 'Advanced Settings',
|
||||
faq: 'FAQ Settings',
|
||||
graph: 'Knowledge Graph'
|
||||
graph: 'Knowledge Graph',
|
||||
share: 'Sharing'
|
||||
},
|
||||
basic: {
|
||||
title: 'Basic Information',
|
||||
@@ -1102,6 +1159,13 @@ export default {
|
||||
create: 'Create Knowledge Base',
|
||||
save: 'Save Configuration'
|
||||
},
|
||||
share: {
|
||||
description: 'Share the knowledge base with spaces so members can access and use it',
|
||||
addShare: 'Share',
|
||||
unshareConfirm: 'Are you sure you want to unshare from "{name}"?',
|
||||
tip1: 'After sharing, space members will access this knowledge base based on the assigned permissions',
|
||||
tip2: 'Editable permission allows members to modify content; Read-only permission only allows retrieval and Q&A'
|
||||
},
|
||||
messages: {
|
||||
loadModelsFailed: 'Failed to load model list',
|
||||
loadDataFailed: 'Failed to load knowledge base data',
|
||||
@@ -1158,6 +1222,8 @@ export default {
|
||||
emptyDesc: 'Click "Create FAQ Entry" above to get started',
|
||||
searchPlaceholder: 'Search standard questions...',
|
||||
searchTest: 'Search Test',
|
||||
addFaq: 'Add FAQ',
|
||||
manageFaq: 'FAQ Actions',
|
||||
searchTestTitle: 'FAQ Search Test',
|
||||
queryLabel: 'Query',
|
||||
queryPlaceholder: 'Enter a question to search',
|
||||
@@ -2278,4 +2344,239 @@ export default {
|
||||
},
|
||||
},
|
||||
},
|
||||
organization: {
|
||||
title: 'Shared Spaces',
|
||||
subtitle: 'Create or join shared spaces to share knowledge bases with your team',
|
||||
createOrg: 'Create Space',
|
||||
joinOrg: 'Join Space',
|
||||
name: 'Space Name',
|
||||
namePlaceholder: 'Enter space name',
|
||||
nameRequired: 'Please enter space name',
|
||||
avatar: 'Space Avatar',
|
||||
description: 'Description',
|
||||
descriptionPlaceholder: 'Enter space description (optional)',
|
||||
noDescription: 'No description',
|
||||
members: 'members',
|
||||
memberCount: 'Member count',
|
||||
owner: 'Creator',
|
||||
inviteCode: 'Invite Code',
|
||||
inviteCodePlaceholder: 'Enter invite code',
|
||||
inviteCodeRequired: 'Please enter invite code',
|
||||
inviteCodeTip: 'Share this invite code with others to let them join your space',
|
||||
refreshInviteCode: 'Refresh Invite Code',
|
||||
inviteCodeRefreshed: 'Invite code refreshed',
|
||||
inviteCodeRefreshFailed: 'Failed to refresh invite code',
|
||||
join: {
|
||||
title: 'Join Space',
|
||||
joining: 'Joining space...',
|
||||
success: 'Successfully joined space!',
|
||||
failed: 'Failed to join space',
|
||||
noCode: 'Invite code not found',
|
||||
goToOrganizations: 'Go to Spaces',
|
||||
confirmTitle: 'Confirm Join Space',
|
||||
confirm: 'Confirm Join',
|
||||
preview: 'Preview & Join',
|
||||
memberCount: '{count} members',
|
||||
shareCount: '{count} shared knowledge bases',
|
||||
alreadyMember: 'You are already a member of this space',
|
||||
invalidCode: 'Invalid invite code',
|
||||
},
|
||||
invite: {
|
||||
loading: 'Loading...',
|
||||
previewTitle: 'Join Space',
|
||||
previewInfo: 'Space Overview',
|
||||
inputDesc: 'Enter the invite code (or paste from an invite link) to view the space and join',
|
||||
previewAction: 'View',
|
||||
primaryJoin: 'Join',
|
||||
invalidTitle: 'Invalid Invitation',
|
||||
invalidCode: 'Invite code is invalid or expired',
|
||||
previewFailed: 'Preview failed, please try again',
|
||||
members: 'Members',
|
||||
knowledgeBases: 'Knowledge Bases',
|
||||
alreadyMember: 'You are already a member of this space',
|
||||
confirmJoin: 'Confirm Join',
|
||||
submitRequest: 'Request to Join',
|
||||
requireApprovalTip: 'This space requires admin approval to join',
|
||||
approvalLabel: 'Join method',
|
||||
needApproval: 'Requires approval',
|
||||
noApproval: 'No approval required',
|
||||
defaultRoleAfterJoin: 'Default role after joining: {role}',
|
||||
requestRole: 'Requested role',
|
||||
selectRole: 'Select role',
|
||||
messagePlaceholder: 'Optional: message (e.g. intro or reason to join)',
|
||||
joinSuccess: 'Successfully joined space!',
|
||||
joinFailed: 'Failed to join, please try again',
|
||||
requestSubmitted: 'Request submitted, please wait for admin approval',
|
||||
requestFailed: 'Failed to submit request, please try again',
|
||||
viewOrganization: 'View Space',
|
||||
},
|
||||
leave: 'Leave Space',
|
||||
leaveConfirm: 'Are you sure you want to leave this space?',
|
||||
leaveConfirmTitle: 'Leave Space',
|
||||
leaveConfirmMessage: 'Are you sure you want to leave "{name}"? You will lose access to shared knowledge bases.',
|
||||
leaveSuccess: 'Left space successfully',
|
||||
leaveFailed: 'Failed to leave space',
|
||||
deleteConfirm: 'Are you sure you want to delete this space? This action cannot be undone.',
|
||||
deleteConfirmTitle: 'Delete Space',
|
||||
deleteConfirmMessage: 'Are you sure you want to delete "{name}"? All members will be removed. This action cannot be undone.',
|
||||
deleteSuccess: 'Space deleted',
|
||||
deleteFailed: 'Failed to delete space',
|
||||
createSuccess: 'Space created successfully',
|
||||
createFailed: 'Failed to create space',
|
||||
joinSuccess: 'Joined space successfully',
|
||||
joinFailed: 'Failed to join space',
|
||||
manageMembers: 'Manage Members',
|
||||
noMembers: 'No members',
|
||||
roleUpdated: 'Role updated',
|
||||
roleUpdateFailed: 'Failed to update role',
|
||||
memberRemoved: 'Member removed',
|
||||
memberRemoveFailed: 'Failed to remove member',
|
||||
empty: 'You have not joined any shared space yet',
|
||||
emptyDesc: 'Create a space or join an existing one with an invite code',
|
||||
all: 'All',
|
||||
createdByMe: 'Created by me',
|
||||
joinedByMe: 'Joined',
|
||||
joinedLabel: 'Joined',
|
||||
emptyCreated: 'You have not created any space yet',
|
||||
emptyCreatedDesc: 'Click "Create Space" to create one',
|
||||
emptyJoined: 'You have not joined any space yet',
|
||||
emptyJoinedDesc: 'Join an existing space with an invite code',
|
||||
role: {
|
||||
admin: 'Admin',
|
||||
editor: 'Editor',
|
||||
viewer: 'Viewer',
|
||||
},
|
||||
detail: {
|
||||
myRole: 'My Role',
|
||||
removeMemberTitle: 'Remove Member',
|
||||
removeMemberConfirm: 'Are you sure you want to remove "{name}"?',
|
||||
removeMember: 'Remove Member',
|
||||
shareKBTip: 'Go to knowledge base list, select a knowledge base and click share to share it to this space',
|
||||
},
|
||||
settings: {
|
||||
editTitle: 'Space Settings',
|
||||
detailTitle: 'Space Details',
|
||||
myRoleDesc: 'Your role in this space determines your permissions',
|
||||
membersDesc: 'View and manage space members, adjust member roles',
|
||||
sharedDesc: 'View all knowledge bases shared to this space',
|
||||
noSharedKB: 'No shared knowledge bases yet',
|
||||
noSharedKBTip: 'Knowledge base owners can share their knowledge bases to this space in KB settings',
|
||||
sharePermissionLabel: 'Space permission',
|
||||
myPermissionLabel: 'My actual permission',
|
||||
permissionCalcFormula: 'Space permission is what was set when the KB was shared to this space; my actual permission = min(space permission, my role in this space)',
|
||||
permissionCalcTip: 'My actual permission = min(space permission, my role in this space). As a viewer in the space, I have at most read-only on this KB; as editor or admin, my permission is capped by the space permission.',
|
||||
inviteMembers: 'Invite Members',
|
||||
inviteMembersDesc: 'Invite others to join the space via code or link',
|
||||
inviteLink: 'Invite Link',
|
||||
inviteLinkValidity: 'Invite link validity',
|
||||
inviteLinkValidityDesc: 'Validity period for newly generated invite links',
|
||||
validity1Day: '1 day',
|
||||
validity7Days: '7 days',
|
||||
validity30Days: '30 days',
|
||||
validityNever: 'Never expire',
|
||||
remainingValidity: 'Expires in {n} days',
|
||||
remainingValidityNever: 'Never expire',
|
||||
remainingValidityExpired: 'Expired',
|
||||
removeShareFromOrg: 'Remove from space',
|
||||
removeShareConfirm: 'Remove "{name}" from this space? Members will no longer have access to this knowledge base.',
|
||||
removeShareSuccess: 'Removed from space',
|
||||
removeShareFailed: 'Failed to remove, please try again',
|
||||
requireApproval: 'Require Approval',
|
||||
requireApprovalDesc: 'When enabled, new members need admin approval to join',
|
||||
joinRequests: 'Join Requests',
|
||||
joinRequestsDesc: 'Review pending requests to join the space',
|
||||
noPendingRequests: 'No pending requests',
|
||||
pendingJoinRequestsBadge: 'Pending join requests to review',
|
||||
pendingReview: 'Pending',
|
||||
assignRole: 'Assign role',
|
||||
approve: 'Approve',
|
||||
reject: 'Reject',
|
||||
approveSuccess: 'Request approved',
|
||||
rejectSuccess: 'Request rejected',
|
||||
reviewFailed: 'Operation failed, please try again',
|
||||
},
|
||||
editor: {
|
||||
navBasic: 'Basic Info',
|
||||
navPermissions: 'Permissions',
|
||||
navJoin: 'Join Space',
|
||||
basicTitle: 'Basic Information',
|
||||
basicDesc: 'Set the space name and description for easy identification',
|
||||
nameTip: 'Use your team or project name for easy identification',
|
||||
descriptionTip: 'Describe the purpose and goals of the space',
|
||||
permissionsTitle: 'Member Permissions',
|
||||
permissionsDesc: 'Understand the permission scope of different roles in the space',
|
||||
permissionFeature: 'Permission Feature',
|
||||
fullAccess: 'Full Access',
|
||||
editAccess: 'Edit Access',
|
||||
viewAccess: 'View Only',
|
||||
adminPerm1: 'Manage space settings, members, and knowledge base shares',
|
||||
adminPerm2: 'Share and manage knowledge bases',
|
||||
adminPerm3: 'Edit shared knowledge base content',
|
||||
adminPerm4: 'View and search knowledge bases',
|
||||
shareKBPerm: 'Share knowledge bases to space',
|
||||
editorPerm1: 'Edit shared knowledge base content',
|
||||
editorPerm2: 'View and search knowledge bases',
|
||||
editorPerm3: 'Manage space settings and members',
|
||||
viewerPerm1: 'View and search knowledge bases',
|
||||
viewerPerm2: 'Edit knowledge base content',
|
||||
viewerPerm3: 'Manage space settings',
|
||||
ownerNote: 'As the space creator, you will automatically become an admin with full permissions.',
|
||||
joinTitle: 'Join Space',
|
||||
joinDesc: 'Join an existing space with an invite code to access shared knowledge bases',
|
||||
joinIllustration: 'Enter the invite code provided by the space admin to join',
|
||||
inviteCodeTip: 'The invite code is generated by space admins, please ask them for it',
|
||||
howToGetCode: 'How to get an invite code?',
|
||||
step1: 'Contact the admin of the space you want to join',
|
||||
step2: 'Ask them to share the space invite code',
|
||||
step3: 'Paste the invite code in the input field above',
|
||||
},
|
||||
upgrade: {
|
||||
requestUpgrade: 'Request Permission Upgrade',
|
||||
pending: 'Request Submitted',
|
||||
dialogTitle: 'Request Permission Upgrade',
|
||||
currentRole: 'Current Role',
|
||||
selectRole: 'Request Role',
|
||||
reason: 'Reason (Optional)',
|
||||
reasonPlaceholder: 'Please briefly explain why you need higher permissions...',
|
||||
submitSuccess: 'Upgrade request submitted, waiting for admin approval',
|
||||
submitFailed: 'Failed to submit request',
|
||||
upgradeRequest: 'Permission Upgrade',
|
||||
},
|
||||
addMember: {
|
||||
button: 'Add Member',
|
||||
dialogTitle: 'Add Member',
|
||||
tip: 'Added users will immediately become space members and can access shared knowledge bases.',
|
||||
searchUser: 'Select User',
|
||||
searchPlaceholder: 'Search by username or email...',
|
||||
searchHint: 'Type at least 2 characters to search',
|
||||
selectRole: 'Assign Role',
|
||||
confirmBtn: 'Add',
|
||||
success: 'Member added successfully',
|
||||
failed: 'Failed to add member',
|
||||
roleHint: {
|
||||
viewer: 'Can view and search',
|
||||
editor: 'Can edit content',
|
||||
admin: 'Full management access',
|
||||
},
|
||||
},
|
||||
share: {
|
||||
title: 'Share Knowledge Base',
|
||||
selectOrg: 'Select Space',
|
||||
selectOrgPlaceholder: 'Select a space to share with',
|
||||
permission: 'Permission',
|
||||
permissionTip: 'Editable permission allows members to modify knowledge base content, Read-only permission only allows search and Q&A',
|
||||
shareSuccess: 'Knowledge base shared',
|
||||
shareFailed: 'Failed to share',
|
||||
unshareSuccess: 'Share cancelled',
|
||||
unshareFailed: 'Failed to cancel share',
|
||||
sharedTo: 'Shared to',
|
||||
noShares: 'This knowledge base has not been shared to any space',
|
||||
sharedKnowledgeBase: 'Shared Knowledge Base',
|
||||
sharedFrom: 'From',
|
||||
sharedBadge: 'Shared',
|
||||
permissionReadonly: 'Read-only',
|
||||
permissionEditable: 'Editable',
|
||||
sharedKBs: ' knowledge bases',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -2,6 +2,7 @@ export default {
|
||||
menu: {
|
||||
knowledgeBase: "知识库",
|
||||
agents: "智能体",
|
||||
organizations: "共享空间",
|
||||
chat: "对话",
|
||||
createChat: "创建对话",
|
||||
tenant: "账户信息",
|
||||
@@ -18,6 +19,17 @@ export default {
|
||||
list: "知识库列表",
|
||||
fileContent: "文件内容",
|
||||
detail: "知识库详情",
|
||||
accessInfo: {
|
||||
myRole: "我的身份",
|
||||
roleOwner: "创建者",
|
||||
permissionOwner: "可编辑、管理设置、删除知识库",
|
||||
permissionAdmin: "可编辑、管理共享设置",
|
||||
permissionEditor: "可编辑文档与分类",
|
||||
permissionViewer: "仅查看与检索",
|
||||
fromOrg: "来自空间",
|
||||
sharedAt: "共享于",
|
||||
lastUpdated: "最后更新",
|
||||
},
|
||||
create: "创建知识库",
|
||||
edit: "编辑知识库",
|
||||
delete: "删除知识库",
|
||||
@@ -70,6 +82,7 @@ export default {
|
||||
uploadFile: "上传文件",
|
||||
uploadFileDesc: "支持 PDF、Word、TXT 等",
|
||||
importURL: "导入网页",
|
||||
addDocument: "添加文档",
|
||||
importURLDesc: "通过URL链接导入",
|
||||
importURLTitle: "导入网页",
|
||||
manualCreate: "手动创建",
|
||||
@@ -686,12 +699,14 @@ export default {
|
||||
},
|
||||
},
|
||||
common: {
|
||||
me: "我",
|
||||
confirm: "确认",
|
||||
cancel: "取消",
|
||||
save: "保存",
|
||||
delete: "删除",
|
||||
edit: "编辑",
|
||||
copy: "复制",
|
||||
copied: "已复制",
|
||||
default: "默认",
|
||||
create: "创建",
|
||||
search: "搜索",
|
||||
@@ -916,6 +931,7 @@ export default {
|
||||
customSection: "我的智能体",
|
||||
addNew: "添加新智能体",
|
||||
current: "当前",
|
||||
goToSettings: "设置",
|
||||
},
|
||||
// 内置智能体信息
|
||||
builtinInfo: {
|
||||
@@ -1431,17 +1447,52 @@ export default {
|
||||
create: "新建知识库",
|
||||
createFAQ: "新建 FAQ 知识库",
|
||||
subtitle: "管理和组织您的知识库,支持文档型和问答型知识库",
|
||||
myKnowledgeBases: "我的知识库",
|
||||
sharedKnowledgeBases: "共享的知识库",
|
||||
sharedToOrgs: "已共享给 {count} 个空间",
|
||||
sharedLabel: "共享",
|
||||
tabs: {
|
||||
all: "全部",
|
||||
myKnowledgeBases: "我的知识库",
|
||||
sharedToMe: "共享给我",
|
||||
},
|
||||
uninitializedBanner:
|
||||
"部分知识库尚未初始化,需要先在设置中配置模型信息才能添加知识文档",
|
||||
empty: {
|
||||
title: "暂无知识库",
|
||||
description: '点击左侧快捷操作"新建知识库"按钮创建第一个知识库',
|
||||
sharedTitle: "暂无共享知识库",
|
||||
sharedDescription: "您可以加入共享空间或请求他人共享知识库给您",
|
||||
},
|
||||
delete: {
|
||||
confirmTitle: "删除确认",
|
||||
confirmMessage: '确认要删除知识库"{name}"?删除后不可恢复',
|
||||
confirmButton: "确认删除",
|
||||
},
|
||||
menu: {
|
||||
viewDetails: "查看详情",
|
||||
},
|
||||
detail: {
|
||||
title: "共享知识库",
|
||||
overview: "概览",
|
||||
overviewDesc: "查看知识库基本信息和来源",
|
||||
permission: "权限",
|
||||
permissionDesc: "查看您在此知识库的操作权限",
|
||||
sourceOrg: "来源空间",
|
||||
sharedAt: "共享时间",
|
||||
myPermission: "我的权限",
|
||||
canEdit: "可以编辑知识库内容",
|
||||
canView: "可以查看知识库内容",
|
||||
canSearch: "可以搜索和使用知识库",
|
||||
goToKb: "进入知识库",
|
||||
enabled: "已启用",
|
||||
disabled: "未启用",
|
||||
},
|
||||
features: {
|
||||
knowledgeGraph: "知识图谱",
|
||||
multimodal: "多模态",
|
||||
questionGeneration: "问题生成",
|
||||
},
|
||||
messages: {
|
||||
deleted: "已删除",
|
||||
deleteFailed: "删除失败",
|
||||
@@ -1482,6 +1533,7 @@ export default {
|
||||
advanced: "高级设置",
|
||||
faq: "FAQ 设置",
|
||||
graph: "知识图谱",
|
||||
share: "共享管理",
|
||||
},
|
||||
basic: {
|
||||
title: "基本信息",
|
||||
@@ -1499,6 +1551,13 @@ export default {
|
||||
create: "创建知识库",
|
||||
save: "保存配置",
|
||||
},
|
||||
share: {
|
||||
description: "将知识库共享给空间,让空间成员可以访问和使用",
|
||||
addShare: "共享",
|
||||
unshareConfirm: "确定要取消对「{name}」的共享吗?",
|
||||
tip1: "共享后,空间成员将根据设定的权限访问此知识库",
|
||||
tip2: "可编辑权限允许成员修改知识库内容,只读权限仅允许检索和问答",
|
||||
},
|
||||
messages: {
|
||||
loadModelsFailed: "加载模型列表失败",
|
||||
loadDataFailed: "加载知识库数据失败",
|
||||
@@ -1559,6 +1618,8 @@ export default {
|
||||
emptyDesc: '点击上方"新增 FAQ 条目"按钮开始创建',
|
||||
searchPlaceholder: "搜索问题和答案...",
|
||||
searchTest: "检索测试",
|
||||
addFaq: "添加FAQ",
|
||||
manageFaq: "FAQ操作",
|
||||
searchTestTitle: "FAQ 检索测试",
|
||||
queryLabel: "查询内容",
|
||||
queryPlaceholder: "请输入要检索的问题",
|
||||
@@ -2283,4 +2344,239 @@ export default {
|
||||
},
|
||||
},
|
||||
},
|
||||
organization: {
|
||||
title: "共享空间",
|
||||
subtitle: "创建或加入共享空间,与团队成员共享知识库",
|
||||
createOrg: "创建空间",
|
||||
joinOrg: "加入空间",
|
||||
name: "空间名称",
|
||||
namePlaceholder: "请输入空间名称",
|
||||
nameRequired: "请输入空间名称",
|
||||
avatar: "空间头像",
|
||||
description: "空间描述",
|
||||
descriptionPlaceholder: "请输入空间描述(选填)",
|
||||
noDescription: "暂无描述",
|
||||
members: "成员",
|
||||
memberCount: "成员数量",
|
||||
owner: "创建者",
|
||||
inviteCode: "邀请码",
|
||||
inviteCodePlaceholder: "请输入邀请码",
|
||||
inviteCodeRequired: "请输入邀请码",
|
||||
inviteCodeTip: "分享此邀请码给他人,他们可以通过邀请码加入空间",
|
||||
refreshInviteCode: "刷新邀请码",
|
||||
inviteCodeRefreshed: "邀请码已刷新",
|
||||
inviteCodeRefreshFailed: "刷新邀请码失败",
|
||||
join: {
|
||||
title: "加入空间",
|
||||
joining: "正在加入空间...",
|
||||
success: "成功加入空间!",
|
||||
failed: "加入空间失败",
|
||||
noCode: "未找到邀请码",
|
||||
goToOrganizations: "前往空间列表",
|
||||
confirmTitle: "确认加入空间",
|
||||
confirm: "确认加入",
|
||||
preview: "预览并加入",
|
||||
memberCount: "{count} 名成员",
|
||||
shareCount: "{count} 个共享知识库",
|
||||
alreadyMember: "您已经是该空间的成员",
|
||||
invalidCode: "无效的邀请码",
|
||||
},
|
||||
invite: {
|
||||
loading: "加载中...",
|
||||
previewTitle: "加入空间",
|
||||
previewInfo: "空间概览",
|
||||
inputDesc: "输入邀请码或粘贴邀请链接中的邀请码,查看空间信息后加入",
|
||||
previewAction: "查看",
|
||||
primaryJoin: "加入",
|
||||
invalidTitle: "无效邀请",
|
||||
invalidCode: "邀请码无效或已过期",
|
||||
previewFailed: "预览失败,请稍后重试",
|
||||
members: "成员",
|
||||
knowledgeBases: "知识库",
|
||||
alreadyMember: "您已经是该空间的成员",
|
||||
confirmJoin: "确认加入",
|
||||
submitRequest: "申请加入",
|
||||
requireApprovalTip: "该空间需要管理员审核后才能加入",
|
||||
approvalLabel: "加入方式",
|
||||
needApproval: "需要审核",
|
||||
noApproval: "无需审核",
|
||||
defaultRoleAfterJoin: "加入后默认权限:{role}",
|
||||
requestRole: "申请角色",
|
||||
selectRole: "选择角色",
|
||||
messagePlaceholder: "选填:申请说明(如自我介绍或加入原因)",
|
||||
joinSuccess: "成功加入空间!",
|
||||
joinFailed: "加入失败,请稍后重试",
|
||||
requestSubmitted: "申请已提交,请等待管理员审核",
|
||||
requestFailed: "申请提交失败,请稍后重试",
|
||||
viewOrganization: "查看空间",
|
||||
},
|
||||
leave: "退出空间",
|
||||
leaveConfirm: "确定要退出该空间吗?",
|
||||
leaveConfirmTitle: "退出空间",
|
||||
leaveConfirmMessage: "确定要退出空间「{name}」吗?退出后将无法访问该空间共享的知识库。",
|
||||
leaveSuccess: "已退出空间",
|
||||
leaveFailed: "退出空间失败",
|
||||
deleteConfirm: "确定要删除该空间吗?此操作不可撤销。",
|
||||
deleteConfirmTitle: "删除空间",
|
||||
deleteConfirmMessage: "确定要删除空间「{name}」吗?删除后所有成员将被移除,此操作不可撤销。",
|
||||
deleteSuccess: "空间已删除",
|
||||
deleteFailed: "删除空间失败",
|
||||
createSuccess: "空间创建成功",
|
||||
createFailed: "创建空间失败",
|
||||
joinSuccess: "成功加入空间",
|
||||
joinFailed: "加入空间失败",
|
||||
manageMembers: "成员管理",
|
||||
noMembers: "暂无成员",
|
||||
roleUpdated: "角色已更新",
|
||||
roleUpdateFailed: "更新角色失败",
|
||||
memberRemoved: "成员已移除",
|
||||
memberRemoveFailed: "移除成员失败",
|
||||
empty: "您还没有加入任何共享空间",
|
||||
emptyDesc: "创建一个空间或通过邀请码加入现有空间",
|
||||
all: "全部",
|
||||
createdByMe: "我创建的",
|
||||
joinedByMe: "我加入的",
|
||||
joinedLabel: "已加入",
|
||||
emptyCreated: "您还没有创建任何共享空间",
|
||||
emptyCreatedDesc: "点击「创建空间」创建一个新空间",
|
||||
emptyJoined: "您还没有加入任何共享空间",
|
||||
emptyJoinedDesc: "通过邀请码加入现有空间",
|
||||
role: {
|
||||
admin: "管理员",
|
||||
editor: "编辑",
|
||||
viewer: "只读",
|
||||
},
|
||||
detail: {
|
||||
myRole: "我的角色",
|
||||
removeMemberTitle: "移除成员",
|
||||
removeMemberConfirm: "确定要移除成员「{name}」吗?",
|
||||
removeMember: "移除成员",
|
||||
shareKBTip: "在知识库列表中选择知识库,点击共享按钮将其共享到此空间",
|
||||
},
|
||||
settings: {
|
||||
editTitle: "空间设置",
|
||||
detailTitle: "空间详情",
|
||||
myRoleDesc: "您在此空间中的角色决定了您的权限范围",
|
||||
membersDesc: "查看和管理空间成员,调整成员角色",
|
||||
sharedDesc: "查看共享到此空间的所有知识库",
|
||||
noSharedKB: "暂无共享的知识库",
|
||||
noSharedKBTip: "知识库拥有者可以在知识库设置中将其共享到此空间",
|
||||
sharePermissionLabel: "空间权限",
|
||||
myPermissionLabel: "我的实际权限",
|
||||
permissionCalcFormula: "空间权限为共享时给该空间设定的权限;我的实际权限 = min(空间权限, 我在本空间的角色)",
|
||||
permissionCalcTip: "我的实际权限 = min(空间权限, 我在本空间的角色)。我在空间内是只读时,对此知识库最多只读;是编辑或管理员时,不超过空间权限。",
|
||||
inviteMembers: "邀请成员",
|
||||
inviteMembersDesc: "通过邀请码或链接邀请他人加入空间",
|
||||
inviteLink: "邀请链接",
|
||||
inviteLinkValidity: "邀请链接有效期",
|
||||
inviteLinkValidityDesc: "新生成的邀请链接的有效期,仅影响之后刷新生成的链接",
|
||||
validity1Day: "1 天",
|
||||
validity7Days: "7 天",
|
||||
validity30Days: "30 天",
|
||||
validityNever: "永不过期",
|
||||
remainingValidity: "剩余 {n} 天",
|
||||
remainingValidityNever: "永不过期",
|
||||
remainingValidityExpired: "已过期",
|
||||
removeShareFromOrg: "从空间中移除",
|
||||
removeShareConfirm: "确定将「{name}」从本空间中移除?移除后空间成员将无法再访问该知识库。",
|
||||
removeShareSuccess: "已从空间中移除",
|
||||
removeShareFailed: "移除失败,请重试",
|
||||
requireApproval: "需要审核",
|
||||
requireApprovalDesc: "开启后,新成员加入需要管理员审核",
|
||||
joinRequests: "加入申请",
|
||||
joinRequestsDesc: "审核待加入空间的申请",
|
||||
noPendingRequests: "暂无待审核的申请",
|
||||
pendingJoinRequestsBadge: "有待审批的加入申请",
|
||||
pendingReview: "待审批",
|
||||
assignRole: "分配角色",
|
||||
approve: "通过",
|
||||
reject: "拒绝",
|
||||
approveSuccess: "已通过申请",
|
||||
rejectSuccess: "已拒绝申请",
|
||||
reviewFailed: "操作失败,请重试",
|
||||
},
|
||||
editor: {
|
||||
navBasic: "基本信息",
|
||||
navPermissions: "权限说明",
|
||||
navJoin: "加入空间",
|
||||
basicTitle: "基本信息",
|
||||
basicDesc: "设置空间的名称和描述,便于成员识别",
|
||||
nameTip: "建议使用团队或项目名称,便于成员识别",
|
||||
descriptionTip: "描述空间的用途和目标,帮助成员了解空间",
|
||||
permissionsTitle: "成员权限",
|
||||
permissionsDesc: "了解空间中不同角色的权限范围",
|
||||
permissionFeature: "权限功能",
|
||||
fullAccess: "完整权限",
|
||||
editAccess: "编辑权限",
|
||||
viewAccess: "只读权限",
|
||||
adminPerm1: "管理空间设置、成员及知识库共享",
|
||||
adminPerm2: "共享和管理知识库",
|
||||
adminPerm3: "编辑共享知识库内容",
|
||||
adminPerm4: "查看和检索知识库",
|
||||
shareKBPerm: "共享知识库到空间",
|
||||
editorPerm1: "编辑共享知识库内容",
|
||||
editorPerm2: "查看和检索知识库",
|
||||
editorPerm3: "管理空间设置和成员",
|
||||
viewerPerm1: "查看和检索知识库",
|
||||
viewerPerm2: "编辑知识库内容",
|
||||
viewerPerm3: "管理空间设置",
|
||||
ownerNote: "作为空间创建者,您将自动成为空间的管理员,拥有完整权限。",
|
||||
joinTitle: "加入空间",
|
||||
joinDesc: "通过邀请码加入现有空间,获得知识库访问权限",
|
||||
joinIllustration: "输入空间管理员提供的邀请码即可加入",
|
||||
inviteCodeTip: "邀请码由空间管理员生成,请向他们索取",
|
||||
howToGetCode: "如何获取邀请码?",
|
||||
step1: "联系您要加入的空间管理员",
|
||||
step2: "请求他们分享空间邀请码",
|
||||
step3: "将邀请码粘贴到上方输入框",
|
||||
},
|
||||
upgrade: {
|
||||
requestUpgrade: "申请权限升级",
|
||||
pending: "已提交申请",
|
||||
dialogTitle: "申请权限升级",
|
||||
currentRole: "当前角色",
|
||||
selectRole: "申请角色",
|
||||
reason: "申请理由(选填)",
|
||||
reasonPlaceholder: "请简要说明申请更高权限的原因...",
|
||||
submitSuccess: "权限升级申请已提交,等待管理员审核",
|
||||
submitFailed: "提交申请失败",
|
||||
upgradeRequest: "权限升级",
|
||||
},
|
||||
addMember: {
|
||||
button: "添加成员",
|
||||
dialogTitle: "添加成员",
|
||||
tip: "添加的用户将立即成为空间成员,可以访问空间内共享的知识库。",
|
||||
searchUser: "选择用户",
|
||||
searchPlaceholder: "输入用户名或邮箱搜索...",
|
||||
searchHint: "输入至少2个字符开始搜索",
|
||||
selectRole: "分配角色",
|
||||
confirmBtn: "添加",
|
||||
success: "成员添加成功",
|
||||
failed: "添加失败",
|
||||
roleHint: {
|
||||
viewer: "可查看和搜索",
|
||||
editor: "可编辑内容",
|
||||
admin: "完整管理权限",
|
||||
},
|
||||
},
|
||||
share: {
|
||||
title: "共享知识库",
|
||||
selectOrg: "选择空间",
|
||||
selectOrgPlaceholder: "请选择要共享的空间",
|
||||
permission: "权限",
|
||||
permissionTip: "可编辑权限允许成员修改知识库内容,只读权限仅允许检索和问答",
|
||||
shareSuccess: "知识库已共享",
|
||||
shareFailed: "共享失败",
|
||||
unshareSuccess: "已取消共享",
|
||||
unshareFailed: "取消共享失败",
|
||||
sharedTo: "已共享到",
|
||||
noShares: "该知识库尚未共享到任何空间",
|
||||
sharedKnowledgeBase: "共享知识库",
|
||||
sharedFrom: "来自",
|
||||
sharedBadge: "共享",
|
||||
permissionReadonly: "只读",
|
||||
permissionEditable: "可编辑",
|
||||
sharedKBs: "个知识库",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -16,6 +16,19 @@ const router = createRouter({
|
||||
component: () => import("../views/auth/Login.vue"),
|
||||
meta: { requiresAuth: false, requiresInit: false }
|
||||
},
|
||||
{
|
||||
path: "/join",
|
||||
name: "joinOrganization",
|
||||
// 重定向到组织列表页,并将 code 参数转换为 invite_code
|
||||
redirect: (to) => {
|
||||
const code = to.query.code as string
|
||||
return {
|
||||
path: '/platform/organizations',
|
||||
query: code ? { invite_code: code } : {}
|
||||
}
|
||||
},
|
||||
meta: { requiresInit: true, requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: "/knowledgeBase",
|
||||
name: "home",
|
||||
@@ -75,6 +88,12 @@ const router = createRouter({
|
||||
component: () => import("../views/chat/index.vue"),
|
||||
meta: { requiresInit: true, requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: "organizations",
|
||||
name: "organizationList",
|
||||
component: () => import("../views/organization/OrganizationList.vue"),
|
||||
meta: { requiresInit: true, requiresAuth: true }
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -19,6 +19,7 @@ export const useMenuStore = defineStore('menuStore', () => {
|
||||
const menuArr = reactive<MenuItem[]>([
|
||||
{ title: '', titleKey: 'menu.knowledgeBase', icon: 'zhishiku', path: 'knowledge-bases' },
|
||||
{ title: '', titleKey: 'menu.agents', icon: 'agent', path: 'agents' },
|
||||
{ title: '', titleKey: 'menu.organizations', icon: 'organization', path: 'organizations' },
|
||||
{
|
||||
title: '',
|
||||
titleKey: 'menu.chat',
|
||||
@@ -54,14 +55,14 @@ export const useMenuStore = defineStore('menuStore', () => {
|
||||
)
|
||||
|
||||
const clearMenuArr = () => {
|
||||
const chatMenu = menuArr[2]
|
||||
const chatMenu = menuArr[3]
|
||||
if (chatMenu && chatMenu.children) {
|
||||
chatMenu.children = createMenuChildren()
|
||||
}
|
||||
}
|
||||
|
||||
const updatemenuArr = (obj: any) => {
|
||||
const chatMenu = menuArr[2]
|
||||
const chatMenu = menuArr[3]
|
||||
if (!chatMenu.children) {
|
||||
chatMenu.children = createMenuChildren()
|
||||
}
|
||||
@@ -72,7 +73,7 @@ export const useMenuStore = defineStore('menuStore', () => {
|
||||
}
|
||||
|
||||
const updataMenuChildren = (item: MenuChild) => {
|
||||
const chatMenu = menuArr[2]
|
||||
const chatMenu = menuArr[3]
|
||||
if (!chatMenu.children) {
|
||||
chatMenu.children = createMenuChildren()
|
||||
}
|
||||
@@ -80,7 +81,7 @@ export const useMenuStore = defineStore('menuStore', () => {
|
||||
}
|
||||
|
||||
const updatasessionTitle = (sessionId: string, title: string) => {
|
||||
const chatMenu = menuArr[2]
|
||||
const chatMenu = menuArr[3]
|
||||
chatMenu.children?.forEach((item: MenuChild) => {
|
||||
if (item.id === sessionId) {
|
||||
item.title = title
|
||||
|
||||
@@ -0,0 +1,435 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import type {
|
||||
Organization,
|
||||
OrganizationMember,
|
||||
SharedKnowledgeBase,
|
||||
OrganizationPreview
|
||||
} from '@/api/organization'
|
||||
import {
|
||||
listMyOrganizations,
|
||||
createOrganization,
|
||||
updateOrganization,
|
||||
deleteOrganization,
|
||||
joinOrganization,
|
||||
previewOrganization,
|
||||
leaveOrganization,
|
||||
generateInviteCode,
|
||||
listMembers,
|
||||
updateMemberRole,
|
||||
removeMember,
|
||||
listSharedKnowledgeBases
|
||||
} from '@/api/organization'
|
||||
|
||||
export const useOrganizationStore = defineStore('organization', () => {
|
||||
// State
|
||||
const organizations = ref<Organization[]>([])
|
||||
const currentOrganization = ref<Organization | null>(null)
|
||||
const currentMembers = ref<OrganizationMember[]>([])
|
||||
const sharedKnowledgeBases = ref<SharedKnowledgeBase[]>([])
|
||||
const previewData = ref<OrganizationPreview | null>(null)
|
||||
const loading = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
// Computed
|
||||
const myOrganizations = computed(() => organizations.value)
|
||||
|
||||
const ownedOrganizations = computed(() =>
|
||||
organizations.value.filter(org => org.is_owner)
|
||||
)
|
||||
|
||||
const joinedOrganizations = computed(() =>
|
||||
organizations.value.filter(org => !org.is_owner)
|
||||
)
|
||||
|
||||
/** 当前用户作为管理员/创建者可见的待审批加入申请总数(用于侧栏提醒) */
|
||||
const totalPendingJoinRequestCount = computed(() =>
|
||||
organizations.value.reduce((sum, org) => sum + (org.pending_join_request_count ?? 0), 0)
|
||||
)
|
||||
|
||||
// Actions
|
||||
|
||||
/**
|
||||
* Fetch all organizations the user belongs to
|
||||
*/
|
||||
async function fetchOrganizations() {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await listMyOrganizations()
|
||||
if (response.success && response.data) {
|
||||
organizations.value = response.data.organizations
|
||||
} else {
|
||||
error.value = response.message || 'Failed to fetch organizations'
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to fetch organizations'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new organization
|
||||
*/
|
||||
async function create(name: string, description?: string) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await createOrganization({ name, description })
|
||||
if (response.success && response.data) {
|
||||
organizations.value.unshift(response.data)
|
||||
return response.data
|
||||
} else {
|
||||
error.value = response.message || 'Failed to create organization'
|
||||
return null
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to create organization'
|
||||
return null
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an organization
|
||||
*/
|
||||
async function update(id: string, name?: string, description?: string) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await updateOrganization(id, { name, description })
|
||||
if (response.success && response.data) {
|
||||
const index = organizations.value.findIndex(o => o.id === id)
|
||||
if (index !== -1) {
|
||||
organizations.value[index] = response.data
|
||||
}
|
||||
if (currentOrganization.value?.id === id) {
|
||||
currentOrganization.value = response.data
|
||||
}
|
||||
return response.data
|
||||
} else {
|
||||
error.value = response.message || 'Failed to update organization'
|
||||
return null
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to update organization'
|
||||
return null
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an organization
|
||||
*/
|
||||
async function remove(id: string) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await deleteOrganization(id)
|
||||
if (response.success) {
|
||||
organizations.value = organizations.value.filter(o => o.id !== id)
|
||||
if (currentOrganization.value?.id === id) {
|
||||
currentOrganization.value = null
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
error.value = response.message || 'Failed to delete organization'
|
||||
return false
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to delete organization'
|
||||
return false
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview an organization by invite code (without joining)
|
||||
*/
|
||||
async function preview(inviteCode: string) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
previewData.value = null
|
||||
try {
|
||||
const response = await previewOrganization(inviteCode)
|
||||
if (response.success && response.data) {
|
||||
previewData.value = response.data
|
||||
return response.data
|
||||
} else {
|
||||
error.value = response.message || 'Failed to preview organization'
|
||||
return null
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to preview organization'
|
||||
return null
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Join an organization by invite code
|
||||
*/
|
||||
async function join(inviteCode: string) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await joinOrganization({ invite_code: inviteCode })
|
||||
if (response.success && response.data) {
|
||||
// Check if already in list
|
||||
const exists = organizations.value.some(o => o.id === response.data!.id)
|
||||
if (!exists) {
|
||||
organizations.value.unshift(response.data)
|
||||
}
|
||||
return response.data
|
||||
} else {
|
||||
error.value = response.message || 'Failed to join organization'
|
||||
return null
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to join organization'
|
||||
return null
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave an organization
|
||||
*/
|
||||
async function leave(id: string) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await leaveOrganization(id)
|
||||
if (response.success) {
|
||||
organizations.value = organizations.value.filter(o => o.id !== id)
|
||||
if (currentOrganization.value?.id === id) {
|
||||
currentOrganization.value = null
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
error.value = response.message || 'Failed to leave organization'
|
||||
return false
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to leave organization'
|
||||
return false
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a new invite code
|
||||
*/
|
||||
async function refreshInviteCode(id: string) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await generateInviteCode(id)
|
||||
if (response.success && response.data) {
|
||||
const org = organizations.value.find(o => o.id === id)
|
||||
if (org) {
|
||||
org.invite_code = response.data.invite_code
|
||||
}
|
||||
if (currentOrganization.value?.id === id) {
|
||||
currentOrganization.value.invite_code = response.data.invite_code
|
||||
}
|
||||
return response.data.invite_code
|
||||
} else {
|
||||
error.value = response.message || 'Failed to generate invite code'
|
||||
return null
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to generate invite code'
|
||||
return null
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch members of an organization
|
||||
*/
|
||||
async function fetchMembers(orgId: string) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await listMembers(orgId)
|
||||
if (response.success && response.data) {
|
||||
currentMembers.value = response.data.members
|
||||
return response.data.members
|
||||
} else {
|
||||
error.value = response.message || 'Failed to fetch members'
|
||||
return []
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to fetch members'
|
||||
return []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a member's role
|
||||
*/
|
||||
async function changeMemberRole(orgId: string, userId: string, role: 'admin' | 'editor' | 'viewer') {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await updateMemberRole(orgId, userId, { role })
|
||||
if (response.success) {
|
||||
const member = currentMembers.value.find(m => m.user_id === userId)
|
||||
if (member) {
|
||||
member.role = role
|
||||
}
|
||||
return true
|
||||
} else {
|
||||
error.value = response.message || 'Failed to update member role'
|
||||
return false
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to update member role'
|
||||
return false
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a member from organization
|
||||
*/
|
||||
async function kickMember(orgId: string, userId: string) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await removeMember(orgId, userId)
|
||||
if (response.success) {
|
||||
currentMembers.value = currentMembers.value.filter(m => m.user_id !== userId)
|
||||
return true
|
||||
} else {
|
||||
error.value = response.message || 'Failed to remove member'
|
||||
return false
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to remove member'
|
||||
return false
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch shared knowledge bases
|
||||
*/
|
||||
async function fetchSharedKnowledgeBases() {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
const response = await listSharedKnowledgeBases()
|
||||
if (response.success && response.data) {
|
||||
// Filter out shares whose knowledge_base was deleted (null)
|
||||
sharedKnowledgeBases.value = response.data.filter(s => s.knowledge_base != null)
|
||||
return sharedKnowledgeBases.value
|
||||
} else {
|
||||
error.value = response.message || 'Failed to fetch shared knowledge bases'
|
||||
return []
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to fetch shared knowledge bases'
|
||||
return []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set current organization for detail view
|
||||
*/
|
||||
function setCurrentOrganization(org: Organization | null) {
|
||||
currentOrganization.value = org
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user's permission for a specific knowledge base
|
||||
* Returns 'owner' if user owns the KB, or the share permission ('admin' | 'editor' | 'viewer'), or null if no access
|
||||
*/
|
||||
function getKBPermission(kbId: string): 'owner' | 'admin' | 'editor' | 'viewer' | null {
|
||||
const shared = sharedKnowledgeBases.value.find(
|
||||
s => s.knowledge_base?.id === kbId
|
||||
)
|
||||
return shared?.permission || null
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user can edit a knowledge base (owner, admin, or editor)
|
||||
*/
|
||||
function canEditKB(kbId: string, isOwner: boolean): boolean {
|
||||
if (isOwner) return true
|
||||
const permission = getKBPermission(kbId)
|
||||
return permission === 'admin' || permission === 'editor'
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user can delete/manage a knowledge base (owner or admin only)
|
||||
*/
|
||||
function canManageKB(kbId: string, isOwner: boolean): boolean {
|
||||
if (isOwner) return true
|
||||
const permission = getKBPermission(kbId)
|
||||
return permission === 'admin'
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all state
|
||||
*/
|
||||
function clearState() {
|
||||
organizations.value = []
|
||||
currentOrganization.value = null
|
||||
currentMembers.value = []
|
||||
sharedKnowledgeBases.value = []
|
||||
previewData.value = null
|
||||
error.value = null
|
||||
}
|
||||
|
||||
return {
|
||||
// State
|
||||
organizations,
|
||||
currentOrganization,
|
||||
currentMembers,
|
||||
sharedKnowledgeBases,
|
||||
previewData,
|
||||
loading,
|
||||
error,
|
||||
|
||||
// Computed
|
||||
myOrganizations,
|
||||
ownedOrganizations,
|
||||
joinedOrganizations,
|
||||
totalPendingJoinRequestCount,
|
||||
|
||||
// Actions
|
||||
fetchOrganizations,
|
||||
create,
|
||||
update,
|
||||
remove,
|
||||
preview,
|
||||
join,
|
||||
leave,
|
||||
refreshInviteCode,
|
||||
fetchMembers,
|
||||
changeMemberRole,
|
||||
kickMember,
|
||||
fetchSharedKnowledgeBases,
|
||||
setCurrentOrganization,
|
||||
getKBPermission,
|
||||
canEditKB,
|
||||
canManageKB,
|
||||
clearState
|
||||
}
|
||||
})
|
||||
@@ -6,6 +6,20 @@
|
||||
<h2>{{ $t('agent.title') }}</h2>
|
||||
<p class="header-subtitle">{{ $t('agent.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<t-button class="agent-create-btn" @click="handleCreateAgent">
|
||||
<template #icon>
|
||||
<span class="btn-icon-wrapper">
|
||||
<svg class="sparkles-icon" width="18" height="18" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" fill="currentColor" stroke="currentColor" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="currentColor" stroke="currentColor" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</span>
|
||||
</template>
|
||||
<span>{{ $t('agent.createAgent') }}</span>
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-divider"></div>
|
||||
|
||||
@@ -323,6 +337,11 @@ const openCreateModal = () => {
|
||||
editorVisible.value = true
|
||||
}
|
||||
|
||||
// 创建智能体
|
||||
const handleCreateAgent = () => {
|
||||
openCreateModal()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openCreateModal
|
||||
})
|
||||
@@ -358,6 +377,76 @@ defineExpose({
|
||||
font-weight: 600;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
|
||||
:deep(.agent-create-btn) {
|
||||
--ripple-color: rgba(118, 75, 162, 0.3) !important;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
||||
border: none !important;
|
||||
color: #fff !important;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
&:hover,
|
||||
&:active,
|
||||
&:focus,
|
||||
&.t-is-active,
|
||||
&[data-state="active"] {
|
||||
background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%) !important;
|
||||
border: none !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
// 覆盖 TDesign 按钮的 CSS 变量
|
||||
--td-button-primary-bg-color: #667eea !important;
|
||||
--td-button-primary-border-color: #667eea !important;
|
||||
--td-button-primary-active-bg-color: #5a6fd6 !important;
|
||||
--td-button-primary-active-border-color: #5a6fd6 !important;
|
||||
}
|
||||
|
||||
.agent-create-btn {
|
||||
.btn-icon-wrapper {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sparkles-icon {
|
||||
animation: twinkle 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -50%;
|
||||
left: -50%;
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
background: linear-gradient(
|
||||
45deg,
|
||||
transparent 30%,
|
||||
rgba(255, 255, 255, 0.1) 50%,
|
||||
transparent 70%
|
||||
);
|
||||
transform: translateX(-100%);
|
||||
transition: transform 0.6s ease;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
&:hover::before {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes twinkle {
|
||||
0%, 100% { opacity: 1; transform: scale(1); }
|
||||
50% { opacity: 0.8; transform: scale(0.95); }
|
||||
}
|
||||
}
|
||||
|
||||
.header-subtitle {
|
||||
|
||||
@@ -320,9 +320,22 @@ const sendMsg = async (value, modelId = '', mentionedItems = []) => {
|
||||
const webSearchEnabled = useSettingsStoreInstance.isWebSearchEnabled;
|
||||
|
||||
// Get knowledge_base_ids from settings store (selected by user via KnowledgeBaseSelector)
|
||||
const kbIds = useSettingsStoreInstance.settings.selectedKnowledgeBases || [];
|
||||
const knowledgeIds = useSettingsStoreInstance.settings.selectedFiles || [];
|
||||
|
||||
// Merge @mentioned KB/file IDs so retrieval uses the same targets user @mentioned (including shared KBs)
|
||||
const sidebarKbIds = useSettingsStoreInstance.settings.selectedKnowledgeBases || [];
|
||||
const sidebarFileIds = useSettingsStoreInstance.settings.selectedFiles || [];
|
||||
const kbIdSet = new Set(sidebarKbIds);
|
||||
const fileIdSet = new Set(sidebarFileIds);
|
||||
for (const item of mentionedItems || []) {
|
||||
if (!item?.id) continue;
|
||||
if (item.type === 'kb' && !kbIdSet.has(item.id)) {
|
||||
kbIdSet.add(item.id);
|
||||
} else if (item.type === 'file' && !fileIdSet.has(item.id)) {
|
||||
fileIdSet.add(item.id);
|
||||
}
|
||||
}
|
||||
const kbIds = [...kbIdSet];
|
||||
const knowledgeIds = [...fileIdSet];
|
||||
|
||||
// Get selected agent ID
|
||||
const selectedAgentId = useSettingsStoreInstance.selectedAgentId || '';
|
||||
|
||||
|
||||
@@ -8,9 +8,13 @@ import EmptyKnowledge from '@/components/empty-knowledge.vue';
|
||||
import { getSessionsList, createSessions, generateSessionsTitle } from "@/api/chat/index";
|
||||
import { useMenuStore } from '@/stores/menu';
|
||||
import { useUIStore } from '@/stores/ui';
|
||||
import { useOrganizationStore } from '@/stores/organization';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import KnowledgeBaseEditorModal from './KnowledgeBaseEditorModal.vue';
|
||||
const usemenuStore = useMenuStore();
|
||||
const uiStore = useUIStore();
|
||||
const orgStore = useOrganizationStore();
|
||||
const authStore = useAuthStore();
|
||||
const router = useRouter();
|
||||
import {
|
||||
batchQueryKnowledge,
|
||||
@@ -32,9 +36,59 @@ const { t } = useI18n();
|
||||
const kbId = computed(() => (route.params as any).kbId as string || '');
|
||||
const kbInfo = ref<any>(null);
|
||||
const uploadInputRef = ref<HTMLInputElement | null>(null);
|
||||
const folderUploadInputRef = ref<HTMLInputElement | null>(null);
|
||||
const uploading = ref(false);
|
||||
const kbLoading = ref(false);
|
||||
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
|
||||
|
||||
// Permission control: check if current user owns this KB or has edit/manage permission
|
||||
const isOwner = computed(() => {
|
||||
if (!kbInfo.value) return false;
|
||||
// Check if the current user's tenant ID matches the KB's tenant ID
|
||||
const userTenantId = authStore.effectiveTenantId;
|
||||
return kbInfo.value.tenant_id === userTenantId;
|
||||
});
|
||||
|
||||
// Can edit: owner, admin, or editor
|
||||
const canEdit = computed(() => {
|
||||
return orgStore.canEditKB(kbId.value, isOwner.value);
|
||||
});
|
||||
|
||||
// Can manage (delete, settings, etc.): owner or admin
|
||||
const canManage = computed(() => {
|
||||
return orgStore.canManageKB(kbId.value, isOwner.value);
|
||||
});
|
||||
|
||||
// Current KB's shared record (when accessed via organization share)
|
||||
const currentSharedKb = computed(() =>
|
||||
orgStore.sharedKnowledgeBases.find((s) => s.knowledge_base?.id === kbId.value) ?? null,
|
||||
);
|
||||
|
||||
// Display role label: owner or org role (admin/editor/viewer)
|
||||
const accessRoleLabel = computed(() => {
|
||||
if (isOwner.value) return t('knowledgeBase.accessInfo.roleOwner');
|
||||
const perm = orgStore.getKBPermission(kbId.value);
|
||||
if (perm) return t(`organization.role.${perm}`);
|
||||
return '--';
|
||||
});
|
||||
|
||||
// Permission summary text for current role
|
||||
const accessPermissionSummary = computed(() => {
|
||||
if (isOwner.value) return t('knowledgeBase.accessInfo.permissionOwner');
|
||||
const perm = orgStore.getKBPermission(kbId.value);
|
||||
if (perm === 'admin') return t('knowledgeBase.accessInfo.permissionAdmin');
|
||||
if (perm === 'editor') return t('knowledgeBase.accessInfo.permissionEditor');
|
||||
if (perm === 'viewer') return t('knowledgeBase.accessInfo.permissionViewer');
|
||||
return '--';
|
||||
});
|
||||
|
||||
// Last updated time from kbInfo
|
||||
const kbLastUpdated = computed(() => {
|
||||
const raw = kbInfo.value?.updated_at;
|
||||
if (!raw) return null;
|
||||
return formatStringDate(new Date(raw));
|
||||
});
|
||||
|
||||
const knowledgeList = ref<Array<{ id: string; name: string; type?: string }>>([]);
|
||||
let { cardList, total, moreIndex, details, getKnowled, delKnowledge, openMore, onVisibleChange, getCardDetails, getfDetails } = useKnowledgeBase(kbId.value)
|
||||
let isCardDetails = ref(false);
|
||||
@@ -397,11 +451,26 @@ const loadKnowledgeBaseInfo = async (targetKbId: string) => {
|
||||
const loadKnowledgeList = async () => {
|
||||
try {
|
||||
const res: any = await listKnowledgeBases();
|
||||
knowledgeList.value = (res?.data || []).map((item: any) => ({
|
||||
const myKbs = (res?.data || []).map((item: any) => ({
|
||||
id: String(item.id),
|
||||
name: item.name,
|
||||
type: item.type || 'document',
|
||||
}));
|
||||
|
||||
// Also include shared knowledge bases from orgStore
|
||||
const sharedKbs = (orgStore.sharedKnowledgeBases || [])
|
||||
.filter(s => s.knowledge_base != null)
|
||||
.map(s => ({
|
||||
id: String(s.knowledge_base.id),
|
||||
name: s.knowledge_base.name,
|
||||
type: s.knowledge_base.type || 'document',
|
||||
}));
|
||||
|
||||
// Merge and deduplicate by id (my KBs take precedence)
|
||||
const myKbIds = new Set(myKbs.map(kb => kb.id));
|
||||
const uniqueSharedKbs = sharedKbs.filter(kb => !myKbIds.has(kb.id));
|
||||
|
||||
knowledgeList.value = [...myKbs, ...uniqueSharedKbs];
|
||||
} catch (error) {
|
||||
console.error('Failed to load knowledge list:', error);
|
||||
}
|
||||
@@ -485,7 +554,9 @@ const handleOpenURLImportDialog = (event: CustomEvent) => {
|
||||
onMounted(() => {
|
||||
loadKnowledgeBaseInfo(kbId.value);
|
||||
loadKnowledgeList();
|
||||
|
||||
// Load shared knowledge bases to get permission info
|
||||
orgStore.fetchSharedKnowledgeBases();
|
||||
|
||||
// 监听文件上传事件
|
||||
window.addEventListener('knowledgeFileUploaded', handleFileUploaded as EventListener);
|
||||
// 监听URL导入对话框打开事件
|
||||
@@ -587,6 +658,32 @@ const documentTitle = computed(() => {
|
||||
return t('knowledgeEditor.document.title');
|
||||
});
|
||||
|
||||
// 文档操作下拉菜单选项
|
||||
const documentActionOptions = computed(() => [
|
||||
{ content: t('upload.uploadDocument'), value: 'upload', prefixIcon: () => h(TIcon, { name: 'upload', size: '16px' }) },
|
||||
{ content: t('upload.uploadFolder'), value: 'uploadFolder', prefixIcon: () => h(TIcon, { name: 'folder-add', size: '16px' }) },
|
||||
{ content: t('knowledgeBase.importURL'), value: 'importURL', prefixIcon: () => h(TIcon, { name: 'link', size: '16px' }) },
|
||||
{ content: t('upload.onlineEdit'), value: 'manualCreate', prefixIcon: () => h(TIcon, { name: 'edit', size: '16px' }) },
|
||||
]);
|
||||
|
||||
// 处理文档操作下拉菜单选择
|
||||
const handleDocumentActionSelect = (data: { value: string }) => {
|
||||
switch (data.value) {
|
||||
case 'upload':
|
||||
handleDocumentUploadClick();
|
||||
break;
|
||||
case 'uploadFolder':
|
||||
handleFolderUploadClick();
|
||||
break;
|
||||
case 'importURL':
|
||||
handleURLImportClick();
|
||||
break;
|
||||
case 'manualCreate':
|
||||
handleManualCreate();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const ensureDocumentKbReady = () => {
|
||||
if (isFAQ.value) {
|
||||
MessagePlugin.warning('当前知识库类型不支持该操作');
|
||||
@@ -609,6 +706,11 @@ const handleDocumentUploadClick = () => {
|
||||
uploadInputRef.value?.click();
|
||||
};
|
||||
|
||||
const handleFolderUploadClick = () => {
|
||||
if (!ensureDocumentKbReady()) return;
|
||||
folderUploadInputRef.value?.click();
|
||||
};
|
||||
|
||||
const resetUploadInput = () => {
|
||||
if (uploadInputRef.value) {
|
||||
uploadInputRef.value.value = '';
|
||||
@@ -705,6 +807,102 @@ const handleDocumentUpload = async (event: Event) => {
|
||||
resetUploadInput();
|
||||
};
|
||||
|
||||
// 处理文件夹上传
|
||||
const handleFolderUpload = async (event: Event) => {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const files = input?.files;
|
||||
if (!files || files.length === 0) return;
|
||||
|
||||
if (!kbId.value) {
|
||||
MessagePlugin.error("缺少知识库ID");
|
||||
if (input) input.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否启用了VLM
|
||||
const vlmEnabled = kbInfo.value?.vlm_config?.enabled || false;
|
||||
|
||||
// 过滤有效文件
|
||||
const validFiles: File[] = [];
|
||||
let hiddenFileCount = 0;
|
||||
let imageFilteredCount = 0;
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
const relativePath = (file as any).webkitRelativePath || file.name;
|
||||
|
||||
// 1. 过滤隐藏文件和隐藏文件夹
|
||||
const pathParts = relativePath.split('/');
|
||||
const hasHiddenComponent = pathParts.some((part: string) => part.startsWith('.'));
|
||||
if (hasHiddenComponent) {
|
||||
hiddenFileCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 2. 如果未启用VLM,过滤图片文件
|
||||
if (!vlmEnabled) {
|
||||
const fileExt = file.name.substring(file.name.lastIndexOf('.') + 1).toLowerCase();
|
||||
const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
|
||||
if (imageTypes.includes(fileExt)) {
|
||||
imageFilteredCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 文件类型验证
|
||||
if (!kbFileTypeVerification(file, true)) {
|
||||
validFiles.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (validFiles.length === 0) {
|
||||
MessagePlugin.warning(t('knowledgeBase.noValidFilesInFolder', { total: files.length }));
|
||||
if (input) input.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingFolder', { total: validFiles.length }));
|
||||
|
||||
// 批量上传
|
||||
let successCount = 0;
|
||||
let failCount = 0;
|
||||
const tagIdToUpload = selectedTagId.value !== '__untagged__' ? selectedTagId.value : undefined;
|
||||
|
||||
for (const file of validFiles) {
|
||||
const relativePath = (file as any).webkitRelativePath;
|
||||
let fileName = file.name;
|
||||
if (relativePath) {
|
||||
const pathParts = relativePath.split('/');
|
||||
if (pathParts.length > 2) {
|
||||
const subPath = pathParts.slice(1, -1).join('/');
|
||||
fileName = `${subPath}/${file.name}`;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await uploadKnowledgeFile(kbId.value, { file, fileName, tag_id: tagIdToUpload });
|
||||
successCount++;
|
||||
} catch (error: any) {
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (successCount > 0) {
|
||||
window.dispatchEvent(new CustomEvent('knowledgeFileUploaded', {
|
||||
detail: { kbId: kbId.value }
|
||||
}));
|
||||
}
|
||||
|
||||
if (failCount === 0) {
|
||||
MessagePlugin.success(t('knowledgeBase.uploadAllSuccess', { count: successCount }));
|
||||
} else if (successCount > 0) {
|
||||
MessagePlugin.warning(t('knowledgeBase.uploadPartialSuccess', { success: successCount, fail: failCount }));
|
||||
} else {
|
||||
MessagePlugin.error(t('knowledgeBase.uploadAllFailed'));
|
||||
}
|
||||
|
||||
if (input) input.value = '';
|
||||
};
|
||||
|
||||
const handleManualCreate = () => {
|
||||
if (!ensureDocumentKbReady()) return;
|
||||
@@ -939,7 +1137,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<t-icon name="chevron-right" class="breadcrumb-separator" />
|
||||
<span class="breadcrumb-current">{{ $t('knowledgeEditor.document.title') }}</span>
|
||||
</h2>
|
||||
<t-tooltip :content="$t('knowledgeBase.settings')" placement="top">
|
||||
<t-tooltip v-if="canManage" :content="$t('knowledgeBase.settings')" placement="top">
|
||||
<button
|
||||
type="button"
|
||||
class="kb-settings-button"
|
||||
@@ -951,6 +1149,41 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<p class="document-subtitle">{{ $t('knowledgeEditor.document.subtitle') }}</p>
|
||||
<!-- 当前知识库权限与来源信息 -->
|
||||
<div v-if="kbInfo" class="kb-access-info">
|
||||
<span class="kb-access-role">
|
||||
<span class="kb-access-label">{{ $t('knowledgeBase.accessInfo.myRole') }}:</span>
|
||||
<t-tag size="small" :theme="isOwner ? 'success' : (currentSharedKb?.permission === 'admin' ? 'primary' : currentSharedKb?.permission === 'editor' ? 'warning' : 'default')">
|
||||
{{ accessRoleLabel }}
|
||||
</t-tag>
|
||||
</span>
|
||||
<span class="kb-access-summary">{{ accessPermissionSummary }}</span>
|
||||
<template v-if="currentSharedKb">
|
||||
<span class="kb-access-sep">·</span>
|
||||
<span class="kb-access-source">
|
||||
{{ $t('knowledgeBase.accessInfo.fromOrg') }}「{{ currentSharedKb.org_name }}」
|
||||
{{ $t('knowledgeBase.accessInfo.sharedAt') }} {{ formatStringDate(new Date(currentSharedKb.shared_at)) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="kbLastUpdated">
|
||||
<span class="kb-access-sep">·</span>
|
||||
<span class="kb-access-updated">{{ $t('knowledgeBase.accessInfo.lastUpdated') }} {{ kbLastUpdated }}</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="canEdit" class="document-header-actions">
|
||||
<t-dropdown
|
||||
:options="documentActionOptions"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
@click="handleDocumentActionSelect"
|
||||
>
|
||||
<t-button class="doc-action-btn dropdown-action-btn">
|
||||
<template #icon><t-icon name="file-add" /></template>
|
||||
<span>{{ $t('knowledgeBase.addDocument') }}</span>
|
||||
<t-icon name="chevron-down" size="14px" class="dropdown-arrow" />
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -962,6 +1195,13 @@ async function createNewSession(value: string): Promise<void> {
|
||||
multiple
|
||||
@change="handleDocumentUpload"
|
||||
/>
|
||||
<input
|
||||
ref="folderUploadInputRef"
|
||||
type="file"
|
||||
class="document-upload-input"
|
||||
webkitdirectory
|
||||
@change="handleFolderUpload"
|
||||
/>
|
||||
<div class="knowledge-main">
|
||||
<aside class="tag-sidebar">
|
||||
<div class="sidebar-header">
|
||||
@@ -969,7 +1209,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<span>{{ $t('knowledgeBase.documentCategoryTitle') }}</span>
|
||||
<span class="sidebar-count">({{ sidebarCategoryCount }})</span>
|
||||
</div>
|
||||
<div class="sidebar-actions">
|
||||
<div v-if="canEdit" class="sidebar-actions">
|
||||
<t-button
|
||||
size="small"
|
||||
variant="text"
|
||||
@@ -1086,7 +1326,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="tag-more" @click.stop>
|
||||
<div v-if="canEdit" class="tag-more" @click.stop>
|
||||
<t-popup trigger="click" placement="top-right" overlayClassName="tag-more-popup">
|
||||
<div class="tag-more-btn">
|
||||
<t-icon name="more" size="14px" />
|
||||
@@ -1168,6 +1408,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<div class="card-content-nav">
|
||||
<span class="card-content-title">{{ item.file_name }}</span>
|
||||
<t-popup
|
||||
v-if="canEdit"
|
||||
v-model="item.isMore"
|
||||
overlayClassName="card-more"
|
||||
:on-visible-change="onVisibleChange"
|
||||
@@ -1232,6 +1473,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<div class="card-bottom-right">
|
||||
<div v-if="tagList.length" class="card-tag-selector" @click.stop>
|
||||
<t-dropdown
|
||||
v-if="canEdit"
|
||||
:options="tagDropdownOptions"
|
||||
trigger="click"
|
||||
@click="(data: any) => handleKnowledgeTagChange(item.id, data.value as string)"
|
||||
@@ -1240,6 +1482,9 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<span class="tag-text">{{ getTagName(item.tag_id) }}</span>
|
||||
</t-tag>
|
||||
</t-dropdown>
|
||||
<t-tag v-else size="small" variant="light-outline">
|
||||
<span class="tag-text">{{ getTagName(item.tag_id) }}</span>
|
||||
</t-tag>
|
||||
</div>
|
||||
<div class="card-type">
|
||||
<span>{{ getKnowledgeType(item) }}</span>
|
||||
@@ -1869,6 +2114,34 @@ async function createNewSession(value: string): Promise<void> {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.document-header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.doc-action-btn {
|
||||
background: linear-gradient(135deg, #07c05f 0%, #00a67e 100%);
|
||||
border: none;
|
||||
color: #fff;
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #05a04f 0%, #008a6a 100%);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.dropdown-action-btn) {
|
||||
.t-button__text {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.dropdown-arrow {
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.document-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -1954,8 +2227,43 @@ async function createNewSession(value: string): Promise<void> {
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.kb-access-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 12px;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.kb-access-label {
|
||||
color: #4e5969;
|
||||
}
|
||||
|
||||
.kb-access-role {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.kb-access-summary {
|
||||
color: #86909c;
|
||||
}
|
||||
|
||||
.kb-access-sep {
|
||||
color: #c9ced6;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.kb-access-source,
|
||||
.kb-access-updated {
|
||||
color: #86909c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.document-upload-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -150,6 +150,11 @@
|
||||
@update:question-generation="handleQuestionGenerationUpdate"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 共享设置(仅编辑模式) -->
|
||||
<div v-if="mode === 'edit' && kbId" v-show="currentSection === 'share'" class="section">
|
||||
<KBShareSettings :kb-id="kbId" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 保存按钮 -->
|
||||
@@ -180,6 +185,7 @@ import KBModelConfig from './settings/KBModelConfig.vue'
|
||||
import KBChunkingSettings from './settings/KBChunkingSettings.vue'
|
||||
import KBAdvancedSettings from './settings/KBAdvancedSettings.vue'
|
||||
import GraphSettings from './settings/GraphSettings.vue'
|
||||
import KBShareSettings from './settings/KBShareSettings.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const uiStore = useUIStore()
|
||||
@@ -219,6 +225,10 @@ const navItems = computed(() => {
|
||||
{ key: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') }
|
||||
)
|
||||
}
|
||||
// 只在编辑模式下显示共享标签页
|
||||
if (props.mode === 'edit' && props.kbId) {
|
||||
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') })
|
||||
}
|
||||
return items
|
||||
})
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,11 +39,10 @@
|
||||
<t-icon name="chevron-right" class="breadcrumb-separator" />
|
||||
<span class="breadcrumb-current">{{ $t('knowledgeEditor.faq.title') }}</span>
|
||||
</h2>
|
||||
<t-tooltip :content="$t('knowledgeBase.settings')" placement="top">
|
||||
<t-tooltip v-if="canManage" :content="$t('knowledgeBase.settings')" placement="top">
|
||||
<button
|
||||
type="button"
|
||||
class="kb-settings-button"
|
||||
:disabled="!props.kbId"
|
||||
@click="handleOpenKBSettings"
|
||||
>
|
||||
<t-icon name="setting" size="16px" />
|
||||
@@ -51,6 +50,41 @@
|
||||
</t-tooltip>
|
||||
</div>
|
||||
<p class="faq-subtitle">{{ $t('knowledgeEditor.faq.subtitle') }}</p>
|
||||
<!-- 当前知识库权限与来源信息 -->
|
||||
<div v-if="kbInfo" class="faq-access-info">
|
||||
<span class="faq-access-role">
|
||||
<span class="faq-access-label">{{ $t('knowledgeBase.accessInfo.myRole') }}:</span>
|
||||
<t-tag size="small" :theme="isOwner ? 'success' : (currentSharedKb?.permission === 'admin' ? 'primary' : currentSharedKb?.permission === 'editor' ? 'warning' : 'default')">
|
||||
{{ accessRoleLabel }}
|
||||
</t-tag>
|
||||
</span>
|
||||
<span class="faq-access-summary">{{ accessPermissionSummary }}</span>
|
||||
<template v-if="currentSharedKb">
|
||||
<span class="faq-access-sep">·</span>
|
||||
<span class="faq-access-source">
|
||||
{{ $t('knowledgeBase.accessInfo.fromOrg') }}「{{ currentSharedKb.org_name }}」
|
||||
{{ $t('knowledgeBase.accessInfo.sharedAt') }} {{ formatImportTime(currentSharedKb.shared_at) }}
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="kbLastUpdated">
|
||||
<span class="faq-access-sep">·</span>
|
||||
<span class="faq-access-updated">{{ $t('knowledgeBase.accessInfo.lastUpdated') }} {{ kbLastUpdated }}</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div class="faq-header-actions">
|
||||
<t-dropdown
|
||||
:options="faqActionOptions"
|
||||
trigger="click"
|
||||
placement="bottom-right"
|
||||
@click="handleFaqAction"
|
||||
>
|
||||
<t-button class="faq-action-btn dropdown-action-btn">
|
||||
<template #icon><t-icon name="help-circle" /></template>
|
||||
<span>{{ $t('knowledgeEditor.faq.manageFaq') }}</span>
|
||||
<t-icon name="chevron-down" size="14px" class="dropdown-arrow" />
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -173,7 +207,7 @@
|
||||
<span>{{ $t('knowledgeBase.faqCategoryTitle') }}</span>
|
||||
<span class="sidebar-count">({{ sidebarCategoryCount }})</span>
|
||||
</div>
|
||||
<div class="sidebar-actions">
|
||||
<div v-if="canEdit" class="sidebar-actions">
|
||||
<t-button
|
||||
size="small"
|
||||
variant="text"
|
||||
@@ -290,7 +324,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="tag-more" @click.stop>
|
||||
<div v-if="canEdit" class="tag-more" @click.stop>
|
||||
<t-popup trigger="click" placement="top-right" overlayClassName="tag-more-popup">
|
||||
<div class="tag-more-btn">
|
||||
<t-icon name="more" size="14px" />
|
||||
@@ -359,6 +393,7 @@
|
||||
</div>
|
||||
<div class="faq-card-actions">
|
||||
<t-popup
|
||||
v-if="canManage"
|
||||
v-model="entry.showMore"
|
||||
overlayClassName="faq-card-popup"
|
||||
trigger="click"
|
||||
@@ -502,7 +537,7 @@
|
||||
<!-- Card Footer -->
|
||||
<div class="faq-card-footer">
|
||||
<div class="faq-card-tag" @click.stop>
|
||||
<template v-if="tagList.length">
|
||||
<template v-if="canEdit && tagList.length">
|
||||
<t-dropdown
|
||||
:options="tagDropdownOptions"
|
||||
trigger="click"
|
||||
@@ -539,22 +574,21 @@
|
||||
</div>
|
||||
</t-tooltip>
|
||||
-->
|
||||
<t-tooltip
|
||||
:content="entry.is_enabled ? $t('knowledgeEditor.faq.statusEnabled') : $t('knowledgeEditor.faq.statusDisabled')"
|
||||
placement="top"
|
||||
>
|
||||
<div class="status-item-compact">
|
||||
<t-switch
|
||||
:key="`${entry.id}-${entry.is_enabled}`"
|
||||
size="small"
|
||||
:value="entry.is_enabled"
|
||||
:loading="!!entryStatusLoading[entry.id]"
|
||||
:disabled="!!entryStatusLoading[entry.id]"
|
||||
@click.stop
|
||||
@change="(value: boolean) => handleEntryStatusChange(entry, value)"
|
||||
/>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
<t-tooltip
|
||||
:content="entry.is_enabled ? $t('knowledgeEditor.faq.statusEnabled') : $t('knowledgeEditor.faq.statusDisabled')"
|
||||
placement="top"
|
||||
>
|
||||
<div class="status-item-compact">
|
||||
<t-switch
|
||||
:key="`${entry.id}-${entry.is_enabled}`"
|
||||
size="small"
|
||||
:value="entry.is_enabled"
|
||||
:loading="!!entryStatusLoading[entry.id]"
|
||||
:disabled="!!entryStatusLoading[entry.id] || !canEdit"
|
||||
@click.stop @change="(value: boolean) => handleEntryStatusChange(entry, value)"
|
||||
/>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1161,6 +1195,8 @@ import { MessagePlugin, DialogPlugin, Icon as TIcon } from 'tdesign-vue-next'
|
||||
import type { FormRules, FormInstanceFunctions } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
import {
|
||||
listFAQEntries,
|
||||
upsertFAQEntries,
|
||||
@@ -1226,6 +1262,95 @@ const props = defineProps<{
|
||||
const { t } = useI18n()
|
||||
const router = useRouter()
|
||||
const uiStore = useUIStore()
|
||||
const authStore = useAuthStore()
|
||||
const orgStore = useOrganizationStore()
|
||||
|
||||
// Permission control: check if current user owns this KB or has edit/manage permission
|
||||
const isOwner = computed(() => {
|
||||
if (!kbInfo.value) return false
|
||||
// Check if the current user's tenant ID matches the KB's tenant ID
|
||||
const userTenantId = authStore.effectiveTenantId
|
||||
return kbInfo.value.tenant_id === userTenantId
|
||||
})
|
||||
|
||||
// Can edit: owner, admin, or editor
|
||||
const canEdit = computed(() => {
|
||||
return orgStore.canEditKB(props.kbId, isOwner.value)
|
||||
})
|
||||
|
||||
// Can manage (delete, settings, etc.): owner or admin
|
||||
const canManage = computed(() => {
|
||||
return orgStore.canManageKB(props.kbId, isOwner.value)
|
||||
})
|
||||
|
||||
// Current KB's shared record (when accessed via organization share)
|
||||
const currentSharedKb = computed(() =>
|
||||
orgStore.sharedKnowledgeBases.find((s) => s.knowledge_base?.id === props.kbId) ?? null,
|
||||
)
|
||||
|
||||
// Display role label: owner or org role (admin/editor/viewer)
|
||||
const accessRoleLabel = computed(() => {
|
||||
if (isOwner.value) return t('knowledgeBase.accessInfo.roleOwner')
|
||||
const perm = orgStore.getKBPermission(props.kbId)
|
||||
if (perm) return t(`organization.role.${perm}`)
|
||||
return '--'
|
||||
})
|
||||
|
||||
// Permission summary text for current role
|
||||
const accessPermissionSummary = computed(() => {
|
||||
if (isOwner.value) return t('knowledgeBase.accessInfo.permissionOwner')
|
||||
const perm = orgStore.getKBPermission(props.kbId)
|
||||
if (perm === 'admin') return t('knowledgeBase.accessInfo.permissionAdmin')
|
||||
if (perm === 'editor') return t('knowledgeBase.accessInfo.permissionEditor')
|
||||
if (perm === 'viewer') return t('knowledgeBase.accessInfo.permissionViewer')
|
||||
return '--'
|
||||
})
|
||||
|
||||
// Last updated time from kbInfo
|
||||
const kbLastUpdated = computed(() => {
|
||||
const raw = kbInfo.value?.updated_at
|
||||
if (!raw) return null
|
||||
return formatImportTime(raw)
|
||||
})
|
||||
|
||||
// FAQ 操作下拉选项
|
||||
const faqActionOptions = computed(() => {
|
||||
const options = []
|
||||
|
||||
// 编辑权限相关操作
|
||||
if (canEdit.value) {
|
||||
options.push(
|
||||
{ content: t('knowledgeEditor.faq.editorCreate'), value: 'create', prefixIcon: () => h(TIcon, { name: 'add', size: '16px' }) },
|
||||
{ content: t('knowledgeEditor.faqImport.importButton'), value: 'import', prefixIcon: () => h(TIcon, { name: 'upload', size: '16px' }) },
|
||||
)
|
||||
}
|
||||
|
||||
// 通用操作
|
||||
options.push(
|
||||
{ content: t('knowledgeEditor.faq.searchTest'), value: 'search', prefixIcon: () => h(TIcon, { name: 'search', size: '16px' }) },
|
||||
{ content: t('knowledgeEditor.faqExport.exportButton'), value: 'export', prefixIcon: () => h(TIcon, { name: 'download', size: '16px' }) },
|
||||
)
|
||||
|
||||
return options
|
||||
})
|
||||
|
||||
// 处理 FAQ 操作
|
||||
const handleFaqAction = (data: { value: string }) => {
|
||||
switch (data.value) {
|
||||
case 'create':
|
||||
openEditor()
|
||||
break
|
||||
case 'import':
|
||||
openImportDialog()
|
||||
break
|
||||
case 'search':
|
||||
searchDrawerVisible.value = true
|
||||
break
|
||||
case 'export':
|
||||
handleExportCSV()
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const loading = ref(false)
|
||||
const loadingMore = ref(false)
|
||||
@@ -1336,11 +1461,26 @@ const loadKnowledgeInfo = async (kbId: string) => {
|
||||
const loadKnowledgeList = async () => {
|
||||
try {
|
||||
const res: any = await listKnowledgeBases()
|
||||
knowledgeList.value = (res?.data || []).map((item: any) => ({
|
||||
const myKbs = (res?.data || []).map((item: any) => ({
|
||||
id: String(item.id),
|
||||
name: item.name,
|
||||
type: item.type,
|
||||
}))
|
||||
|
||||
// Also include shared knowledge bases from orgStore
|
||||
const sharedKbs = (orgStore.sharedKnowledgeBases || [])
|
||||
.filter(s => s.knowledge_base != null)
|
||||
.map(s => ({
|
||||
id: String(s.knowledge_base.id),
|
||||
name: s.knowledge_base.name,
|
||||
type: s.knowledge_base.type,
|
||||
}))
|
||||
|
||||
// Merge and deduplicate by id (my KBs take precedence)
|
||||
const myKbIds = new Set(myKbs.map(kb => kb.id))
|
||||
const uniqueSharedKbs = sharedKbs.filter(kb => !myKbIds.has(kb.id))
|
||||
|
||||
knowledgeList.value = [...myKbs, ...uniqueSharedKbs]
|
||||
} catch (error) {
|
||||
console.error('Failed to load knowledge bases:', error)
|
||||
}
|
||||
@@ -1671,13 +1811,15 @@ const handleKnowledgeDropdownSelect = (data: { value: string }) => {
|
||||
const handleFaqMenuAction = (event: Event) => {
|
||||
const detail = (event as CustomEvent<{ action: string; kbId: string }>).detail
|
||||
if (!detail || detail.kbId !== props.kbId) return
|
||||
|
||||
if (detail.action === 'create') {
|
||||
openEditor()
|
||||
if (canEdit.value) openEditor()
|
||||
} else if (detail.action === 'import') {
|
||||
openImportDialog()
|
||||
if (canEdit.value) openImportDialog()
|
||||
} else if (detail.action === 'search') {
|
||||
searchDrawerVisible.value = true
|
||||
} else if (detail.action === 'export') {
|
||||
// Export is usually allowed for viewers as well
|
||||
handleExportCSV()
|
||||
} else if (detail.action === 'batch') {
|
||||
// 批量操作通过左侧菜单的下拉菜单处理
|
||||
@@ -1685,19 +1827,19 @@ const handleFaqMenuAction = (event: Event) => {
|
||||
MessagePlugin.warning(t('knowledgeEditor.faq.selectEntriesFirst') || '请先选中要操作的FAQ条目')
|
||||
}
|
||||
} else if (detail.action === 'batchTag') {
|
||||
if (selectedRowKeys.value.length > 0) {
|
||||
if (canEdit.value && selectedRowKeys.value.length > 0) {
|
||||
openBatchTagDialog()
|
||||
}
|
||||
} else if (detail.action === 'batchEnable') {
|
||||
if (selectedRowKeys.value.length > 0) {
|
||||
if (canEdit.value && selectedRowKeys.value.length > 0) {
|
||||
handleBatchStatusChange(true)
|
||||
}
|
||||
} else if (detail.action === 'batchDisable') {
|
||||
if (selectedRowKeys.value.length > 0) {
|
||||
if (canEdit.value && selectedRowKeys.value.length > 0) {
|
||||
handleBatchStatusChange(false)
|
||||
}
|
||||
} else if (detail.action === 'batchDelete') {
|
||||
if (selectedRowKeys.value.length > 0) {
|
||||
if (canManage.value && selectedRowKeys.value.length > 0) {
|
||||
handleBatchDelete()
|
||||
}
|
||||
}
|
||||
@@ -3021,6 +3163,8 @@ const handleResize = () => {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// Ensure shared knowledge bases are loaded before loading the knowledge list
|
||||
orgStore.fetchSharedKnowledgeBases()
|
||||
loadKnowledgeList()
|
||||
window.addEventListener('resize', handleResize)
|
||||
window.addEventListener('faqMenuAction', handleFaqMenuAction as EventListener)
|
||||
@@ -3603,6 +3747,160 @@ watch(() => entries.value.map(e => ({
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1px solid #e7ebf0;
|
||||
flex-shrink: 0;
|
||||
|
||||
.faq-header-title {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.faq-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.faq-breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #1d2129;
|
||||
}
|
||||
|
||||
.breadcrumb-link {
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 4px 8px;
|
||||
margin: -4px -8px;
|
||||
font: inherit;
|
||||
color: #4e5969;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
border-radius: 6px;
|
||||
transition: all 0.12s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
color: #10b981;
|
||||
background: #f6f8f7;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
color: #c9ced6;
|
||||
}
|
||||
|
||||
&.dropdown {
|
||||
padding-right: 6px;
|
||||
|
||||
:deep(.t-icon) {
|
||||
font-size: 14px;
|
||||
transition: transform 0.12s ease;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
:deep(.t-icon) {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.breadcrumb-separator {
|
||||
font-size: 14px;
|
||||
color: #c9ced6;
|
||||
}
|
||||
|
||||
.breadcrumb-current {
|
||||
color: #1d2129;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
color: #1d2129;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
.faq-subtitle {
|
||||
margin: 0;
|
||||
color: #00000099;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.faq-access-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 12px;
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #86909c;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.faq-access-label {
|
||||
color: #4e5969;
|
||||
}
|
||||
|
||||
.faq-access-role {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.faq-access-summary {
|
||||
color: #86909c;
|
||||
}
|
||||
|
||||
.faq-access-sep {
|
||||
color: #c9ced6;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.faq-access-source,
|
||||
.faq-access-updated {
|
||||
color: #86909c;
|
||||
}
|
||||
}
|
||||
|
||||
.faq-header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.faq-action-btn {
|
||||
background: linear-gradient(135deg, #26a69a 0%, #00897b 100%);
|
||||
border: none;
|
||||
color: #fff;
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(135deg, #00897b 0%, #00796b 100%);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.dropdown-action-btn) {
|
||||
.t-button__text {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.dropdown-arrow {
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 导入进度条样式(显示在列表页面顶部)
|
||||
@@ -3850,97 +4148,6 @@ watch(() => entries.value.map(e => ({
|
||||
}
|
||||
}
|
||||
|
||||
.faq-header-title {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.faq-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.faq-breadcrumb {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #1d2129;
|
||||
}
|
||||
|
||||
.breadcrumb-link {
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 4px 8px;
|
||||
margin: -4px -8px;
|
||||
font: inherit;
|
||||
color: #4e5969;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
border-radius: 6px;
|
||||
transition: all 0.12s ease;
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
color: #10b981;
|
||||
background: #f6f8f7;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
color: #c9ced6;
|
||||
}
|
||||
|
||||
&.dropdown {
|
||||
padding-right: 6px;
|
||||
|
||||
:deep(.t-icon) {
|
||||
font-size: 14px;
|
||||
transition: transform 0.12s ease;
|
||||
}
|
||||
|
||||
&:hover:not(:disabled) {
|
||||
:deep(.t-icon) {
|
||||
transform: translateY(1px);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.breadcrumb-separator {
|
||||
font-size: 14px;
|
||||
color: #c9ced6;
|
||||
}
|
||||
|
||||
.breadcrumb-current {
|
||||
color: #1d2129;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
color: #1d2129;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
.faq-subtitle {
|
||||
margin: 0;
|
||||
color: #00000099;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
|
||||
.tag-filter-bar {
|
||||
display: flex;
|
||||
|
||||
@@ -0,0 +1,550 @@
|
||||
<template>
|
||||
<div class="section-content">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">{{ $t('organization.share.title') }}</h3>
|
||||
<p class="section-desc">{{ $t('knowledgeEditor.share.description') }}</p>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<!-- 共享表单 -->
|
||||
<div class="share-form">
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('organization.share.selectOrg') }}</label>
|
||||
<div class="share-input-row">
|
||||
<t-select
|
||||
v-model="selectedOrgId"
|
||||
:placeholder="$t('organization.share.selectOrgPlaceholder')"
|
||||
:loading="loadingOrgs"
|
||||
class="org-select"
|
||||
>
|
||||
<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-select
|
||||
v-model="selectedPermission"
|
||||
class="permission-select"
|
||||
>
|
||||
<t-option value="viewer" :label="$t('organization.share.permissionReadonly')" />
|
||||
<t-option value="editor" :label="$t('organization.share.permissionEditable')" />
|
||||
</t-select>
|
||||
<t-button
|
||||
theme="primary"
|
||||
:loading="submitting"
|
||||
:disabled="!selectedOrgId"
|
||||
@click="handleShare"
|
||||
>
|
||||
{{ $t('knowledgeEditor.share.addShare') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<p class="form-tip">{{ $t('organization.share.permissionTip') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 已共享列表 -->
|
||||
<div class="shares-section">
|
||||
<div class="shares-header">
|
||||
<span class="shares-title">{{ $t('organization.share.sharedTo') }}</span>
|
||||
<span class="shares-count">{{ shares.length }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="loadingShares" class="shares-loading">
|
||||
<t-loading size="small" />
|
||||
<span>{{ $t('common.loading') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else-if="shares.length === 0" class="shares-empty">
|
||||
<t-icon name="share" class="empty-icon" />
|
||||
<span>{{ $t('organization.share.noShares') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else class="shares-list">
|
||||
<div v-for="share in shares" :key="share.id" class="share-item">
|
||||
<div class="share-info">
|
||||
<div class="share-org">
|
||||
<t-icon name="usergroup" class="org-icon" />
|
||||
<span class="org-name">{{ share.organization_name }}</span>
|
||||
</div>
|
||||
<t-tag
|
||||
:theme="share.permission === 'editor' ? 'warning' : 'default'"
|
||||
size="small"
|
||||
variant="light"
|
||||
>
|
||||
{{ share.permission === 'editor' ? $t('organization.share.permissionEditable') : $t('organization.share.permissionReadonly') }}
|
||||
</t-tag>
|
||||
</div>
|
||||
<div class="share-actions">
|
||||
<t-select
|
||||
:value="share.permission"
|
||||
size="small"
|
||||
class="permission-change-select"
|
||||
@change="(val: string) => handleUpdatePermission(share, val)"
|
||||
>
|
||||
<t-option value="viewer" :label="$t('organization.share.permissionReadonly')" />
|
||||
<t-option value="editor" :label="$t('organization.share.permissionEditable')" />
|
||||
</t-select>
|
||||
<t-popconfirm
|
||||
:content="$t('knowledgeEditor.share.unshareConfirm', { name: share.organization_name })"
|
||||
@confirm="handleUnshare(share)"
|
||||
>
|
||||
<t-button variant="text" theme="danger" size="small">
|
||||
<t-icon name="delete" />
|
||||
</t-button>
|
||||
</t-popconfirm>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 提示信息 -->
|
||||
<div class="share-tips">
|
||||
<t-icon name="info-circle" class="tip-icon" />
|
||||
<div class="tip-content">
|
||||
<p>{{ $t('knowledgeEditor.share.tip1') }}</p>
|
||||
<p>{{ $t('knowledgeEditor.share.tip2') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
import { shareKnowledgeBase, listKBShares, removeShare, updateSharePermission } from '@/api/organization'
|
||||
import type { KnowledgeBaseShare } from '@/api/organization'
|
||||
|
||||
const { t } = useI18n()
|
||||
const orgStore = useOrganizationStore()
|
||||
|
||||
interface Props {
|
||||
kbId: string
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const loadingOrgs = ref(false)
|
||||
const loadingShares = ref(false)
|
||||
const submitting = ref(false)
|
||||
const selectedOrgId = ref('')
|
||||
const selectedPermission = ref<'viewer' | 'editor'>('viewer')
|
||||
const shares = ref<(KnowledgeBaseShare & { organization_name?: string })[]>([])
|
||||
|
||||
// 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')
|
||||
)
|
||||
})
|
||||
|
||||
// Load organizations
|
||||
async function loadOrganizations() {
|
||||
loadingOrgs.value = true
|
||||
try {
|
||||
await orgStore.fetchOrganizations()
|
||||
} finally {
|
||||
loadingOrgs.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Load shares
|
||||
async function loadShares() {
|
||||
if (!props.kbId) return
|
||||
loadingShares.value = true
|
||||
try {
|
||||
const result = await listKBShares(props.kbId)
|
||||
if (result.success && result.data) {
|
||||
// result.data is ListSharesResponse with shares array
|
||||
const sharesData = (result.data as any).shares || result.data
|
||||
const sharesList = Array.isArray(sharesData) ? sharesData : []
|
||||
shares.value = sharesList.map((share: KnowledgeBaseShare) => ({
|
||||
...share,
|
||||
organization_name: 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
|
||||
}
|
||||
}
|
||||
|
||||
// Handle share
|
||||
async function handleShare() {
|
||||
if (!selectedOrgId.value) return
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const result = await shareKnowledgeBase(props.kbId, {
|
||||
organization_id: selectedOrgId.value,
|
||||
permission: selectedPermission.value
|
||||
})
|
||||
if (result.success) {
|
||||
MessagePlugin.success(t('organization.share.shareSuccess'))
|
||||
selectedOrgId.value = ''
|
||||
selectedPermission.value = 'viewer'
|
||||
await loadShares()
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.share.shareFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.share.shareFailed'))
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Handle update permission
|
||||
async function handleUpdatePermission(share: KnowledgeBaseShare, newPermission: string) {
|
||||
if (share.permission === newPermission) return
|
||||
|
||||
try {
|
||||
const result = await updateSharePermission(props.kbId, share.id, {
|
||||
permission: newPermission as 'viewer' | 'editor'
|
||||
})
|
||||
if (result.success) {
|
||||
MessagePlugin.success(t('organization.roleUpdated'))
|
||||
await loadShares()
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.roleUpdateFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.roleUpdateFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
// Handle unshare
|
||||
async function handleUnshare(share: KnowledgeBaseShare) {
|
||||
try {
|
||||
const result = await removeShare(props.kbId, share.id)
|
||||
if (result.success) {
|
||||
MessagePlugin.success(t('organization.share.unshareSuccess'))
|
||||
await loadShares()
|
||||
} else {
|
||||
MessagePlugin.error(result.message || t('organization.share.unshareFailed'))
|
||||
}
|
||||
} catch (e: any) {
|
||||
MessagePlugin.error(e?.message || t('organization.share.unshareFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
// Watch for kbId changes
|
||||
watch(() => props.kbId, async (newKbId) => {
|
||||
if (newKbId) {
|
||||
await Promise.all([loadOrganizations(), loadShares()])
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
onMounted(async () => {
|
||||
if (props.kbId) {
|
||||
await Promise.all([loadOrganizations(), loadShares()])
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.section-content {
|
||||
.section-header {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 0 0 8px 0;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #000000e6;
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
margin: 0;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
color: #00000066;
|
||||
line-height: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
.share-form {
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 24px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #000000e6;
|
||||
}
|
||||
|
||||
.form-tip {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #00000066;
|
||||
line-height: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.share-input-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
|
||||
.org-select {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.permission-select {
|
||||
width: 120px;
|
||||
}
|
||||
}
|
||||
|
||||
.shares-section {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.shares-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.shares-title {
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #000000e6;
|
||||
}
|
||||
|
||||
.shares-count {
|
||||
padding: 2px 8px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 10px;
|
||||
font-size: 12px;
|
||||
color: #00000066;
|
||||
}
|
||||
}
|
||||
|
||||
.shares-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 32px;
|
||||
color: #00000066;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.shares-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
padding: 40px 20px;
|
||||
background: #fafafa;
|
||||
border-radius: 8px;
|
||||
color: #00000066;
|
||||
|
||||
.empty-icon {
|
||||
font-size: 32px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
.shares-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.share-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12px 16px;
|
||||
background: #fafafa;
|
||||
border-radius: 8px;
|
||||
transition: background 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
}
|
||||
|
||||
.share-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.share-org {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.org-icon {
|
||||
font-size: 16px;
|
||||
color: #0052d9;
|
||||
}
|
||||
|
||||
.org-name {
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #000000e6;
|
||||
}
|
||||
}
|
||||
|
||||
.share-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.permission-change-select {
|
||||
width: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
.share-tips {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
background: #f0f7ff;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #e6f0ff;
|
||||
|
||||
.tip-icon {
|
||||
flex-shrink: 0;
|
||||
font-size: 16px;
|
||||
color: #0052d9;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.tip-content {
|
||||
flex: 1;
|
||||
|
||||
p {
|
||||
margin: 0 0 4px 0;
|
||||
font-size: 13px;
|
||||
color: #00000099;
|
||||
line-height: 20px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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>
|
||||
@@ -0,0 +1,118 @@
|
||||
<template>
|
||||
<div class="join-page">
|
||||
<div class="join-card">
|
||||
<div class="join-icon">
|
||||
<t-icon name="user-add" size="48px" />
|
||||
</div>
|
||||
<h2 class="join-title">{{ $t('organization.join.title') }}</h2>
|
||||
<p v-if="loading" class="join-message">{{ $t('organization.join.joining') }}</p>
|
||||
<p v-else-if="error" class="join-message error">{{ error }}</p>
|
||||
<p v-else class="join-message success">{{ $t('organization.join.success') }}</p>
|
||||
|
||||
<t-button
|
||||
v-if="!loading"
|
||||
theme="primary"
|
||||
@click="goToOrganizations"
|
||||
>
|
||||
{{ $t('organization.join.goToOrganizations') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { t } = useI18n()
|
||||
const orgStore = useOrganizationStore()
|
||||
|
||||
const loading = ref(true)
|
||||
const error = ref('')
|
||||
|
||||
onMounted(async () => {
|
||||
const code = route.query.code as string
|
||||
|
||||
if (!code) {
|
||||
error.value = t('organization.join.noCode')
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await orgStore.join(code)
|
||||
if (result) {
|
||||
MessagePlugin.success(t('organization.join.success'))
|
||||
} else {
|
||||
error.value = orgStore.error || t('organization.join.failed')
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e?.message || t('organization.join.failed')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
const goToOrganizations = () => {
|
||||
router.push('/platform/organizations')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.join-page {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #f7f9fc 0%, #e6f7ec 100%);
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.join-card {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
padding: 48px;
|
||||
text-align: center;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
|
||||
max-width: 400px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.join-icon {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin: 0 auto 24px;
|
||||
border-radius: 50%;
|
||||
background: #e6f7ec;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #00a870;
|
||||
}
|
||||
|
||||
.join-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
color: #1d2129;
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
|
||||
.join-message {
|
||||
font-size: 14px;
|
||||
color: #86909c;
|
||||
margin: 0 0 24px;
|
||||
|
||||
&.error {
|
||||
color: #e34d59;
|
||||
}
|
||||
|
||||
&.success {
|
||||
color: #00a870;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,900 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="modal">
|
||||
<div v-if="visible" class="settings-overlay" @click.self="handleClose">
|
||||
<div class="settings-modal" :class="{ 'join-mode': mode === 'join' }">
|
||||
<!-- 关闭按钮 -->
|
||||
<button class="close-btn" @click="handleClose" :aria-label="$t('common.close')">
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path d="M15 5L5 15M5 5L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div class="settings-container">
|
||||
<!-- 左侧导航 -->
|
||||
<div class="settings-sidebar">
|
||||
<div class="sidebar-header">
|
||||
<h2 class="sidebar-title">{{ modalTitle }}</h2>
|
||||
</div>
|
||||
<div class="settings-nav">
|
||||
<div
|
||||
v-for="(item, index) in navItems"
|
||||
:key="index"
|
||||
:class="['nav-item', { 'active': currentSection === item.key }]"
|
||||
@click="currentSection = item.key"
|
||||
>
|
||||
<t-icon :name="item.icon" class="nav-icon" />
|
||||
<span class="nav-label">{{ item.label }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧内容区域 -->
|
||||
<div class="settings-content">
|
||||
<div class="content-wrapper">
|
||||
<!-- 创建组织 - 基本信息 -->
|
||||
<div v-if="mode === 'create'" v-show="currentSection === 'basic'" class="section">
|
||||
<div class="section-content">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">{{ $t('organization.editor.basicTitle') }}</h3>
|
||||
<p class="section-desc">{{ $t('organization.editor.basicDesc') }}</p>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<div class="form-item">
|
||||
<label class="form-label required">{{ $t('organization.name') }}</label>
|
||||
<div class="name-input-wrapper">
|
||||
<SpaceAvatar :name="createForm.name || '?'" size="large" />
|
||||
<t-input
|
||||
v-model="createForm.name"
|
||||
:placeholder="$t('organization.namePlaceholder')"
|
||||
:maxlength="100"
|
||||
class="name-input"
|
||||
/>
|
||||
</div>
|
||||
<p class="form-tip">{{ $t('organization.editor.nameTip') }}</p>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label">{{ $t('organization.description') }}</label>
|
||||
<t-textarea
|
||||
v-model="createForm.description"
|
||||
:placeholder="$t('organization.descriptionPlaceholder')"
|
||||
:maxlength="500"
|
||||
:autosize="{ minRows: 3, maxRows: 6 }"
|
||||
/>
|
||||
<p class="form-tip">{{ $t('organization.editor.descriptionTip') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 创建组织 - 权限说明 -->
|
||||
<div v-if="mode === 'create'" v-show="currentSection === 'permissions'" class="section">
|
||||
<div class="section-content">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">{{ $t('organization.editor.permissionsTitle') }}</h3>
|
||||
<p class="section-desc">{{ $t('organization.editor.permissionsDesc') }}</p>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<div class="permissions-info">
|
||||
<div class="permission-card">
|
||||
<div class="permission-header">
|
||||
<div class="permission-icon admin">
|
||||
<t-icon name="user-safety" />
|
||||
</div>
|
||||
<div class="permission-title">
|
||||
<span class="role-name">{{ $t('organization.role.admin') }}</span>
|
||||
<t-tag size="small" theme="primary">{{ $t('organization.editor.fullAccess') }}</t-tag>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="permission-list">
|
||||
<li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm1') }}</li>
|
||||
<li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm2') }}</li>
|
||||
<li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm3') }}</li>
|
||||
<li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.adminPerm4') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="permission-card">
|
||||
<div class="permission-header">
|
||||
<div class="permission-icon editor">
|
||||
<t-icon name="edit" />
|
||||
</div>
|
||||
<div class="permission-title">
|
||||
<span class="role-name">{{ $t('organization.role.editor') }}</span>
|
||||
<t-tag size="small" theme="warning">{{ $t('organization.editor.editAccess') }}</t-tag>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="permission-list">
|
||||
<li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.editorPerm1') }}</li>
|
||||
<li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.editorPerm2') }}</li>
|
||||
<li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.shareKBPerm') }}</li>
|
||||
<li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.editorPerm3') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="permission-card">
|
||||
<div class="permission-header">
|
||||
<div class="permission-icon viewer">
|
||||
<t-icon name="browse" />
|
||||
</div>
|
||||
<div class="permission-title">
|
||||
<span class="role-name">{{ $t('organization.role.viewer') }}</span>
|
||||
<t-tag size="small">{{ $t('organization.editor.viewAccess') }}</t-tag>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="permission-list">
|
||||
<li><t-icon name="check" class="check-icon" />{{ $t('organization.editor.viewerPerm1') }}</li>
|
||||
<li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.shareKBPerm') }}</li>
|
||||
<li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.viewerPerm2') }}</li>
|
||||
<li><t-icon name="close" class="close-icon" />{{ $t('organization.editor.viewerPerm3') }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-notice">
|
||||
<t-icon name="info-circle" />
|
||||
<span>{{ $t('organization.editor.ownerNote') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 加入组织 -->
|
||||
<div v-if="mode === 'join'" v-show="currentSection === 'join'" class="section">
|
||||
<div class="section-content">
|
||||
<div class="section-header">
|
||||
<h3 class="section-title">{{ $t('organization.editor.joinTitle') }}</h3>
|
||||
<p class="section-desc">{{ $t('organization.editor.joinDesc') }}</p>
|
||||
</div>
|
||||
<div class="section-body">
|
||||
<div class="join-illustration">
|
||||
<div class="illustration-icon">
|
||||
<t-icon name="user-add" size="48px" />
|
||||
</div>
|
||||
<p class="illustration-text">{{ $t('organization.editor.joinIllustration') }}</p>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<label class="form-label required">{{ $t('organization.inviteCode') }}</label>
|
||||
<t-input
|
||||
v-model="joinForm.invite_code"
|
||||
:placeholder="$t('organization.inviteCodePlaceholder')"
|
||||
:maxlength="32"
|
||||
size="large"
|
||||
class="invite-code-input"
|
||||
/>
|
||||
<p class="form-tip">{{ $t('organization.editor.inviteCodeTip') }}</p>
|
||||
</div>
|
||||
<div class="join-steps">
|
||||
<div class="step-title">{{ $t('organization.editor.howToGetCode') }}</div>
|
||||
<div class="step-list">
|
||||
<div class="step-item">
|
||||
<span class="step-number">1</span>
|
||||
<span class="step-text">{{ $t('organization.editor.step1') }}</span>
|
||||
</div>
|
||||
<div class="step-item">
|
||||
<span class="step-number">2</span>
|
||||
<span class="step-text">{{ $t('organization.editor.step2') }}</span>
|
||||
</div>
|
||||
<div class="step-item">
|
||||
<span class="step-number">3</span>
|
||||
<span class="step-text">{{ $t('organization.editor.step3') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<div class="settings-footer">
|
||||
<t-button theme="default" variant="outline" @click="handleClose">
|
||||
{{ $t('common.cancel') }}
|
||||
</t-button>
|
||||
<t-button theme="primary" @click="handleSubmit" :loading="submitting">
|
||||
{{ mode === 'create' ? $t('common.create') : $t('organization.join.preview') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
|
||||
<!-- 加入确认弹窗 -->
|
||||
<t-dialog
|
||||
v-model:visible="showJoinConfirm"
|
||||
:header="$t('organization.join.confirmTitle')"
|
||||
:confirm-btn="previewInfo?.is_already_member ? $t('common.close') : $t('organization.join.confirm')"
|
||||
:cancel-btn="previewInfo?.is_already_member ? null : $t('common.cancel')"
|
||||
:confirm-on-enter="!previewInfo?.is_already_member"
|
||||
@confirm="previewInfo?.is_already_member ? (showJoinConfirm = false) : confirmJoin()"
|
||||
@cancel="showJoinConfirm = false"
|
||||
:confirm-loading="joining"
|
||||
>
|
||||
<div v-if="previewInfo" class="join-confirm-content">
|
||||
<div class="org-preview-card">
|
||||
<div class="org-preview-header">
|
||||
<div class="org-avatar">
|
||||
<t-icon name="usergroup" size="24px" />
|
||||
</div>
|
||||
<div class="org-info">
|
||||
<h4 class="org-name">{{ previewInfo.name }}</h4>
|
||||
<p class="org-desc">{{ previewInfo.description || $t('organization.noDescription') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="org-stats">
|
||||
<div class="stat-item">
|
||||
<t-icon name="user" />
|
||||
<span>{{ $t('organization.join.memberCount', { count: previewInfo.member_count }) }}</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<t-icon name="folder" />
|
||||
<span>{{ $t('organization.join.shareCount', { count: previewInfo.share_count }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="previewInfo.is_already_member" class="already-member-notice">
|
||||
<t-icon name="check-circle-filled" />
|
||||
<span>{{ $t('organization.join.alreadyMember') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</t-dialog>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { useOrganizationStore } from '@/stores/organization'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { OrganizationPreview } from '@/api/organization'
|
||||
import SpaceAvatar from '@/components/SpaceAvatar.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const orgStore = useOrganizationStore()
|
||||
|
||||
// Props
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
mode: 'create' | 'join'
|
||||
}>()
|
||||
|
||||
// Emits
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void
|
||||
(e: 'success'): void
|
||||
}>()
|
||||
|
||||
const currentSection = ref<string>('basic')
|
||||
const submitting = ref(false)
|
||||
const showJoinConfirm = ref(false)
|
||||
const previewInfo = ref<OrganizationPreview | null>(null)
|
||||
const joining = ref(false)
|
||||
|
||||
const createForm = ref({
|
||||
name: '',
|
||||
description: ''
|
||||
})
|
||||
|
||||
const joinForm = ref({
|
||||
invite_code: ''
|
||||
})
|
||||
|
||||
// 计算属性
|
||||
const modalTitle = computed(() => {
|
||||
return props.mode === 'create'
|
||||
? t('organization.createOrg')
|
||||
: t('organization.joinOrg')
|
||||
})
|
||||
|
||||
const navItems = computed(() => {
|
||||
if (props.mode === 'create') {
|
||||
return [
|
||||
{ key: 'basic', icon: 'info-circle', label: t('organization.editor.navBasic') },
|
||||
{ key: 'permissions', icon: 'user-safety', label: t('organization.editor.navPermissions') }
|
||||
]
|
||||
} else {
|
||||
return [
|
||||
{ key: 'join', icon: 'user-add', label: t('organization.editor.navJoin') }
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
// 方法
|
||||
const resetForm = () => {
|
||||
createForm.value = { name: '', description: '' }
|
||||
joinForm.value = { invite_code: '' }
|
||||
currentSection.value = props.mode === 'create' ? 'basic' : 'join'
|
||||
showJoinConfirm.value = false
|
||||
previewInfo.value = null
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
emit('update:visible', false)
|
||||
setTimeout(resetForm, 300)
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (props.mode === 'create') {
|
||||
await handleCreate()
|
||||
} else {
|
||||
await handleJoin()
|
||||
}
|
||||
}
|
||||
|
||||
const handleCreate = async () => {
|
||||
if (!createForm.value.name.trim()) {
|
||||
MessagePlugin.warning(t('organization.nameRequired'))
|
||||
currentSection.value = 'basic'
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
const result = await orgStore.create(
|
||||
createForm.value.name.trim(),
|
||||
createForm.value.description.trim()
|
||||
)
|
||||
if (result) {
|
||||
MessagePlugin.success(t('organization.createSuccess'))
|
||||
emit('success')
|
||||
handleClose()
|
||||
} else {
|
||||
MessagePlugin.error(orgStore.error || t('organization.createFailed'))
|
||||
}
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('organization.createFailed'))
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleJoin = async () => {
|
||||
if (!joinForm.value.invite_code.trim()) {
|
||||
MessagePlugin.warning(t('organization.inviteCodeRequired'))
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
// First preview the organization
|
||||
const preview = await orgStore.preview(joinForm.value.invite_code.trim())
|
||||
if (preview) {
|
||||
previewInfo.value = preview
|
||||
showJoinConfirm.value = true
|
||||
} else {
|
||||
MessagePlugin.error(orgStore.error || t('organization.join.invalidCode'))
|
||||
}
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('organization.join.invalidCode'))
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const confirmJoin = async () => {
|
||||
if (!joinForm.value.invite_code.trim()) {
|
||||
return
|
||||
}
|
||||
|
||||
joining.value = true
|
||||
try {
|
||||
const result = await orgStore.join(joinForm.value.invite_code.trim())
|
||||
if (result) {
|
||||
MessagePlugin.success(t('organization.joinSuccess'))
|
||||
showJoinConfirm.value = false
|
||||
emit('success')
|
||||
handleClose()
|
||||
} else {
|
||||
MessagePlugin.error(orgStore.error || t('organization.joinFailed'))
|
||||
}
|
||||
} catch (error: any) {
|
||||
MessagePlugin.error(error?.message || t('organization.joinFailed'))
|
||||
} finally {
|
||||
joining.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 监听
|
||||
watch(() => props.visible, (newVal) => {
|
||||
if (newVal) {
|
||||
resetForm()
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => props.mode, () => {
|
||||
currentSection.value = props.mode === 'create' ? 'basic' : 'join'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.settings-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.settings-modal {
|
||||
position: relative;
|
||||
width: 90vw;
|
||||
max-width: 900px;
|
||||
height: 80vh;
|
||||
max-height: 650px;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
|
||||
&.join-mode {
|
||||
max-width: 700px;
|
||||
max-height: 580px;
|
||||
}
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
background: #f5f5f5;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #666;
|
||||
transition: all 0.2s ease;
|
||||
z-index: 10;
|
||||
|
||||
&:hover {
|
||||
background: #e5e5e5;
|
||||
color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.settings-sidebar {
|
||||
width: 200px;
|
||||
background: #fafafa;
|
||||
border-right: 1px solid #e5e5e5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sidebar-header {
|
||||
padding: 24px 20px;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.sidebar-title {
|
||||
margin: 0;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #000000e6;
|
||||
}
|
||||
|
||||
.settings-nav {
|
||||
flex: 1;
|
||||
padding: 12px 8px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.nav-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 4px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
color: #00000099;
|
||||
|
||||
&:hover {
|
||||
background: #f0f0f0;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: #07c05f1a;
|
||||
color: #07c05f;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.nav-label {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.settings-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 24px 32px;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.section-content {
|
||||
.section-header {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin: 0 0 8px 0;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #000000e6;
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
margin: 0;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
color: #00000066;
|
||||
line-height: 22px;
|
||||
}
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 24px;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #000000e6;
|
||||
|
||||
&.required::after {
|
||||
content: '*';
|
||||
color: #FA5151;
|
||||
margin-left: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.form-tip {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
color: #00000066;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
.name-input-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
.name-input-wrapper .name-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
// 权限说明样式
|
||||
.permissions-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.permission-card {
|
||||
background: #fafafa;
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
border: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.permission-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.permission-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
|
||||
&.admin {
|
||||
background: linear-gradient(135deg, #07c05f, #05a04f);
|
||||
}
|
||||
|
||||
&.editor {
|
||||
background: linear-gradient(135deg, #f5a623, #e09612);
|
||||
}
|
||||
|
||||
&.viewer {
|
||||
background: linear-gradient(135deg, #909399, #606266);
|
||||
}
|
||||
}
|
||||
|
||||
.permission-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
|
||||
.role-name {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #000000e6;
|
||||
}
|
||||
}
|
||||
|
||||
.permission-list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
|
||||
li {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 0;
|
||||
font-size: 13px;
|
||||
color: #00000099;
|
||||
}
|
||||
|
||||
.check-icon {
|
||||
color: #07c05f;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.close-icon {
|
||||
color: #FA5151;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.info-notice {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
margin-top: 20px;
|
||||
padding: 12px 16px;
|
||||
background: #e8f4ff;
|
||||
border-radius: 8px;
|
||||
color: #0052d9;
|
||||
font-size: 13px;
|
||||
line-height: 20px;
|
||||
|
||||
.t-icon {
|
||||
flex-shrink: 0;
|
||||
margin-top: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
// 加入组织样式
|
||||
.join-illustration {
|
||||
text-align: center;
|
||||
padding: 24px 0 32px;
|
||||
|
||||
.illustration-icon {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
margin: 0 auto 16px;
|
||||
background: linear-gradient(135deg, #07c05f1a, #07c05f0d);
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #07c05f;
|
||||
}
|
||||
|
||||
.illustration-text {
|
||||
margin: 0;
|
||||
font-size: 14px;
|
||||
color: #00000066;
|
||||
}
|
||||
}
|
||||
|
||||
.invite-code-input {
|
||||
:deep(.t-input__inner) {
|
||||
font-size: 16px;
|
||||
letter-spacing: 1px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.join-steps {
|
||||
margin-top: 32px;
|
||||
padding: 20px;
|
||||
background: #fafafa;
|
||||
border-radius: 8px;
|
||||
|
||||
.step-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #000000e6;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.step-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.step-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.step-number {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: #07c05f;
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.step-text {
|
||||
font-size: 13px;
|
||||
color: #00000099;
|
||||
}
|
||||
}
|
||||
|
||||
.settings-footer {
|
||||
padding: 16px 32px;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// 过渡动画
|
||||
.modal-enter-active,
|
||||
.modal-leave-active {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-enter-from,
|
||||
.modal-leave-to {
|
||||
opacity: 0;
|
||||
|
||||
.settings-modal {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
}
|
||||
|
||||
// 加入确认弹窗样式
|
||||
.join-confirm-content {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.org-preview-card {
|
||||
background: #fafafa;
|
||||
border-radius: 8px;
|
||||
padding: 16px;
|
||||
border: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.org-preview-header {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.org-avatar {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background: linear-gradient(135deg, #07c05f, #05a04f);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #fff;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.org-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.org-name {
|
||||
margin: 0 0 4px 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #000000e6;
|
||||
}
|
||||
|
||||
.org-desc {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
color: #00000066;
|
||||
line-height: 20px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
.org-stats {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
color: #00000099;
|
||||
|
||||
.t-icon {
|
||||
font-size: 16px;
|
||||
color: #00000066;
|
||||
}
|
||||
}
|
||||
|
||||
.already-member-notice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
padding: 12px 16px;
|
||||
background: #e8f4ff;
|
||||
border-radius: 8px;
|
||||
color: #0052d9;
|
||||
font-size: 14px;
|
||||
|
||||
.t-icon {
|
||||
font-size: 18px;
|
||||
color: #07c05f;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user