-
-
+
未登录
diff --git a/public/js/auth.js b/public/js/auth.js
index d9ea0da..8ac0e1f 100644
--- a/public/js/auth.js
+++ b/public/js/auth.js
@@ -62,16 +62,19 @@ export default class AuthManager {
if (this.closeModalBtn) {
this.closeModalBtn.addEventListener('click', () => {
- if (!state.token) {
- showToast('请先登录后再关闭', 'error');
- return;
- }
+ // Allow closing modal even without login
this.hideAuthModal();
});
}
if (this.logoutBtn) {
- this.logoutBtn.addEventListener('click', () => this.logout());
+ this.logoutBtn.addEventListener('click', () => {
+ if (state.user) {
+ this.logout();
+ } else {
+ this.showAuthModal(state.currentServer || window.location.origin);
+ }
+ });
}
if (this.authPassword) {
@@ -229,9 +232,7 @@ export default class AuthManager {
if (this.authModal) {
this.authModal.style.display = 'flex';
}
- if (this.mainContainer) {
- this.mainContainer.style.display = 'none';
- }
+ // Don't hide main container anymore
const serverValue = prefillServer || state.currentServer || window.location.origin;
if (this.authServer) {
@@ -266,6 +267,10 @@ export default class AuthManager {
if (this.userDisplay) {
this.userDisplay.textContent = state.user ? `用户: ${state.user.username}` : '未登录';
}
+ // Update logout button text based on login state
+ if (this.logoutBtn) {
+ this.logoutBtn.textContent = state.user ? '退出' : '登录';
+ }
}
async handleServerSelection(server) {
@@ -275,9 +280,8 @@ export default class AuthManager {
state.token = '';
state.user = null;
this.calendarView.clearData();
- this.hideMainContainer();
- this.showAuthModal();
this.updateUserDisplay();
+ // Keep main container visible
return;
}
@@ -299,6 +303,8 @@ export default class AuthManager {
state.user = null;
this.calendarView.clearData();
this.updateUserDisplay();
+ // Show main container and auth modal together
+ this.showMainContainer();
this.showAuthModal(server);
}
}
@@ -312,7 +318,7 @@ export default class AuthManager {
this.calendarView.clearData();
this.updateUserDisplay();
showToast('已退出登录', 'success');
- this.hideMainContainer();
+ // Keep main container visible, just show auth modal
this.showAuthModal(state.currentServer || window.location.origin);
}
@@ -329,15 +335,18 @@ export default class AuthManager {
const storedToken = storedServer ? getToken(storedServer) : '';
const storedUser = storedServer ? getUser(storedServer) : null;
+ // Always show main container first
+ this.showMainContainer();
if (storedServer && storedToken && storedUser) {
state.token = storedToken;
state.user = storedUser;
- this.showMainContainer();
this.updateUserDisplay();
+ // Try to load data, will show login if it fails
this.calendarView.loadData();
} else {
- this.hideMainContainer();
- this.showAuthModal(storedServer || window.location.origin);
+ // Render empty calendar
+ this.updateUserDisplay();
+ this.calendarView.renderCalendar();
}
}
}
diff --git a/public/js/calendar.js b/public/js/calendar.js
index 817eeef..d12c840 100644
--- a/public/js/calendar.js
+++ b/public/js/calendar.js
@@ -52,6 +52,8 @@ export default class CalendarView {
async loadData() {
if (!state.currentServer || !state.token) {
+ // No server or token, just render calendar without loading
+ this.renderCalendar();
return;
}
@@ -74,6 +76,8 @@ export default class CalendarView {
return;
}
showToast(error.message || '加载失败', 'error');
+ // Still render the calendar even if loading fails
+ this.renderCalendar();
}
}