show main page by default.
Some checks failed
Build and Push Docker Image / buildx (push) Has been cancelled
Some checks failed
Build and Push Docker Image / buildx (push) Has been cancelled
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<!-- 登录/注册模态框 -->
|
||||
<div id="authModal" class="modal">
|
||||
<div id="authModal" class="modal" style="display: none;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h2 id="authTitle">登录</h2>
|
||||
@@ -43,7 +43,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 主应用容器 -->
|
||||
<div class="container" id="mainContainer" style="display: none;">
|
||||
<div class="container" id="mainContainer">
|
||||
<!-- 日历放在顶部 -->
|
||||
<div class="calendar" id="calendar"></div>
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
<button id="removeServerBtn" class="btn-remove">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 用户信息移到最后 -->
|
||||
<div class="user-info">
|
||||
<span id="userDisplay">未登录</span>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user