Spaces:
Running
Running
Upload 9 files
Browse files- src/views/InstructorView.js +18 -12
src/views/InstructorView.js
CHANGED
|
@@ -383,24 +383,30 @@ export function setupInstructorEvents() {
|
|
| 383 |
} catch (error) {
|
| 384 |
console.error(error);
|
| 385 |
let msg = error.message;
|
|
|
|
|
|
|
| 386 |
if (error.code === 'auth/popup-blocked' || error.code === 'auth/popup-closed-by-user') {
|
| 387 |
-
msg = "瀏覽器攔截
|
| 388 |
-
|
| 389 |
-
if (confirm("視窗無法正常開啟。是否改用頁面跳轉方式登入?\n(將會重新整理頁面)")) {
|
| 390 |
-
try {
|
| 391 |
-
await signInWithGoogleRedirect();
|
| 392 |
-
} catch (err) {
|
| 393 |
-
alert("跳轉失敗: " + err.message);
|
| 394 |
-
}
|
| 395 |
-
return;
|
| 396 |
-
}
|
| 397 |
}
|
| 398 |
if (error.code === 'auth/operation-not-allowed' || error.message.includes('invalid')) {
|
| 399 |
msg = "Google 登入功能未啟用。請前往 Firebase Console > Authentication開啟 Google Sign-In。";
|
| 400 |
-
alert(msg);
|
| 401 |
}
|
| 402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
authErrorMsg.classList.remove('hidden');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
} finally {
|
| 405 |
authBtn.disabled = false;
|
| 406 |
authBtn.classList.remove('opacity-50');
|
|
|
|
| 383 |
} catch (error) {
|
| 384 |
console.error(error);
|
| 385 |
let msg = error.message;
|
| 386 |
+
let showRedirectBtn = false;
|
| 387 |
+
|
| 388 |
if (error.code === 'auth/popup-blocked' || error.code === 'auth/popup-closed-by-user') {
|
| 389 |
+
msg = "登入視窗未正常開啟 (可能是瀏覽器攔截)。";
|
| 390 |
+
showRedirectBtn = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
}
|
| 392 |
if (error.code === 'auth/operation-not-allowed' || error.message.includes('invalid')) {
|
| 393 |
msg = "Google 登入功能未啟用。請前往 Firebase Console > Authentication開啟 Google Sign-In。";
|
|
|
|
| 394 |
}
|
| 395 |
+
|
| 396 |
+
authErrorMsg.innerHTML = `
|
| 397 |
+
${msg}
|
| 398 |
+
${showRedirectBtn ? '<br><button id="redirect-login-btn" class="mt-2 bg-cyan-600 hover:bg-cyan-500 text-white px-3 py-1 rounded text-xs transition-colors">改用頁面跳轉登入</button>' : ''}
|
| 399 |
+
`;
|
| 400 |
authErrorMsg.classList.remove('hidden');
|
| 401 |
+
|
| 402 |
+
// Attach listener if button exists
|
| 403 |
+
const retryBtn = document.getElementById('redirect-login-btn');
|
| 404 |
+
if (retryBtn) {
|
| 405 |
+
retryBtn.addEventListener('click', () => {
|
| 406 |
+
signInWithGoogleRedirect().catch(e => alert("跳轉失敗: " + e.message));
|
| 407 |
+
});
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
} finally {
|
| 411 |
authBtn.disabled = false;
|
| 412 |
authBtn.classList.remove('opacity-50');
|