Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 联调蓝鲸语言切换接口 #1056

Open
wants to merge 2 commits into
base: v1.7.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions front/src/views/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,29 @@ export default defineComponent({
const { topMenuActiveItem, menus, curPath, handleHeaderMenuClick } = useChangeHeaderTab();

const saveLanguage = async (val: string) => {
return new Promise((resovle) => {
const url = `${BK_COMPONENT_API_URL}/api/c/compapi/v2/usermanage/fe_update_user_language/language=${val}`;
return new Promise((resolve, reject) => {
const url = `${BK_COMPONENT_API_URL}/api/c/compapi/v2/usermanage/fe_update_user_language/`;
const callbackName = 'CALLBACK585231658';
const headEle = document.head || document.getElementsByTagName('head')[0];

const scriptTag = document.createElement('script');
scriptTag.setAttribute('type', 'text/javascript');
scriptTag.setAttribute('src', url);
const headTag = document.getElementsByTagName('head')[0];
headTag.appendChild(scriptTag);
resovle(val);
const JSONP = document.createElement('script');
JSONP.setAttribute('type', 'text/javascript');
JSONP.setAttribute('src', `${url}?callback=${callbackName}&language=${val}`);

window[callbackName] = (result: boolean) => {
resolve(result);
headEle.removeChild(JSONP);
delete window[callbackName];
};

// 错误处理
JSONP.onerror = (err) => {
reject(err);
headEle.removeChild(JSONP);
delete window[callbackName];
};

document.head.appendChild(JSONP);
});
};

Expand Down