Skip to content

Commit

Permalink
feat(front): 加上协议头(closed #320)
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 9384
  • Loading branch information
hyunfa authored and wyyalt committed Jun 6, 2024
1 parent dd79240 commit a870fe4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion web/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,17 @@ function handleReject(error, config) {
const nextError = { message: error.message, response: error.response };
if (status === 401) {
// 未登录, o.a 登录弹窗有问题先不做弹窗
const siteLoginUrl = window.PROJECT_CONFIG.LOGIN_URL;
let siteLoginUrl = window.PROJECT_CONFIG.LOGIN_URL;
// 登录成功之后的回调地址,用于执行关闭登录窗口或刷新父窗口页面等动作
const successUrl = `${window.location.origin}/login_success.html`;
if (!siteLoginUrl) {
console.error('Login URL not configured!')
return
}
// 加上协议头
if (!/http(s)?:\/\//.test(siteLoginUrl)) {
siteLoginUrl = `${window.location.protocol}//${siteLoginUrl}`;
}
const loginURL = new URL(siteLoginUrl);
loginURL.searchParams.set('c_url', successUrl);
const pathname = loginURL.pathname.endsWith('/') ? loginURL.pathname : `${loginURL.pathname}/`;
Expand Down
8 changes: 6 additions & 2 deletions web/src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ export default {
this.$router.push('/process-manage/status');
},
handleLogout() {
// location.assign('/console/accounts/logout/');
location.href = `${window.PROJECT_CONFIG.LOGIN_URL}?c_url=${encodeURIComponent(`${window.location}&is_from_logout=1`)}`;
// 加上协议头
let loginUrl = window.PROJECT_CONFIG.LOGIN_URL;
if (!/http(s)?:\/\//.test(loginUrl)) {
loginUrl = `${window.location.protocol}//${loginUrl}`;
}
location.href = `${loginUrl}?is_from_logout=1&c_url=${encodeURIComponent(window.location)}`;
},
async resetAuthInfo() {
const currentBiz = this.bizList.find(item => item.bk_biz_id === this.bizId);
Expand Down

0 comments on commit a870fe4

Please sign in to comment.