Skip to content

Commit

Permalink
sprintfix: 调整国际化切换规则 (closed TencentBlueKing#1445)
Browse files Browse the repository at this point in the history
  • Loading branch information
GONGONGONG committed Jul 10, 2023
1 parent acf4c0d commit 1e5b17e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
4 changes: 4 additions & 0 deletions frontend/index-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
const BK_PAAS_HOST = ''
const DEFAULT_SSH_PORT = '22'
const USE_TJJ = 'False'
const BK_COMPONENT_API_URL = ''
const BK_DOCS_CENTER_URL = '/'
const BK_DOMAIN = ''
const BKAPP_RUN_ENV = 'ee'
const BKAPP_ENABLE_DHCP = 'True'
const TAM_ID = ''
Expand Down Expand Up @@ -62,7 +64,9 @@
BK_PAAS_HOST,
DEFAULT_SSH_PORT,
USE_TJJ,
BK_COMPONENT_API_URL,
BK_DOCS_CENTER_URL,
BK_DOMAIN,
BKAPP_RUN_ENV,
BKAPP_ENABLE_DHCP,
TAM_ID,
Expand Down
4 changes: 4 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
const BK_PAAS_HOST = '{{ BK_PAAS_HOST }}'
const DEFAULT_SSH_PORT = '{{ DEFAULT_SSH_PORT }}'
const USE_TJJ = '{{ USE_TJJ }}'
const BK_COMPONENT_API_URL = '{{ BK_COMPONENT_API_URL }}'
const BK_DOCS_CENTER_URL = '{{ BK_DOCS_CENTER_URL }}'
const BK_DOMAIN = '{{ BK_DOMAIN }}'
const BKAPP_RUN_ENV = '{{ BKAPP_RUN_ENV }}'
const BKAPP_ENABLE_DHCP = '{{ BKAPP_ENABLE_DHCP }}'
const TAM_ID = '{{ TAM_ID }}'
Expand All @@ -46,7 +48,9 @@
return {
APP_CODE,
APPO_IP,
BK_COMPONENT_API_URL,
BK_DOCS_CENTER_URL,
BK_DOMAIN,
BK_PAAS_HOST,
BKAPP_ENABLE_DHCP,
BKAPP_NAV_HELPER_URL,
Expand Down
26 changes: 18 additions & 8 deletions frontend/src/components/common/navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,27 @@ export default class NodemanNavigation extends Mixins(routerBackMixin) {
}
private toggleLang(item: IUserItem) {
if (item.id !== this.language) {
const {
BK_COMPONENT_API_URL: overwriteUrl = '',
BK_DOMAIN: domain = '',
} = window.PROJECT_CONFIG;
const api = `${overwriteUrl}/api/c/compapi/v2/usermanage/fe_update_user_language/?language=${item.id}`;
const scriptId = 'jsonp-script';
const prevJsonpScript = document.getElementById(scriptId);
if (prevJsonpScript) {
document.body.removeChild(prevJsonpScript);
}
const scriptEl = document.createElement('script');
scriptEl.type = 'text/javascript';
scriptEl.src = api;
scriptEl.id = scriptId;
document.body.appendChild(scriptEl);
const today = new Date();
today.setTime(today.getTime() + 1000 * 60 * 60 * 24);
const domainArr = document.domain.split('.');
if (domainArr.length > 2) {
domainArr.shift();
}
document.cookie = `blueking_language=0;path=/;domain=${domainArr.slice(-2).join('.')};expires=${new Date(0).toUTCString()}`;
document.cookie = `blueking_language=${item.id};path=/;domain=${domainArr.join('.')};expires=${today.toUTCString()}`;
document.cookie = `blueking_language=${item.id};path=/;domain=${domainArr.slice(-2).join('.')};expires=${today.toUTCString()}`;
document.cookie = `blueking_language=${item.id};path=/;domain=${domain};expires=${today.toUTCString()}`;
location.reload();
// this.$i18n.locale = item.id;
}
}
/**
Expand Down

0 comments on commit 1e5b17e

Please sign in to comment.