From b2bb6dd11429e5a4bd9833a7bd2061dbf8a8a4f2 Mon Sep 17 00:00:00 2001 From: panxinying Date: Thu, 3 Dec 2026 18:08:08 +0800 Subject: [PATCH] fix: chat authentication version detection --- apps/chat/serializers/chat_authentication.py | 9 +++++++++ ui/src/api/types/chat-auth.ts | 2 ++ .../left-sidebar/account-menu/index.vue | 2 +- ui/src/stores/chat/auth.ts | 6 ++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/chat/serializers/chat_authentication.py b/apps/chat/serializers/chat_authentication.py index 48ba48d89a2..1e9446496aa 100644 --- a/apps/chat/serializers/chat_authentication.py +++ b/apps/chat/serializers/chat_authentication.py @@ -25,6 +25,12 @@ from portal.models import Portal +def _is_license_valid(): + """判断当前 license 是否有效;专业版、企业版据此展示授权相关能力。""" + license_validator = DatabaseModelManage.get_model("license_is_valid") or (lambda: False) + return bool(license_validator()) + + class AnonymousAuthenticationSerializer(serializers.Serializer): access_token = serializers.CharField(required=False, label=_("access_token")) @@ -93,6 +99,7 @@ def profile(self): else {"theme_color": "", "header_font_color": ""}, "logo": application_access_token.application.icon, "edition": edition, + "license_is_valid": _is_license_valid(), "meta": { "application_name": application_access_token.application.name, "application_id": str(application_access_token.application_id), @@ -126,6 +133,7 @@ def profile(): "meta": {"portal_name": ""}, "logo": "./favicon.ico", "edition": edition, + "license_is_valid": _is_license_valid(), "language": "zh-CN", }, **result, @@ -143,6 +151,7 @@ def profile(): "meta": {"portal_name": portal.name}, "logo": portal.logo or "./favicon.ico", "edition": edition, + "license_is_valid": _is_license_valid(), "language": "zh-CN", }, **result, diff --git a/ui/src/api/types/chat-auth.ts b/ui/src/api/types/chat-auth.ts index 03286b8f0f8..1e99e7a04fe 100644 --- a/ui/src/api/types/chat-auth.ts +++ b/ui/src/api/types/chat-auth.ts @@ -15,6 +15,8 @@ export interface AuthProfile> { logo: string custom_theme?: { theme_color?: string; header_font_color?: string } | null edition?: string + /** 当前 license 是否有效;专业版、企业版据此判断授权相关能力。 */ + license_is_valid?: boolean meta: Meta } diff --git a/ui/src/conversation-panel/left-sidebar/account-menu/index.vue b/ui/src/conversation-panel/left-sidebar/account-menu/index.vue index 16b6ebea346..9ed19c08770 100644 --- a/ui/src/conversation-panel/left-sidebar/account-menu/index.vue +++ b/ui/src/conversation-panel/left-sidebar/account-menu/index.vue @@ -100,7 +100,7 @@ const goLogin = () => {
{{ account?.username || '-' }}
-