From 2072d23439b9a6ef667b0a30fc6f7ec224155880 Mon Sep 17 00:00:00 2001 From: waylon <1158341873@qq.com> Date: Tue, 18 Jun 2024 16:44:29 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=20footer=20=E4=BF=A1=E6=81=AF=20#7495?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env.py | 2 ++ gcloud/core/api.py | 39 +++++++++++++++++-------- gcloud/core/context_processors.py | 1 + gcloud/core/footer/__init__.py | 2 ++ gcloud/core/footer/sites/open/footer.py | 6 ++++ gcloud/core/urls.py | 5 ++-- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/env.py b/env.py index fb49b8553e..95c3ba5bb1 100644 --- a/env.py +++ b/env.py @@ -113,6 +113,8 @@ # 获取 PaaS 注入的蓝鲸域名 BKPAAS_BK_DOMAIN = os.getenv("BKPAAS_BK_DOMAIN", "") or os.getenv("BK_DOMAIN", "") +# PaaS 注入的蓝鲸共享资源域名 +BKPAAS_SHARED_RES_URL = os.getenv("BKPAAS_SHARED_RES_URL", "") # 获取加密类型 BKPAAS_BK_CRYPTO_TYPE = ( diff --git a/gcloud/core/api.py b/gcloud/core/api.py index c7083ca814..814ef1d2d0 100644 --- a/gcloud/core/api.py +++ b/gcloud/core/api.py @@ -15,26 +15,23 @@ import re from datetime import datetime -from django.http import JsonResponse +from blueapps.account.decorators import login_exempt from django.contrib.auth.models import Group -from django.views.decorators.http import require_POST, require_GET +from django.http import JsonResponse from django.utils.translation import ugettext_lazy as _ +from django.views.decorators.http import require_GET, require_POST from drf_yasg.utils import swagger_auto_schema - from mako.template import Template from rest_framework.decorators import api_view -from blueapps.account.decorators import login_exempt -from gcloud.core import roles +import env from gcloud.conf import settings -from gcloud.core.footer import FOOTER -from gcloud.constants import TASK_CATEGORY, TASK_FLOW_TYPE, NOTIFY_TYPE -from gcloud.core.models import ( - UserDefaultProject, - ProjectCounter, -) -from gcloud.core.utils import convert_group_name +from gcloud.constants import NOTIFY_TYPE, TASK_CATEGORY, TASK_FLOW_TYPE +from gcloud.core import roles from gcloud.core.api_adapter import get_all_users +from gcloud.core.footer import FOOTER, FOOTER_INFO +from gcloud.core.models import ProjectCounter, UserDefaultProject +from gcloud.core.utils import convert_group_name from gcloud.openapi.schema import AnnotationAutoSchema logger = logging.getLogger("root") @@ -141,6 +138,24 @@ def get_footer(request): ) +@require_GET +def get_footer_info(request): + """ + @summary: 获取当前环境的页面 footer 信息 + """ + return JsonResponse( + { + "result": True, + "data": { + "env": env.RUN_VER, + "sops_version": settings.STATIC_VERSION, + "year": datetime.now().year, + **FOOTER_INFO, + }, + } + ) + + @require_GET def get_msg_types(request): client = get_client_by_user(request.user.username) diff --git a/gcloud/core/context_processors.py b/gcloud/core/context_processors.py index 14a5b89df3..ce169e0041 100644 --- a/gcloud/core/context_processors.py +++ b/gcloud/core/context_processors.py @@ -125,6 +125,7 @@ def mysetting(request): "BK_DOMAIN": env.BKPAAS_BK_DOMAIN, # 是否开启通知中心 "ENABLE_NOTICE_CENTER": enable_notice_center, + "BK_PAAS_SHARED_RES_URL": env.BKPAAS_SHARED_RES_URL, "TASK_LIST_STATUS_FILTER_DAYS": settings.TASK_LIST_STATUS_FILTER_DAYS, } diff --git a/gcloud/core/footer/__init__.py b/gcloud/core/footer/__init__.py index a7c8c99311..55b4491190 100644 --- a/gcloud/core/footer/__init__.py +++ b/gcloud/core/footer/__init__.py @@ -18,3 +18,5 @@ footer_module = importlib.import_module("gcloud.core.footer.sites.{}.footer".format(settings.RUN_VER)) FOOTER = footer_module.FOOTER # noqa + +FOOTER_INFO = footer_module.FOOTER_INFO # noqa diff --git a/gcloud/core/footer/sites/open/footer.py b/gcloud/core/footer/sites/open/footer.py index ded8429200..77bd7ec4f5 100644 --- a/gcloud/core/footer/sites/open/footer.py +++ b/gcloud/core/footer/sites/open/footer.py @@ -37,4 +37,10 @@ def i18n_footer(language): return EnvironmentVariables.objects.get_var(footer_key, default) +FOOTER_INFO = { + "tech_support_url": "https://wpa1.qq.com/KziXGWJs?_type=wpa&qidian=true", + "smart_url": "http://bk.tencent.com/s-mart/community/", + "bk_tencent_url": "http://bk.tencent.com/index", +} + FOOTER = i18n_footer diff --git a/gcloud/core/urls.py b/gcloud/core/urls.py index f5f2e85644..9e62d4f544 100644 --- a/gcloud/core/urls.py +++ b/gcloud/core/urls.py @@ -10,14 +10,14 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ +from blueapps.account.decorators import login_exempt from django.apps import apps from django.conf.urls import include, url from django.views.i18n import JavaScriptCatalog +from version_log import config as version_log_config -from blueapps.account.decorators import login_exempt from gcloud.core import api, views from gcloud.iam_auth.resource_api import dispatcher -from version_log import config as version_log_config javascript_catalog = JavaScriptCatalog.as_view( packages=[app_config.name for app_config in apps.get_app_configs() if app_config.name.startswith("gcloud")] @@ -31,6 +31,7 @@ url(r"^core/api/get_roles_and_personnel/(?P\d+)/$", api.get_roles_and_personnel), url(r"^core/api/get_basic_info/$", api.get_basic_info), url(r"^core/footer/$", api.get_footer), + url(r"^core/footer_info/$", api.get_footer_info), url(r"^core/api/get_user_list/$", api.get_user_list), url(r"^core/api/get_msg_types/$", api.get_msg_types), url(r"^core/healthz", api.healthz), From 0ebf3b1ef86b20bbe8306d3901a1597db51eb4c9 Mon Sep 17 00:00:00 2001 From: yiwenZhou <67539158+ywywZhou@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:19:42 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E9=A1=B9=E7=9B=AE=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=AF=E4=BF=AE=E6=94=B9=20&&=20=E9=80=80?= =?UTF-8?q?=E5=87=BA=E7=99=BB=E5=BD=95=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0?= =?UTF-8?q?=20(#7499)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 项目全局配置title/footer/logo/favicon/产品名称可修改 --bug=118043660 * fix: 退出登录添加参数 --bug=117514164 # Reviewed, transaction id: 10124 --- frontend/desktop/package.json | 1 + frontend/desktop/src/App.vue | 16 +++-- frontend/desktop/src/api/index.js | 13 ++-- frontend/desktop/src/assets/html/index.html | 2 + .../src/components/layout/CopyrightFooter.vue | 17 +++-- .../src/components/layout/Navigation.vue | 5 +- .../components/layout/NavigatorHeadRight.vue | 12 +++- frontend/desktop/src/config/i18n/cn.js | 7 +- frontend/desktop/src/config/i18n/en.js | 7 +- .../pages/task/TaskExecute/TaskOperation.vue | 22 +++--- frontend/desktop/src/store/index.js | 69 ++++++++++++++++++- 11 files changed, 131 insertions(+), 40 deletions(-) diff --git a/frontend/desktop/package.json b/frontend/desktop/package.json index d6e6fc822d..6d28499abe 100644 --- a/frontend/desktop/package.json +++ b/frontend/desktop/package.json @@ -15,6 +15,7 @@ "@blueking/crypto-js-sdk": "0.0.5", "@blueking/login-modal": "^1.0.1", "@blueking/notice-component-vue2": "^2.0.1", + "@blueking/platform-config": "^1.0.2", "@blueking/user-selector": "^1.0.5-beta.2", "@vue/babel-preset-jsx": "^1.3.0", "ajv": "^6.10.2", diff --git a/frontend/desktop/src/App.vue b/frontend/desktop/src/App.vue index 6291207b5b..ad576b2915 100644 --- a/frontend/desktop/src/App.vue +++ b/frontend/desktop/src/App.vue @@ -109,7 +109,7 @@ this.handleRouteChange(id) } }, - created () { + async created () { window.msg_list = [] bus.$on('showLoginModal', args => { const { has_plain, login_url, width, height, method } = args @@ -166,7 +166,8 @@ }) }) } - this.getPageFooter() + await this.getPageFooter() + this.getGlobalConfig() window.addEventListener('message', this.messageHandler, false) }, mounted () { @@ -176,7 +177,9 @@ ...mapActions([ 'getPermissionMeta', 'queryUserPermission', - 'getFooterContent' + 'getFooterContent', + 'getFooterInfo', + 'getGlobalConfig' ]), ...mapActions('appmaker/', [ 'loadAppmakerDetail' @@ -202,7 +205,7 @@ 'setProjectConfig' ]), ...mapMutations([ - 'setPageFooter', + 'setFooterInfo', 'setAdminPerm', 'setStatisticsPerm' ]), @@ -281,12 +284,11 @@ async getPageFooter () { try { this.footerLoading = true - const resp = await this.getFooterContent() + const resp = await this.getFooterInfo() if (resp.result) { - this.setPageFooter(resp.data) + this.setFooterInfo(resp.data) } } catch (e) { - this.setPageFooter(``) console.log(e) } finally { this.footerLoading = false diff --git a/frontend/desktop/src/api/index.js b/frontend/desktop/src/api/index.js index b62629ceee..07d31ea105 100644 --- a/frontend/desktop/src/api/index.js +++ b/frontend/desktop/src/api/index.js @@ -86,11 +86,14 @@ axios.interceptors.response.use( bus.$emit('createSnapshot', true) // 创建模板快照 } - const successUrl = `${window.location.origin}${window.SITE_URL}static/bk_sops/login_success.html` - let [loginUrl] = data.login_url.split('?') - loginUrl = `${loginUrl}?c_url=${encodeURIComponent(successUrl)}` - - showLoginModal({ loginUrl }) + // 退出登录接口不打开登录弹框 + if (response.config.url !== '/logout') { + const successUrl = `${window.location.origin}${window.SITE_URL}static/bk_sops/login_success.html` + let [loginUrl] = data.login_url.split('?') + loginUrl = `${loginUrl}?c_url=${encodeURIComponent(successUrl)}` + + showLoginModal({ loginUrl }) + } } break case 499: diff --git a/frontend/desktop/src/assets/html/index.html b/frontend/desktop/src/assets/html/index.html index 2bef9dad5c..9a045ae3b7 100644 --- a/frontend/desktop/src/assets/html/index.html +++ b/frontend/desktop/src/assets/html/index.html @@ -52,6 +52,8 @@ var BK_DOMAIN = '{{BK_DOMAIN}}'; var BK_PAAS_ESB_HOST = '{{BK_PAAS_ESB_HOST}}' var TASK_LIST_STATUS_FILTER_DAYS = {{TASK_LIST_STATUS_FILTER_DAYS}} + var LOGIN_URL = '{{LOGIN_URL}}' + var BK_PAAS_SHARED_RES_URL = '{{BK_PAAS_SHARED_RES_URL}}' // 是否开启通知中心 var ENABLE_NOTICE_CENTER = {{ENABLE_NOTICE_CENTER}} function getCookie(name) { diff --git a/frontend/desktop/src/components/layout/CopyrightFooter.vue b/frontend/desktop/src/components/layout/CopyrightFooter.vue index 0f450f64b0..4a331b9551 100644 --- a/frontend/desktop/src/components/layout/CopyrightFooter.vue +++ b/frontend/desktop/src/components/layout/CopyrightFooter.vue @@ -10,7 +10,12 @@ * specific language governing permissions and limitations under the License. */