Skip to content

Commit

Permalink
Merge pull request #1353 from benero/feat_version
Browse files Browse the repository at this point in the history
feat: 新增版本信息返回
  • Loading branch information
benero authored Jun 21, 2024
2 parents 66103bf + 7139cca commit eb8da84
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
18 changes: 18 additions & 0 deletions itsm/sites/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import os
import datetime
import re

from blueapps.account.decorators import login_exempt
from django.conf import settings
Expand Down Expand Up @@ -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()
},
)

Expand All @@ -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"

0 comments on commit eb8da84

Please sign in to comment.