From 7139cca4e1887f0c3ce0c027b6ffacbe7ac46bbc Mon Sep 17 00:00:00 2001 From: benero Date: Thu, 20 Jun 2024 17:41:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/default.py | 3 ++- itsm/sites/views.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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"