|
|
@@ -86,17 +86,40 @@ const handleLinkClick = (event, link) => {
|
|
|
console.log('[前端] 链接名称:', link.name);
|
|
|
console.log('[前端] 自动登录端点:', link.autoLoginEndpoint);
|
|
|
|
|
|
- const autoLoginUrl = getAutoLoginUrl(link.autoLoginEndpoint);
|
|
|
- console.log('[前端] 完整自动登录URL:', autoLoginUrl);
|
|
|
- console.log('[前端] 准备跳转到后端端点...');
|
|
|
- console.log('========================================');
|
|
|
-
|
|
|
- // 阻止默认行为并跳转到后端端点
|
|
|
- event.preventDefault();
|
|
|
- event.stopPropagation();
|
|
|
+ try {
|
|
|
+ const autoLoginUrl = getAutoLoginUrl(link.autoLoginEndpoint);
|
|
|
+ console.log('[前端] 完整自动登录URL:', autoLoginUrl);
|
|
|
+ console.log('[前端] 准备跳转到后端端点...');
|
|
|
+
|
|
|
+ // 阻止默认行为并跳转到后端端点
|
|
|
+ event.preventDefault();
|
|
|
+ event.stopPropagation();
|
|
|
+
|
|
|
+ // 先测试后端是否可达
|
|
|
+ console.log('[前端] 测试后端连接...');
|
|
|
+ fetch(autoLoginUrl, { method: 'HEAD', mode: 'no-cors' })
|
|
|
+ .then(() => {
|
|
|
+ console.log('[前端] 后端连接正常,开始跳转');
|
|
|
+ window.location.href = autoLoginUrl;
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.error('[前端] 后端连接失败:', error);
|
|
|
+ console.log('[前端] 仍然尝试跳转...');
|
|
|
+ window.location.href = autoLoginUrl;
|
|
|
+ });
|
|
|
+
|
|
|
+ // 如果 fetch 不支持,直接跳转
|
|
|
+ setTimeout(() => {
|
|
|
+ console.log('[前端] 执行跳转:', autoLoginUrl);
|
|
|
+ window.location.href = autoLoginUrl;
|
|
|
+ }, 100);
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ console.error('[前端] 处理自动登录时出错:', error);
|
|
|
+ alert('自动登录失败: ' + error.message);
|
|
|
+ }
|
|
|
|
|
|
- // 直接跳转,让后端处理
|
|
|
- window.location.href = autoLoginUrl;
|
|
|
+ console.log('========================================');
|
|
|
} else {
|
|
|
// 普通链接,允许默认行为
|
|
|
console.log('[前端] 普通链接:', link.name, link.url);
|