From ae246968201c70c3a50087d3eff22018c2c7084a Mon Sep 17 00:00:00 2001 From: yiwenZhou <67539158+ywywZhou@users.noreply.github.com> Date: Sun, 25 Jun 2023 11:25:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B7=A8=E7=B3=BB=E7=BB=9F=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E5=A4=84=E7=90=86&&ip=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=99=A8agent=E5=BC=82=E5=B8=B8=E6=80=81=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E6=93=8D=E4=BD=9C=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20(#6815)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/desktop/src/api/index.js | 41 +++++++++++++++++++ frontend/desktop/src/assets/html/index.html | 1 + .../common/RenderForm/IpSelector/StaticIp.vue | 6 +-- .../components/layout/NavigatorHeadRight.vue | 16 +++++++- 4 files changed, 59 insertions(+), 5 deletions(-) diff --git a/frontend/desktop/src/api/index.js b/frontend/desktop/src/api/index.js index 373acfa707..ce178fb808 100644 --- a/frontend/desktop/src/api/index.js +++ b/frontend/desktop/src/api/index.js @@ -137,3 +137,44 @@ axios.interceptors.response.use( return Promise.reject(response) } ) + +axios.jsonp = (url, data) => { + if (!url) { + throw new Error('url is necessary') + } + const callback = 'CALLBACK' + Math.random().toString().substr(9, 18) + const JSONP = document.createElement('script') + JSONP.setAttribute('type', 'text/javascript') + + const headEle = document.getElementsByTagName('head')[0] + + let ret = '' + if (data) { + if (typeof data === 'string') { + ret = '&' + data + } else if (typeof data === 'object') { + for (const key in data) { + ret += '&' + key + '=' + encodeURIComponent(data[key]) + } + } + ret += '&_time=' + Date.now() + } + JSONP.src = `${url}?callback=${callback}${ret}` + + function remove () { + headEle.removeChild(JSONP) + delete window[callback] + } + return new Promise((resolve, reject) => { + window[callback] = r => { + resolve(r) + remove() + } + JSONP.onerror = err => { + reject(err) + remove() + } + + headEle.appendChild(JSONP) + }) +} diff --git a/frontend/desktop/src/assets/html/index.html b/frontend/desktop/src/assets/html/index.html index abb98a5fd3..75cb5e8541 100644 --- a/frontend/desktop/src/assets/html/index.html +++ b/frontend/desktop/src/assets/html/index.html @@ -47,6 +47,7 @@ var MEMBER_SELECTOR_DATA_HOST = '{{MEMBER_SELECTOR_DATA_HOST}}'; var MAX_NODE_EXECUTE_TIMEOUT = {{MAX_NODE_EXECUTE_TIMEOUT}}; var BK_DOMAIN = '{{BK_DOMAIN}}' + var BK_PAAS_ESB_HOST = {{BK_PAAS_ESB_HOST}} function getCookie(name) { var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); return (arr = document.cookie.match(reg)) ? unescape(arr[2]) : null; diff --git a/frontend/desktop/src/components/common/RenderForm/IpSelector/StaticIp.vue b/frontend/desktop/src/components/common/RenderForm/IpSelector/StaticIp.vue index 2a6c344a33..b821b6e476 100644 --- a/frontend/desktop/src/components/common/RenderForm/IpSelector/StaticIp.vue +++ b/frontend/desktop/src/components/common/RenderForm/IpSelector/StaticIp.vue @@ -158,7 +158,7 @@ }, computed: { failedAgentLength () { - return this.staticIps.filter(item => !item.agent).length + return this.staticIps.filter(item => item.agent !== 1).length }, isShowQuantity () { return this.staticIps.length @@ -224,14 +224,14 @@ this.handleIpCopy(ipStr) }, copyAgentIp () { - const ipStr = this.staticIps.filter(item => !item.agent).map(d => d.bk_host_innerip).join(',') + const ipStr = this.staticIps.filter(item => item.agent !== 1).map(d => d.bk_host_innerip).join(',') this.handleIpCopy(ipStr) }, clearIp () { this.$emit('change', []) }, clearFailedAgentIp () { - const staticIps = this.staticIps.filter(item => !!item.agent) + const staticIps = this.staticIps.filter(item => item.agent === 1) this.$emit('change', staticIps) }, onDropdownShow () { diff --git a/frontend/desktop/src/components/layout/NavigatorHeadRight.vue b/frontend/desktop/src/components/layout/NavigatorHeadRight.vue index 4221dab6d8..1e8ced062d 100644 --- a/frontend/desktop/src/components/layout/NavigatorHeadRight.vue +++ b/frontend/desktop/src/components/layout/NavigatorHeadRight.vue @@ -92,6 +92,7 @@ import ProjectSelector from './ProjectSelector.vue' import VersionLog from './VersionLog.vue' import Cookies from 'js-cookie' + import axios from 'axios' export default { name: 'NavigatorHeadRight', @@ -163,7 +164,7 @@ ...mapMutations('project', [ 'setProjectId' ]), - toggleLanguage (language) { + async toggleLanguage (language) { this.curLanguage = language const local = language === 'chinese' ? 'zh-cn' : 'en' const domain = window.BK_DOMAIN || window.location.hostname.replace(/^[^.]+(.*)$/, '$1') @@ -172,7 +173,18 @@ domain, path: '/' }) - window.location.reload() + if (window.BK_PAAS_ESB_HOST) { + const url = `${window.BK_PAAS_ESB_HOST}/api/c/compapi/v2/usermanage/fe_update_user_language/` + try { + await axios.jsonp(url, { language }) + } catch (error) { + console.warn(error) + } finally { + window.location.reload() + } + } else { + window.location.reload() + } }, goToHelpDoc () { window.open(this.bkDocUrl, '_blank') From 251c536e092f8ec67b500751094a9ac016095441 Mon Sep 17 00:00:00 2001 From: pagezz Date: Sun, 25 Jun 2023 11:27:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/stag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/stag.py b/config/stag.py index 75ae77ad99..1a711d2deb 100644 --- a/config/stag.py +++ b/config/stag.py @@ -16,7 +16,7 @@ if RUN_VER == "open": from blueapps.patch.settings_open_saas import * # noqa else: - from blueapps.patch.settings_paas_services import * # noqaJobExecuteTaskComponent + from blueapps.patch.settings_paas_services import * # noqa import env