Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat(organization): add member limit feature
wizardchenca1b3da1dff6
diff --git "a/docs/\345\267\245\344\275\234\347\251\272\351\227\264\350\257\264\346\230\216.md" "b/docs/\345\267\245\344\275\234\347\251\272\351\227\264\350\257\264\346\230\216.md"index 6677de59d..befba320f 100644--- "a/docs/\345\267\245\344\275\234\347\251\272\351\227\264\350\257\264\346\230\216.md"+++ "b/docs/\345\267\245\344\275\234\347\251\272\351\227\264\350\257\264\346\230\216.md"@@ -54,19 +54,27 @@- 空间管理员审批通过时可指定角色(管理员/编辑者/只读);若不指定,则使用申请时填写的角色或默认只读。- 审批拒绝后,用户不是成员,无法访问该空间及其共享知识库。-### 2.3 邀请码+### 2.3 成员人数上限++- 空间可设置**成员人数上限**(默认 50;设为 0 表示不限制)。+- 达到或超过上限时:+ - 邀请码加入、管理员添加成员、审批通过加入均会被拒绝,并提示「该空间成员已满」;+ - 已满时不允许提交新的加入申请。+- 管理员在设置中调低上限时,若当前成员数已超过新上限,不允许保存,需先移除成员或设置更大的上限。++### 2.4 邀请码- 仅空间**管理员**可生成或刷新邀请码。- 邀请码可设置有效期(例如 1 天、7 天、30 天或永不过期);过期后需重新生成才能使用。- 同一时间一个空间仅有一个有效邀请码;重新生成会使旧邀请码失效。-### 2.4 离开空间+### 2.5 离开空间- 成员可主动退出空间(无需管理员同意)。- 管理员可移除其他成员(不能移除空间创建者)。- 退出或移除后,该用户不再拥有该空间内的任何角色,也无法再通过该空间访问其共享的知识库。-### 2.5 删除空间+### 2.6 删除空间- 仅空间**创建者**可删除空间。- 删除空间时会解除该空间下所有知识库的共享关系,成员将无法再通过该空间访问这些知识库。diff --git a/frontend/src/api/organization/index.ts b/frontend/src/api/organization/index.tsindex c733e2116..ef281512c 100644--- a/frontend/src/api/organization/index.ts+++ b/frontend/src/api/organization/index.ts@@ -12,6 +12,8 @@ export interface Organization {invite_code_validity_days?: numberrequire_approval?: booleansearchable?: boolean+ /** Max members; 0 = unlimited */+ member_limit?: numbermember_count?: numbershare_count?: numberpending_join_request_count?: number@@ -101,6 +103,7 @@ export interface CreateOrganizationRequest {description?: stringavatar?: stringinvite_code_validity_days?: number // 0=never, 1, 7, 30; default 7+ member_limit?: number // 0=unlimited; default 50}export interface UpdateOrganizationRequest {@@ -110,6 +113,7 @@ export interface UpdateOrganizationRequest {require_approval?: booleansearchable?: booleaninvite_code_validity_days?: number // 0=never, 1, 7, 30+ member_limit?: number // 0=unlimited}export interface UpdateMemberRoleRequest {diff --git a/frontend/src/assets/img/organization-green.svg b/frontend/src/assets/img/organization-green.svgindex 33dd02f29..f821b10af 100644--- a/frontend/src/assets/img/organization-green.svg+++ b/frontend/src/assets/img/organization-green.svg@@ -1,3 +1,17 @@-<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 width="20" height="20" viewBox="0 0 56 40" fill="none" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">+ <defs>+ <radialGradient id="orbGreen" cx="0.35" cy="0.35" r="0.7" gradientUnits="objectBoundingBox">+ <stop offset="0%" stop-color="#6ee7a0"/>+ <stop offset="45%" stop-color="#07C05F"/>+ <stop offset="100%" stop-color="#047857"/>+ </radialGradient>+ </defs>+ <!-- 连接线:粗实线 -->+ <path d="M14 13 L24 10 M32 10 L42 13" stroke="#07C05F" stroke-width="2.2" stroke-linecap="round" opacity="0.95"/>+ <path d="M28 14 L28 22 M20 18 L26 24 M36 18 L30 24" stroke="#07C05F" stroke-width="1.8" stroke-linecap="round" opacity="0.9"/>+ <!-- 节点:立体球体 -->+ <circle cx="10" cy="12" r="5" fill="url(#orbGreen)" stroke="#059669" stroke-width="0.8"/>+ <circle cx="28" cy="8" r="6" fill="url(#orbGreen)" stroke="#059669" stroke-width="0.9"/>+ <circle cx="46" cy="14" r="5" fill="url(#orbGreen)" stroke="#059669" stroke-width="0.8"/>+ <circle cx="28" cy="28" r="7" fill="url(#orbGreen)" stroke="#059669" stroke-width="0.9"/></svg>diff --git a/frontend/src/assets/img/organization.svg b/frontend/src/assets/img/organization.svgindex 83495f56a..222f40d6e 100644--- a/frontend/src/assets/img/organization.svg+++ b/frontend/src/assets/img/organization.svg@@ -1,3 +1,21 @@-<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 width="20" height="20" viewBox="0 0 56 40" fill="none" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">+ <defs>+ <radialGradient id="orbGray" cx="0.35" cy="0.35" r="0.7" gradientUnits="objectBoundingBox">+ <stop offset="0%" stop-color="#b5b5b5"/>+ <stop offset="45%" stop-color="#6b6b6b"/>+ <stop offset="100%" stop-color="#3d3d3d"/>+ </radialGradient>+ <linearGradient id="lineGray" x1="0%" y1="0%" x2="100%" y2="0%" gradientUnits="objectBoundingBox">+ <stop offset="0%" stop-color="#5c5c5c"/>+ <stop offset="100%" stop-color="#4a4a4a"/>+ </linearGradient>+ </defs>+ <!-- 连接线:粗实线增强空间感 -->+ <path d="M14 13 L24 10 M32 10 L42 13" stroke="#5c5c5c" stroke-width="2.2" stroke-linecap="round" opacity="0.9"/>+ <path d="M28 14 L28 22 M20 18 L26 24 M36 18 L30 24" stroke="#5c5c5c" stroke-width="1.8" stroke-linecap="round" opacity="0.85"/>+ <!-- 节点:立体球体 -->+ <circle cx="10" cy="12" r="5" fill="url(#orbGray)" stroke="#4a4a4a" stroke-width="0.8"/>+ <circle cx="28" cy="8" r="6" fill="url(#orbGray)" stroke="#4a4a4a" stroke-width="0.9"/>+ <circle cx="46" cy="14" r="5" fill="url(#orbGray)" stroke="#4a4a4a" stroke-width="0.8"/>+ <circle cx="28" cy="28" r="7" fill="url(#orbGray)" stroke="#4a4a4a" stroke-width="0.9"/></svg>diff --git a/frontend/src/components/SpaceAvatar.vue b/frontend/src/components/SpaceAvatar.vueindex d3b356898..73dd6b895 100644--- a/frontend/src/components/SpaceAvatar.vue+++ b/frontend/src/components/SpaceAvatar.vue@@ -4,9 +4,14 @@: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 class="space-avatar-decoration" viewBox="0 0 56 40" preserveAspectRatio="xMaxYMax meet" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">+ <circle cx="10" cy="12" r="4" stroke="currentColor" stroke-width="1.5" fill="none" opacity="0.5"/>+ <circle cx="28" cy="8" r="5" stroke="currentColor" stroke-width="1.8" fill="none" opacity="0.7"/>+ <circle cx="46" cy="14" r="4" stroke="currentColor" stroke-width="1.5" fill="none" opacity="0.5"/>+ <path d="M14 13 L24 10 M32 10 L42 13" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" opacity="0.4"/>+ <circle cx="28" cy="28" r="6" stroke="currentColor" stroke-width="1.2" fill="none" opacity="0.35"/>+ <path d="M28 14 L28 22 M20 18 L26 24 M36 18 L30 24" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.3"/></svg><span class="space-avatar-letter" :style="letterStyle">{{ letter }}</span></div>@@ -117,11 +122,12 @@ const letterStyle = computed(() => {.space-avatar-decoration {position: absolute;- right: 2px;- bottom: 2px;- width: 40%;- height: 40%;- opacity: 0.85;+ right: 0;+ bottom: 0;+ width: 55%;+ height: 55%;+ opacity: 0.35;+ color: rgba(255, 255, 255, 0.9);pointer-events: none;}diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex 8262d4b0a..540f41759 100755--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -2482,6 +2482,10 @@ export default {requireApprovalDesc: 'When enabled, new members need admin approval to join',searchable: 'Open for search',searchableDesc: 'When enabled, this space appears in the "Join Space" search list; others can search and request to join without an invite code',+ memberLimit: 'Member limit',+ memberLimitDesc: 'No new members can be added when the limit is reached; 0 means unlimited',+ memberLimitPlaceholder: '0 = unlimited',+ memberLimitHint: 'Current members: {count}',joinRequests: 'Join Requests',joinRequestsDesc: 'Review pending requests to join the space',noPendingRequests: 'No pending requests',diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex b54c9d54e..e13980c0d 100755--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -2487,6 +2487,10 @@ export default {requireApprovalDesc: "开启后,新成员加入需要管理员审核",searchable: "开放可被搜索",searchableDesc: "开启后,空间将出现在「加入空间」的搜索列表中,他人可搜索并申请加入,无需邀请码",+ memberLimit: "成员人数上限",+ memberLimitDesc: "超过上限后无法再添加新成员;设为 0 表示不限制",+ memberLimitPlaceholder: "0 表示不限制",+ memberLimitHint: "当前成员数:{count}",joinRequests: "加入申请",joinRequestsDesc: "审核待加入空间的申请",noPendingRequests: "暂无待审核的申请",diff --git a/frontend/src/views/organization/OrganizationList.vue b/frontend/src/views/organization/OrganizationList.vueindex 0946f1dbb..6acdb0f50 100644--- a/frontend/src/views/organization/OrganizationList.vue+++ b/frontend/src/views/organization/OrganizationList.vue@@ -51,13 +51,15 @@:class="{ 'joined-org': !org.is_owner }"@click="handleCardClick(org)">- <!-- 装饰图标 - 无限/连接/圈子 -->+ <!-- 装饰:协作网络感图形 --><div class="card-decoration">- <svg class="org-icon" width="28" height="28" 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="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.9"/>- </svg>- <svg class="connect-icon" width="16" height="16" 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="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none" opacity="0.7"/>+ <svg class="card-deco-svg" width="56" height="40" viewBox="0 0 56 40" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">+ <circle cx="10" cy="12" r="4" stroke="currentColor" stroke-width="1.5" fill="none" opacity="0.5"/>+ <circle cx="28" cy="8" r="5" stroke="currentColor" stroke-width="1.8" fill="none" opacity="0.7"/>+ <circle cx="46" cy="14" r="4" stroke="currentColor" stroke-width="1.5" fill="none" opacity="0.5"/>+ <path d="M14 13 L24 10 M32 10 L42 13" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" opacity="0.4"/>+ <circle cx="28" cy="28" r="6" stroke="currentColor" stroke-width="1.2" fill="none" opacity="0.35"/>+ <path d="M28 14 L28 22 M20 18 L26 24 M36 18 L30 24" stroke="currentColor" stroke-width="1" stroke-linecap="round" opacity="0.3"/></svg></div>@@ -70,7 +72,6 @@</div><div class="card-title-block"><span class="card-title" :title="org.name">{{ org.name }}</span>- <span v-if="!org.is_owner" class="card-subtitle">{{ $t('organization.joinedByMe') }}</span></div></div><t-popup@@ -118,6 +119,11 @@<div class="card-bottom"><div class="bottom-left"><div class="feature-badges">+ <t-tooltip v-if="!org.is_owner" :content="$t('organization.joinedByMe')" placement="top">+ <div class="feature-badge joined-badge">+ <t-icon name="usergroup" size="14px" />+ </div>+ </t-tooltip><t-tooltip :content="$t('organization.memberCount')" placement="top"><div class="feature-badge member-badge"><t-icon name="user" size="14px" />@@ -968,15 +974,16 @@ onUnmounted(() => {.header-title {display: flex;flex-direction: column;- gap: 4px;+ gap: 6px;}h2 {margin: 0;- color: #000000e6;- font-family: "PingFang SC";- font-size: 24px;+ color: #0f172a;+ font-family: "PingFang SC", system-ui, sans-serif;+ font-size: 26px;font-weight: 600;+ letter-spacing: -0.02em;line-height: 32px;}@@ -986,23 +993,30 @@ onUnmounted(() => {gap: 12px;.org-join-btn {- border-color: #07c05f;- color: #07c05f;-+ border-color: rgba(7, 192, 95, 0.5);+ color: #059669;+ font-weight: 500;+ transition: all 0.2s ease;+&:hover {- background-color: rgba(7, 192, 95, 0.08);- border-color: #05a04f;- color: #05a04f;+ background: linear-gradient(135deg, rgba(7, 192, 95, 0.06) 0%, rgba(0, 166, 126, 0.06) 100%);+ border-color: #07c05f;+ color: #047857;}}.org-create-btn {- background: linear-gradient(135deg, #07c05f 0%, #00a67e 100%);+ background: linear-gradient(135deg, #07c05f 0%, #059669 50%, #047857 100%);border: none;color: #fff;+ font-weight: 500;+ box-shadow: 0 2px 8px rgba(7, 192, 95, 0.25);+ transition: all 0.25s ease;&:hover {- background: linear-gradient(135deg, #05a04f 0%, #008a6a 100%);+ background: linear-gradient(135deg, #059669 0%, #047857 100%);+ box-shadow: 0 4px 14px rgba(7, 192, 95, 0.35);+ transform: translateY(-1px);}}}@@ -1010,26 +1024,26 @@ onUnmounted(() => {.header-subtitle {margin: 0;- color: #00000099;- font-family: "PingFang SC";+ color: #64748b;+ font-family: "PingFang SC", system-ui, sans-serif;font-size: 14px;font-weight: 400;line-height: 20px;}-// Tab 切换样式(下划线式,简洁清晰)+// Tab 切换样式(下划线式,与整体协作感一致).org-tabs {display: flex;align-items: center;- gap: 24px;- border-bottom: 1px solid #e7ebf0;- margin-bottom: 20px;+ gap: 28px;+ border-bottom: 1px solid #e2e8f0;+ margin-bottom: 24px;.tab-item {padding: 12px 0;cursor: pointer;- color: #666;- font-family: "PingFang SC";+ color: #64748b;+ font-family: "PingFang SC", system-ui, sans-serif;font-size: 14px;font-weight: 400;user-select: none;@@ -1037,11 +1051,11 @@ onUnmounted(() => {transition: color 0.2s ease;&:hover {- color: #333;+ color: #334155;}&.active {- color: #07c05f;+ color: #059669;font-weight: 500;&::after {@@ -1051,7 +1065,7 @@ onUnmounted(() => {left: 0;right: 0;height: 2px;- background: #07c05f;+ background: linear-gradient(90deg, #07c05f, #059669);border-radius: 1px;}}@@ -1079,38 +1093,50 @@ onUnmounted(() => {}.org-card {- border: 1px solid #e8ecf1;- border-radius: 12px;+ border: 1px solid #e2e8f0;+ border-radius: 14px;overflow: hidden;box-sizing: border-box;box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);- background: #fff;+ background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);position: relative;cursor: pointer;- transition: border-color 0.2s ease, box-shadow 0.2s ease;+ transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;padding: 18px 20px;display: flex;flex-direction: column;height: 160px;+ &::before {+ content: '';+ position: absolute;+ top: 0;+ right: 0;+ width: 120px;+ height: 80px;+ background: radial-gradient(ellipse 60% 50% at 100% 0%, rgba(7, 192, 95, 0.06) 0%, transparent 70%);+ pointer-events: none;+ z-index: 0;+ }+&.joined-org {&:hover {- border-color: #b8e6c9;- box-shadow: 0 2px 8px rgba(7, 192, 95, 0.08);+ border-color: rgba(7, 192, 95, 0.4);+ box-shadow: 0 4px 16px rgba(7, 192, 95, 0.08);}}&:hover {- border-color: #07c05f;- box-shadow: 0 2px 10px rgba(7, 192, 95, 0.1);+ border-color: rgba(7, 192, 95, 0.5);+ box-shadow: 0 6px 20px rgba(7, 192, 95, 0.12);}.card-decoration {- color: rgba(7, 192, 95, 0.24);+ color: rgba(7, 192, 95, 0.35);}&:hover .card-decoration {- color: rgba(7, 192, 95, 0.38);+ color: rgba(7, 192, 95, 0.55);}.card-header {@@ -1125,25 +1151,20 @@ onUnmounted(() => {}}-// 装饰图标样式+// 卡片装饰:协作网络图形.card-decoration {position: absolute;- top: 10px;- right: 50px;+ top: 8px;+ right: 16px;display: flex;align-items: flex-start;- gap: 6px;+ justify-content: flex-end;pointer-events: none;z-index: 0;- transition: color 0.25s ease;+ transition: color 0.3s ease;- .org-icon {- opacity: 0.9;- }-- .connect-icon {- margin-top: 16px;- opacity: 0.7;+ .card-deco-svg {+ display: block;}}@@ -1191,14 +1212,6 @@ onUnmounted(() => {white-space: nowrap;}-.card-subtitle {- font-family: "PingFang SC";- font-size: 12px;- font-weight: 400;- color: #9ca3af;- line-height: 1.3;-}-.more-wrap {display: flex;width: 28px;@@ -1256,7 +1269,7 @@ onUnmounted(() => {justify-content: space-between;margin-top: auto;padding-top: 12px;- border-top: 1px solid #f0f2f5;+ border-top: 1px solid rgba(226, 232, 240, 0.8);}.bottom-left {@@ -1312,6 +1325,15 @@ onUnmounted(() => {}}+ &.joined-badge {+ padding: 0 6px;+ background: rgba(100, 116, 139, 0.08);+ color: #64748b;++ &:hover {+ background: rgba(100, 116, 139, 0.12);+ }+ }}.role-tag {@@ -1596,8 +1618,12 @@ onUnmounted(() => {max-width: 480px;max-height: 90vh;background: #ffffff;- border-radius: 12px;- box-shadow: 0 6px 28px rgba(15, 23, 42, 0.08);+ border-radius: 16px;+ box-shadow:+ 0 0 0 1px rgba(0, 0, 0, 0.04),+ 0 4px 6px -1px rgba(15, 23, 42, 0.06),+ 0 12px 24px -4px rgba(15, 23, 42, 0.1),+ 0 24px 48px -8px rgba(15, 23, 42, 0.12);overflow: hidden;display: flex;flex-direction: column;@@ -1607,39 +1633,46 @@ onUnmounted(() => {display: flex;align-items: center;justify-content: space-between;- padding: 24px 24px 16px;- border-bottom: 1px solid #e5e5e5;+ padding: 28px 24px 20px;+ background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);+ border-bottom: 1px solid rgba(0, 0, 0, 0.06);flex-shrink: 0;}.invite-preview-title {margin: 0;- font-family: "PingFang SC";- font-size: 16px;+ font-family: "PingFang SC", -apple-system, sans-serif;+ font-size: 18px;font-weight: 600;- color: #000000e6;+ color: #0f172a;+ letter-spacing: -0.02em;}.invite-preview-close {position: absolute;top: 20px;right: 20px;- width: 32px;- height: 32px;+ width: 36px;+ height: 36px;border: none;- background: #f5f5f5;- border-radius: 6px;+ background: rgba(0, 0, 0, 0.04);+ border-radius: 10px;cursor: pointer;display: flex;align-items: center;justify-content: center;- color: #666;- transition: all 0.2s ease;+ color: #64748b;+ transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;z-index: 10;&:hover {- background: #e5e5e5;- color: #000;+ background: rgba(0, 0, 0, 0.08);+ color: #0f172a;+ transform: scale(1.02);+ }++ &:active {+ transform: scale(0.98);}}@@ -1656,55 +1689,56 @@ onUnmounted(() => {}&::-webkit-scrollbar-track {- background: #f5f5f5;+ background: #f1f5f9;border-radius: 3px;}&::-webkit-scrollbar-thumb {- background: #d0d0d0;+ background: #cbd5e1;border-radius: 3px;transition: background 0.2s;&:hover {- background: #07C05F;+ background: #07c05f;}}}.join-modal-tabs {display: flex;- gap: 24px;- margin-bottom: 20px;- border-bottom: 1px solid #e5e5e5;+ gap: 32px;+ margin-bottom: 24px;+ padding-bottom: 4px;+ border-bottom: 1px solid rgba(0, 0, 0, 0.08);.join-tab {- padding: 8px 0;+ padding: 10px 0;cursor: pointer;- color: #00000099;+ color: #64748b;font-size: 14px;- font-weight: 400;+ font-weight: 500;user-select: none;position: relative;transition: color 0.2s ease;- font-family: "PingFang SC";+ font-family: "PingFang SC", -apple-system, sans-serif;&:hover {- color: #000000e6;+ color: #0f172a;}&.active {color: #07c05f;- font-weight: 500;+ font-weight: 600;&::after {content: '';position: absolute;- bottom: -1px;+ bottom: -5px;left: 0;right: 0;- height: 2px;- background: #07c05f;- border-radius: 1px;+ height: 3px;+ background: linear-gradient(90deg, #07c05f, #05a650);+ border-radius: 2px 2px 0 0;}}}@@ -1725,74 +1759,82 @@ onUnmounted(() => {}.searchable-list-wrap {- max-height: 300px;+ max-height: 320px;overflow-y: auto;margin-bottom: 20px;- border: 1px solid #e5e5e5;- border-radius: 8px;- background: #fafafa;+ border: 1px solid rgba(0, 0, 0, 0.06);+ border-radius: 12px;+ background: #f8fafc;+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);&::-webkit-scrollbar {width: 6px;}&::-webkit-scrollbar-track {- background: #f5f5f5;+ background: #f1f5f9;border-radius: 3px;}&::-webkit-scrollbar-thumb {- background: #d0d0d0;+ background: #cbd5e1;border-radius: 3px;transition: background 0.2s;&:hover {- background: #07C05F;+ background: #07c05f;}}}.searchable-empty {- padding: 40px 16px;+ padding: 48px 20px;text-align: center;- color: #00000066;+ color: #64748b;font-size: 14px;- font-family: "PingFang SC";+ font-family: "PingFang SC", -apple-system, sans-serif;+ line-height: 1.5;}.searchable-list {display: flex;flex-direction: column;gap: 0;+ padding: 4px;.searchable-item {display: flex;align-items: center;justify-content: space-between;- gap: 12px;- padding: 12px 16px;- border-bottom: 1px solid #e5e5e5;+ gap: 14px;+ padding: 14px 16px;+ margin-bottom: 4px;+ border-radius: 10px;background: #fff;- transition: background 0.2s;+ border: 1px solid transparent;+ transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;cursor: pointer;&:last-child {- border-bottom: none;+ margin-bottom: 0;}&:hover:not(.is-already-member) {- background: #f5f5f5;+ background: #fff;+ border-color: rgba(7, 192, 95, 0.2);+ box-shadow: 0 2px 8px rgba(7, 192, 95, 0.06);}&.is-already-member {cursor: default;- opacity: 0.6;+ opacity: 0.75;+ background: #f8fafc;}.searchable-item-left {display: flex;align-items: center;- gap: 12px;+ gap: 14px;flex: 1;min-width: 0;}@@ -1808,33 +1850,36 @@ onUnmounted(() => {.searchable-item-name {display: block;font-size: 14px;- font-weight: 500;- color: #000000e6;+ font-weight: 600;+ color: #0f172a;margin-bottom: 4px;- font-family: "PingFang SC";+ font-family: "PingFang SC", -apple-system, sans-serif;}.searchable-item-desc {display: block;font-size: 13px;- color: #00000066;+ color: #64748b;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;margin-bottom: 8px;- font-family: "PingFang SC";+ font-family: "PingFang SC", -apple-system, sans-serif;}.searchable-item-badges {display: flex;align-items: center;- gap: 12px;+ gap: 10px;flex-wrap: wrap;.badge {font-size: 12px;- color: #00000066;- font-family: "PingFang SC";+ color: #64748b;+ font-family: "PingFang SC", -apple-system, sans-serif;+ padding: 2px 8px;+ background: rgba(0, 0, 0, 0.04);+ border-radius: 6px;}.approval-tag {@@ -1852,32 +1897,32 @@ onUnmounted(() => {.invite-preview-input {.invite-preview-input-desc {font-size: 14px;- color: #333333;+ color: #475569;margin: 0 0 16px;- line-height: 1.5;- font-family: "PingFang SC";+ line-height: 1.55;+ font-family: "PingFang SC", -apple-system, sans-serif;}.invite-preview-input-wrap {- margin-bottom: 10px;+ margin-bottom: 12px;}.invite-preview-input-tip {font-size: 12px;- color: #00000066;+ color: #64748b;margin: 0 0 20px;- line-height: 1.4;- font-family: "PingFang SC";+ line-height: 1.5;+ font-family: "PingFang SC", -apple-system, sans-serif;}.invite-preview-error-inline {display: flex;align-items: center;gap: 8px;- color: #FA5151;+ color: #dc2626;font-size: 13px;margin-bottom: 16px;- font-family: "PingFang SC";+ font-family: "PingFang SC", -apple-system, sans-serif;}.invite-preview-footer-single {- margin: 20px 0 0;+ margin: 24px 0 0;padding: 0;border-top: none;background: transparent;@@ -1889,13 +1934,13 @@ onUnmounted(() => {flex-direction: column;align-items: center;justify-content: center;- padding: 56px 28px;- gap: 16px;+ padding: 64px 28px;+ gap: 20px;.invite-preview-loading-text {font-size: 14px;- color: #86909c;- font-family: "PingFang SC";+ color: #64748b;+ font-family: "PingFang SC", -apple-system, sans-serif;}}@@ -1928,16 +1973,26 @@ onUnmounted(() => {}}-// 预览内容区域 - 紧凑布局+// 预览内容区域 - 空间信息卡片+.invite-preview-body-preview {+ padding-top: 20px;+}+.invite-preview-org {display: flex;align-items: flex-start;- gap: 16px;- margin-bottom: 20px;+ gap: 18px;+ margin-bottom: 24px;+ padding: 20px;+ background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);+ border: 1px solid rgba(0, 0, 0, 0.05);+ border-radius: 14px;+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);}.invite-preview-org-icon {flex-shrink: 0;+ filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.06));}.invite-preview-org-info {@@ -1946,69 +2001,82 @@ onUnmounted(() => {}.invite-preview-org-name {- font-size: 16px;+ font-size: 17px;font-weight: 600;- color: #000000e6;- margin: 0 0 6px;- font-family: "PingFang SC";+ color: #0f172a;+ margin: 0 0 8px;+ font-family: "PingFang SC", -apple-system, sans-serif;line-height: 1.3;+ letter-spacing: -0.02em;}.invite-preview-org-desc {font-size: 14px;- color: #00000066;+ color: #64748b;margin: 0;- line-height: 1.5;- font-family: "PingFang SC";+ line-height: 1.55;+ font-family: "PingFang SC", -apple-system, sans-serif;}.invite-preview-stats {display: flex;- gap: 24px;- margin-bottom: 20px;- padding-bottom: 20px;- border-bottom: 1px solid #e5e5e5;+ gap: 16px;+ margin-bottom: 24px;+ padding: 18px 0 22px;+ border-bottom: 1px solid rgba(0, 0, 0, 0.06);}.invite-preview-stat {display: flex;align-items: center;- gap: 8px;+ gap: 10px;+ padding: 10px 16px;+ background: rgba(7, 192, 95, 0.06);+ border: 1px solid rgba(7, 192, 95, 0.12);+ border-radius: 10px;font-size: 14px;- color: #333333;- font-family: "PingFang SC";+ color: #0f172a;+ font-family: "PingFang SC", -apple-system, sans-serif;+ transition: background 0.2s ease, border-color 0.2s ease;++ &:hover {+ background: rgba(7, 192, 95, 0.08);+ border-color: rgba(7, 192, 95, 0.18);+ }.invite-preview-stat-icon {color: #07c05f;- font-size: 16px;+ font-size: 18px;+ flex-shrink: 0;}.invite-preview-stat-value {font-weight: 600;- color: #000000e6;+ color: #0f172a;+ font-size: 15px;}.invite-preview-stat-label {- color: #00000066;- font-weight: 400;+ color: #64748b;+ font-weight: 500;}}.invite-preview-join-section,.invite-preview-status-section {- margin-top: 20px;+ margin-top: 24px;}.invite-preview-approval-row {display: flex;align-items: center;- gap: 10px;- margin-bottom: 16px;+ gap: 12px;+ margin-bottom: 18px;font-size: 14px;- font-family: "PingFang SC";+ font-family: "PingFang SC", -apple-system, sans-serif;.invite-preview-approval-label {- color: #333333;+ color: #475569;flex-shrink: 0;font-weight: 500;}@@ -2016,19 +2084,21 @@ onUnmounted(() => {.invite-preview-approval-badge {display: inline-flex;align-items: center;- padding: 4px 10px;- border-radius: 6px;+ padding: 6px 12px;+ border-radius: 8px;font-size: 12px;- font-weight: 500;+ font-weight: 600;&.need-approval {background: rgba(250, 173, 20, 0.12);- color: #d48806;+ color: #b45309;+ border: 1px solid rgba(250, 173, 20, 0.2);}&.no-approval {- background: rgba(7, 192, 95, 0.12);- color: #07c05f;+ background: rgba(7, 192, 95, 0.1);+ color: #059669;+ border: 1px solid rgba(7, 192, 95, 0.2);}}}@@ -2036,13 +2106,14 @@ onUnmounted(() => {.invite-preview-tip {display: flex;align-items: flex-start;- gap: 8px;- padding: 10px 12px;- border-radius: 6px;+ gap: 10px;+ padding: 12px 14px;+ border-radius: 10px;font-size: 13px;- line-height: 1.5;- font-family: "PingFang SC";- margin-bottom: 16px;+ line-height: 1.55;+ font-family: "PingFang SC", -apple-system, sans-serif;+ margin-bottom: 18px;+ border: 1px solid transparent;.t-icon {flex-shrink: 0;@@ -2052,17 +2123,20 @@ onUnmounted(() => {.invite-preview-tip-success {background: rgba(7, 192, 95, 0.08);- color: #07c05f;+ color: #059669;+ border-color: rgba(7, 192, 95, 0.15);}.invite-preview-tip-warning {background: rgba(250, 173, 20, 0.08);- color: #d48806;+ color: #b45309;+ border-color: rgba(250, 173, 20, 0.15);}.invite-preview-tip-info {background: rgba(0, 112, 240, 0.06);- color: #0052d9;+ color: #0369a1;+ border-color: rgba(0, 112, 240, 0.12);}.invite-preview-form-group {@@ -2076,11 +2150,11 @@ onUnmounted(() => {.invite-preview-form-label {display: block;margin-bottom: 8px;- font-family: "PingFang SC";+ font-family: "PingFang SC", -apple-system, sans-serif;font-size: 14px;font-weight: 500;- color: #333333;- letter-spacing: -0.2px;+ color: #475569;+ letter-spacing: -0.02em;}.invite-preview-role-select {@@ -2093,8 +2167,9 @@ onUnmounted(() => {}.invite-preview-footer {- padding: 16px 24px;- border-top: 1px solid #e5e5e5;+ padding: 20px 24px;+ border-top: 1px solid rgba(0, 0, 0, 0.06);+ background: linear-gradient(0deg, #fafbfc 0%, #ffffff 100%);display: flex;justify-content: flex-end;gap: 12px;@@ -2103,14 +2178,24 @@ onUnmounted(() => {.modal-enter-active,.modal-leave-active {- transition: all 0.3s ease;+ transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);++ .invite-preview-modal {+ transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);+ }}.modal-enter-from,.modal-leave-to {opacity: 0;.invite-preview-modal {- transform: scale(0.95);+ transform: scale(0.92) translateY(-8px);+ }+}+.modal-enter-to,+.modal-leave-from {+ .invite-preview-modal {+ transform: scale(1) translateY(0);}}</style>diff --git a/frontend/src/views/organization/OrganizationSettingsModal.vue b/frontend/src/views/organization/OrganizationSettingsModal.vueindex cda26d54f..89d9179ac 100644--- a/frontend/src/views/organization/OrganizationSettingsModal.vue+++ b/frontend/src/views/organization/OrganizationSettingsModal.vue@@ -179,6 +179,28 @@<span class="approval-desc">{{ $t('organization.settings.searchableDesc') }}</span></div></div>++ <div class="invite-divider"></div>++ <!-- 成员人数上限 -->+ <div class="invite-method">+ <div class="invite-method-header">+ <t-icon name="user-add" class="invite-icon" />+ <span class="invite-method-title">{{ $t('organization.settings.memberLimit') }}</span>+ </div>+ <p class="invite-validity-desc">{{ $t('organization.settings.memberLimitDesc') }}</p>+ <div class="member-limit-input-row">+ <t-input-number+ v-model="formData.member_limit"+ :min="0"+ :max="10000"+ :placeholder="$t('organization.settings.memberLimitPlaceholder')"+ theme="normal"+ style="width: 140px;"+ />+ <span class="member-limit-hint">{{ $t('organization.settings.memberLimitHint', { count: orgInfo?.member_count ?? 0 }) }}</span>+ </div>+ </div></div></div></div>@@ -673,7 +695,8 @@ const formData = ref({description: '',require_approval: false,searchable: false,- invite_code_validity_days: 7 as number+ invite_code_validity_days: 7 as number,+ member_limit: 50 as number // 0 = unlimited})// Computed@@ -794,12 +817,14 @@ const fetchOrgDetail = async () => {if (res.success && res.data) {orgInfo.value = res.dataconst validity = res.data.invite_code_validity_days+ const memberLimit = res.data.member_limitformData.value = {name: res.data.name,description: res.data.description || '',require_approval: res.data.require_approval || false,searchable: res.data.searchable || false,- invite_code_validity_days: typeof validity === 'number' ? validity : 7+ invite_code_validity_days: typeof validity === 'number' ? validity : 7,+ member_limit: typeof memberLimit === 'number' && memberLimit >= 0 ? memberLimit : 50}inviteCode.value = res.data.invite_code || ''inviteCodeExpiresAt.value = res.data.invite_code_expires_at ?? null@@ -949,7 +974,8 @@ const handleSave = async () => {description: formData.value.description.trim(),require_approval: formData.value.require_approval,searchable: formData.value.searchable,- invite_code_validity_days: formData.value.invite_code_validity_days+ invite_code_validity_days: formData.value.invite_code_validity_days,+ member_limit: formData.value.member_limit})if (res.success) {MessagePlugin.success(t('common.saveSuccess'))@@ -1233,7 +1259,7 @@ watch(() => props.visible, (newVal) => {joinRequests.value = []if (props.mode === 'create') {// 创建模式:重置表单- formData.value = { name: '', description: '', require_approval: false, searchable: false, invite_code_validity_days: 7 }+ formData.value = { name: '', description: '', require_approval: false, searchable: false, invite_code_validity_days: 7, member_limit: 50 }orgInfo.value = nullmembers.value = []sharedKnowledgeBases.value = []@@ -1281,8 +1307,12 @@ watch(currentSection, (section) => {height: 85vh;max-height: 750px;background: #fff;- border-radius: 12px;- box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);+ border-radius: 16px;+ box-shadow:+ 0 0 0 1px rgba(0, 0, 0, 0.04),+ 0 4px 6px -1px rgba(15, 23, 42, 0.06),+ 0 12px 24px -4px rgba(15, 23, 42, 0.1),+ 0 24px 48px -8px rgba(15, 23, 42, 0.12);display: flex;flex-direction: column;overflow: hidden;@@ -1292,22 +1322,27 @@ watch(currentSection, (section) => {position: absolute;top: 20px;right: 20px;- width: 32px;- height: 32px;+ width: 36px;+ height: 36px;border: none;- background: #f5f5f5;- border-radius: 6px;+ background: rgba(0, 0, 0, 0.04);+ border-radius: 10px;cursor: pointer;display: flex;align-items: center;justify-content: center;- color: #666;- transition: all 0.2s ease;+ color: #64748b;+ transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;z-index: 10;&:hover {- background: #e5e5e5;- color: #000;+ background: rgba(0, 0, 0, 0.08);+ color: #0f172a;+ transform: scale(1.02);+ }++ &:active {+ transform: scale(0.98);}}@@ -1319,22 +1354,23 @@ watch(currentSection, (section) => {.settings-sidebar {width: 200px;- background: #fafafa;- border-right: 1px solid #e5e5e5;+ background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);+ border-right: 1px solid rgba(0, 0, 0, 0.06);display: flex;flex-direction: column;flex-shrink: 0;.sidebar-header {- padding: 24px 20px;- border-bottom: 1px solid #e5e5e5;+ padding: 26px 20px;+ border-bottom: 1px solid rgba(0, 0, 0, 0.06);.sidebar-title {margin: 0;- font-family: "PingFang SC";+ font-family: "PingFang SC", -apple-system, sans-serif;font-size: 18px;font-weight: 600;- color: #000000e6;+ color: #0f172a;+ letter-spacing: -0.02em;}}@@ -1346,23 +1382,24 @@ watch(currentSection, (section) => {.nav-item {display: flex;align-items: center;- padding: 10px 12px;+ padding: 12px 14px;margin-bottom: 4px;- border-radius: 6px;+ border-radius: 10px;cursor: pointer;- transition: all 0.2s ease;- font-family: "PingFang SC";+ transition: background 0.2s ease, color 0.2s ease;+ font-family: "PingFang SC", -apple-system, sans-serif;font-size: 14px;- color: #00000099;+ color: #64748b;+ font-weight: 500;.nav-icon {- margin-right: 8px;+ margin-right: 10px;font-size: 18px;flex-shrink: 0;display: flex;align-items: center;justify-content: center;- color: #86909c;+ color: #94a3b8;transition: color 0.2s;}@@ -1372,31 +1409,31 @@ watch(currentSection, (section) => {}.nav-item-badge {- min-width: 18px;- height: 18px;- padding: 0 5px;- border-radius: 9px;- background: rgba(250, 173, 20, 0.2);- color: #d48806;+ min-width: 20px;+ height: 20px;+ padding: 0 6px;+ border-radius: 10px;+ background: rgba(250, 173, 20, 0.18);+ color: #b45309;font-size: 12px;font-weight: 600;- line-height: 18px;+ line-height: 20px;text-align: center;flex-shrink: 0;}&:hover {- background: #f0f0f0;+ background: rgba(0, 0, 0, 0.04);.nav-icon {- color: #00000099;+ color: #64748b;}}&.active {background: rgba(7, 192, 95, 0.1);color: @primary-color;- font-weight: 500;+ font-weight: 600;.nav-icon {color: @primary-color;@@ -1600,6 +1637,18 @@ watch(currentSection, (section) => {min-width: 140px;}+ .member-limit-input-row {+ display: flex;+ align-items: center;+ gap: 12px;+ margin-top: 8px;++ .member-limit-hint {+ font-size: 12px;+ color: #86909c;+ }+ }+.invite-divider {height: 1px;background: #e5e5e5;@@ -2151,19 +2200,23 @@ watch(currentSection, (section) => {}.settings-footer {- padding: 16px 32px;- border-top: 1px solid #e5e5e5;+ padding: 20px 32px;+ border-top: 1px solid rgba(0, 0, 0, 0.06);display: flex;justify-content: flex-end;gap: 12px;flex-shrink: 0;- background: #fff;+ background: linear-gradient(0deg, #fafbfc 0%, #ffffff 100%);}// Transitions.modal-enter-active,.modal-leave-active {- transition: all 0.3s ease;+ transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);++ .settings-modal {+ transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);+ }}.modal-enter-from,@@ -2171,7 +2224,14 @@ watch(currentSection, (section) => {opacity: 0;.settings-modal {- transform: scale(0.95);+ transform: scale(0.92) translateY(-8px);+ }+}++.modal-enter-to,+.modal-leave-from {+ .settings-modal {+ transform: scale(1) translateY(0);}}diff --git a/internal/application/repository/organization.go b/internal/application/repository/organization.goindex 1d0955eb7..0fd3a05b8 100644--- a/internal/application/repository/organization.go+++ b/internal/application/repository/organization.go@@ -98,7 +98,7 @@ func (r *organizationRepository) ListSearchable(ctx context.Context, query strin// Update updates an organization (Select ensures zero values like invite_code_validity_days=0 are persisted)func (r *organizationRepository) Update(ctx context.Context, org *types.Organization) error {return r.db.WithContext(ctx).Model(&types.Organization{}).Where("id = ?", org.ID).- Select("name", "description", "require_approval", "searchable", "invite_code_validity_days", "updated_at").+ Select("name", "description", "require_approval", "searchable", "invite_code_validity_days", "member_limit", "updated_at").Updates(org).Error}diff --git a/internal/application/service/organization.go b/internal/application/service/organization.goindex a73b7549d..a87e5fdf0 100644--- a/internal/application/service/organization.go+++ b/internal/application/service/organization.go@@ -18,6 +18,9 @@ import (// Default invite code validity in days; allowed values: 0 (never), 1, 7, 30const DefaultInviteCodeValidityDays = 7+// DefaultMemberLimit is the default max members per organization (0 = unlimited)+const DefaultMemberLimit = 50+// ValidInviteCodeValidityDays are the allowed values for invite_code_validity_daysvar ValidInviteCodeValidityDays = map[int]bool{0: true, 1: true, 7: true, 30: true}@@ -30,6 +33,8 @@ var (ErrInvalidRole = errors.New("invalid role")ErrInviteCodeExpired = errors.New("invite code has expired")ErrInvalidValidityDays = errors.New("invite_code_validity_days must be 0, 1, 7, or 30")+ ErrOrgMemberLimitReached = errors.New("organization member limit reached")+ ErrOrgMemberLimitTooLow = errors.New("member limit cannot be lower than current member count"))// organizationService implements OrganizationService interface@@ -68,6 +73,13 @@ func (s *organizationService) CreateOrganization(ctx context.Context, userID str}validityDays = *req.InviteCodeValidityDays}+ memberLimit := DefaultMemberLimit+ if req.MemberLimit != nil {+ if *req.MemberLimit < 0 {+ return nil, errors.New("member_limit must be >= 0")+ }+ memberLimit = *req.MemberLimit+ }now := time.Now()org := &types.Organization{@@ -79,6 +91,7 @@ func (s *organizationService) CreateOrganization(ctx context.Context, userID strInviteCode: generateInviteCode(),InviteCodeExpiresAt: resolveInviteExpiry(validityDays, now),InviteCodeValidityDays: validityDays,+ MemberLimit: memberLimit,CreatedAt: now,UpdatedAt: now,}@@ -179,6 +192,21 @@ func (s *organizationService) UpdateOrganization(ctx context.Context, id string,}org.InviteCodeValidityDays = *req.InviteCodeValidityDays}+ if req.MemberLimit != nil {+ if *req.MemberLimit < 0 {+ return nil, errors.New("member_limit must be >= 0")+ }+ if *req.MemberLimit > 0 {+ count, err := s.orgRepo.CountMembers(ctx, id)+ if err != nil {+ return nil, err+ }+ if int64(*req.MemberLimit) < count {+ return nil, ErrOrgMemberLimitTooLow+ }+ }+ org.MemberLimit = *req.MemberLimit+ }org.UpdatedAt = time.Now()if err := s.orgRepo.Update(ctx, org); err != nil {@@ -293,6 +321,20 @@ func (s *organizationService) AddMember(ctx context.Context, orgID string, userIreturn ErrInvalidRole}+ org, err := s.orgRepo.GetByID(ctx, orgID)+ if err != nil {+ return err+ }+ if org.MemberLimit > 0 {+ count, errCount := s.orgRepo.CountMembers(ctx, orgID)+ if errCount != nil {+ return errCount+ }+ if count >= int64(org.MemberLimit) {+ return ErrOrgMemberLimitReached+ }+ }+member := &types.OrganizationMember{ID: uuid.New().String(),OrganizationID: orgID,@@ -435,6 +477,17 @@ func (s *organizationService) JoinByInviteCode(ctx context.Context, inviteCode sreturn nil, err}+ // Check member limit (0 = unlimited)+ if org.MemberLimit > 0 {+ count, errCount := s.orgRepo.CountMembers(ctx, org.ID)+ if errCount != nil {+ return nil, errCount+ }+ if count >= int64(org.MemberLimit) {+ return nil, ErrOrgMemberLimitReached+ }+ }+// Add user as viewer by defaultmember := &types.OrganizationMember{ID: uuid.New().String(),@@ -506,6 +559,24 @@ func (s *organizationService) SubmitJoinRequest(ctx context.Context, orgID strinreturn nil, ErrPendingRequestExists}+ // Reject if organization is already at member limit+ org, err := s.orgRepo.GetByID(ctx, orgID)+ if err != nil {+ if errors.Is(err, repository.ErrOrganizationNotFound) {+ return nil, ErrOrgNotFound+ }+ return nil, err+ }+ if org.MemberLimit > 0 {+ count, errCount := s.orgRepo.CountMembers(ctx, orgID)+ if errCount != nil {+ return nil, errCount+ }+ if count >= int64(org.MemberLimit) {+ return nil, ErrOrgMemberLimitReached+ }+ }+// Default to viewer if role is empty or invalidif requestedRole == "" || !requestedRole.IsValid() {requestedRole = types.OrgRoleViewer@@ -577,7 +648,20 @@ func (s *organizationService) ReviewJoinRequest(ctx context.Context, orgID strin}logger.Infof(ctx, "Upgrade request %s approved, user %s role updated to %s in organization %s", requestID, request.UserID, role, request.OrganizationID)} else {- // Join: add new member+ // Join: check member limit then add new member+ org, errOrg := s.orgRepo.GetByID(ctx, request.OrganizationID)+ if errOrg != nil {+ return errOrg+ }+ if org.MemberLimit > 0 {+ count, errCount := s.orgRepo.CountMembers(ctx, request.OrganizationID)+ if errCount != nil {+ return errCount+ }+ if count >= int64(org.MemberLimit) {+ return ErrOrgMemberLimitReached+ }+ }member := &types.OrganizationMember{ID: uuid.New().String(),OrganizationID: request.OrganizationID,diff --git a/internal/handler/organization.go b/internal/handler/organization.goindex 4d87d0c86..93e7fc18b 100644--- a/internal/handler/organization.go+++ b/internal/handler/organization.go@@ -178,6 +178,10 @@ func (h *OrganizationHandler) UpdateOrganization(c *gin.Context) {c.Error(apperrors.NewValidationError(err.Error()))return}+ if errors.Is(err, service.ErrOrgMemberLimitTooLow) {+ c.Error(apperrors.NewValidationError("当前成员数已超过新的上限,请先移除成员或设置更大的上限"))+ return+ }c.Error(apperrors.NewForbiddenError("Permission denied or organization not found"))return}@@ -435,6 +439,10 @@ func (h *OrganizationHandler) JoinByInviteCode(c *gin.Context) {org, err := h.orgService.JoinByInviteCode(ctx, req.InviteCode, userID.(string), tenantID.(uint64))if err != nil {logger.Errorf(ctx, "Failed to join organization: %v", err)+ if errors.Is(err, service.ErrOrgMemberLimitReached) {+ c.Error(apperrors.NewValidationError("该空间成员已满,无法加入"))+ return+ }c.Error(apperrors.NewNotFoundError("Invalid invite code"))return}@@ -500,6 +508,10 @@ func (h *OrganizationHandler) SubmitJoinRequest(c *gin.Context) {request, err := h.orgService.SubmitJoinRequest(ctx, org.ID, userID.(string), tenantID.(uint64), req.Message, requestedRole)if err != nil {logger.Errorf(ctx, "Failed to submit join request: %v", err)+ if errors.Is(err, service.ErrOrgMemberLimitReached) {+ c.Error(apperrors.NewValidationError("该空间成员已满,无法提交加入申请"))+ return+ }if err.Error() == "pending request already exists" {c.Error(apperrors.NewValidationError("You have already submitted a request to join this organization"))return@@ -585,6 +597,10 @@ func (h *OrganizationHandler) JoinByOrganizationID(c *gin.Context) {c.Error(apperrors.NewForbiddenError("Organization not open for search"))return}+ if errors.Is(err, service.ErrOrgMemberLimitReached) {+ c.Error(apperrors.NewValidationError("该空间成员已满,无法加入"))+ return+ }if errors.Is(err, service.ErrInvalidRole) {c.Error(apperrors.NewValidationError("Invalid role"))return@@ -810,6 +826,10 @@ func (h *OrganizationHandler) ReviewJoinRequest(c *gin.Context) {if err := h.orgService.ReviewJoinRequest(ctx, orgID, requestID, req.Approved, userID.(string), req.Message, assignRole); err != nil {logger.Errorf(ctx, "Failed to review join request: %v", err)+ if errors.Is(err, service.ErrOrgMemberLimitReached) {+ c.Error(apperrors.NewValidationError("空间成员已满,无法通过该加入申请"))+ return+ }if err.Error() == "request has already been reviewed" {c.Error(apperrors.NewValidationError("Request has already been reviewed"))return@@ -1093,6 +1113,7 @@ func (h *OrganizationHandler) toOrgResponse(ctx context.Context, org *types.OrgaIsOwner: org.OwnerID == currentUserID,RequireApproval: org.RequireApproval,Searchable: org.Searchable,+ MemberLimit: org.MemberLimit,InviteCodeValidityDays: org.InviteCodeValidityDays,CreatedAt: org.CreatedAt,UpdatedAt: org.UpdatedAt,@@ -1265,6 +1286,10 @@ func (h *OrganizationHandler) InviteMember(c *gin.Context) {// Add memberif err := h.orgService.AddMember(ctx, orgID, req.UserID, invitedUser.TenantID, req.Role); err != nil {logger.Errorf(ctx, "Failed to add member: %v", err)+ if errors.Is(err, service.ErrOrgMemberLimitReached) {+ c.Error(apperrors.NewValidationError("该空间成员已满,无法添加新成员"))+ return+ }c.Error(apperrors.NewInternalServerError("Failed to add member"))return}diff --git a/internal/types/organization.go b/internal/types/organization.goindex 96f5e287c..1f879122d 100644--- a/internal/types/organization.go+++ b/internal/types/organization.go@@ -60,6 +60,8 @@ type Organization struct {RequireApproval bool `json:"require_approval" gorm:"default:false"`// Whether the space is open for search (discoverable; non-members can search and join by org ID)Searchable bool `json:"searchable" gorm:"default:false"`+ // Max members allowed; 0 means no limit+ MemberLimit int `json:"member_limit" gorm:"default:50"`// Creation timeCreatedAt time.Time `json:"created_at"`// Last updated time@@ -218,6 +220,7 @@ type CreateOrganizationRequest struct {Description string `json:"description" binding:"max=1000"`Avatar string `json:"avatar" binding:"omitempty,max=512"` // optional avatar URLInviteCodeValidityDays *int `json:"invite_code_validity_days"` // optional: 0=never, 1, 7, 30; default 7+ MemberLimit *int `json:"member_limit"` // optional: max members; 0=unlimited; default 50}// UpdateOrganizationRequest represents a request to update an organization@@ -226,8 +229,9 @@ type UpdateOrganizationRequest struct {Description *string `json:"description" binding:"omitempty,max=1000"`Avatar *string `json:"avatar" binding:"omitempty,max=512"` // optional avatar URLRequireApproval *bool `json:"require_approval"`- Searchable *bool `json:"searchable"` // open for search so others can discover and join+ Searchable *bool `json:"searchable"` // open for search so others can discover and joinInviteCodeValidityDays *int `json:"invite_code_validity_days"` // 0=never, 1, 7, 30+ MemberLimit *int `json:"member_limit"` // max members; 0=unlimited}// AddMemberRequest represents a request to add a member to an organization@@ -295,6 +299,7 @@ type OrganizationResponse struct {InviteCodeValidityDays int `json:"invite_code_validity_days"`RequireApproval bool `json:"require_approval"`Searchable bool `json:"searchable"`+ MemberLimit int `json:"member_limit"` // 0 = unlimitedMemberCount int `json:"member_count"`ShareCount int `json:"share_count"` // 共享到该组织的知识库数量PendingJoinRequestCount int `json:"pending_join_request_count"` // 待审批加入申请数(仅管理员可见)diff --git a/migrations/versioned/000013_organization_member_limit.down.sql b/migrations/versioned/000013_organization_member_limit.down.sqlnew file mode 100644index 000000000..9039bb6a4--- /dev/null+++ b/migrations/versioned/000013_organization_member_limit.down.sql@@ -0,0 +1,3 @@+-- Migration: 000013_organization_member_limit (down)+ALTER TABLE organizations+ DROP COLUMN IF EXISTS member_limit;diff --git a/migrations/versioned/000013_organization_member_limit.up.sql b/migrations/versioned/000013_organization_member_limit.up.sqlnew file mode 100644index 000000000..24e4e3ed2--- /dev/null+++ b/migrations/versioned/000013_organization_member_limit.up.sql@@ -0,0 +1,6 @@+-- Migration: 000013_organization_member_limit+-- Description: Add member_limit to organizations (0 = unlimited)+ALTER TABLE organizations+ ADD COLUMN IF NOT EXISTS member_limit INTEGER NOT NULL DEFAULT 50;++COMMENT ON COLUMN organizations.member_limit IS 'Max members allowed; 0 means no limit';