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 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')