diff --git a/config/default.py b/config/default.py index a488f2777..1af5de957 100644 --- a/config/default.py +++ b/config/default.py @@ -955,5 +955,6 @@ def redirect_func(request): IAM_SDK_CLIENT_TIMEOUT = int(os.getenv("BKAPP_IAM_SDK_CLIENT_TIMEOUT", 20)) -# 公共 header / footer +# 公共配置 BK_SHARED_RES_URL = os.getenv("BKPAAS_SHARED_RES_URL") or os.getenv("BKAPP_SHARED_RES_URL") +BK_PLATFORM_NAME = os.getenv("BKAPP_PLATFORM_NAME", "Tencent BlueKing") diff --git a/itsm/sites/views.py b/itsm/sites/views.py index d68cf8099..898a7bb6c 100644 --- a/itsm/sites/views.py +++ b/itsm/sites/views.py @@ -25,6 +25,7 @@ import os import datetime +import re from blueapps.account.decorators import login_exempt from django.conf import settings @@ -136,6 +137,8 @@ def index(request): "SOPS_URL": settings.SOPS_SITE_URL, "NOTICE_CENTER_SWITCH": notice_center_switch_value, "BK_SHARED_RES_URL": settings.BK_SHARED_RES_URL, + "BK_PLATFORM_NAME": settings.BK_PLATFORM_NAME, + "VERSION": get_version() }, ) @@ -159,4 +162,19 @@ def get_footer(request): ) +def get_version(): + """ + @summary: 获取版本信息 + """ + # 读取文件内容 + app_desc = os.path.join(settings.PROJECT_ROOT, "app_desc.yaml") + with open(app_desc, 'r') as file: + content = file.read() + + # 使用正则表达式提取版本号 + pattern = r'app_version:\s*"([\d.]+)"' + match = re.search(pattern, content) + return match[1] if match else "2.6" + + template_name = "wiki/create.html"