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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- 登录/注册模态框 -->
|
<!-- 登录/注册模态框 -->
|
||||||
<div id="authModal" class="modal">
|
<div id="authModal" class="modal" style="display: none;">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h2 id="authTitle">登录</h2>
|
<h2 id="authTitle">登录</h2>
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 主应用容器 -->
|
<!-- 主应用容器 -->
|
||||||
<div class="container" id="mainContainer" style="display: none;">
|
<div class="container" id="mainContainer">
|
||||||
<!-- 日历放在顶部 -->
|
<!-- 日历放在顶部 -->
|
||||||
<div class="calendar" id="calendar"></div>
|
<div class="calendar" id="calendar"></div>
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
<button id="removeServerBtn" class="btn-remove">删除</button>
|
<button id="removeServerBtn" class="btn-remove">删除</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 用户信息移到最后 -->
|
<!-- 用户信息移到最后 -->
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<span id="userDisplay">未登录</span>
|
<span id="userDisplay">未登录</span>
|
||||||
|
|||||||
@@ -62,16 +62,19 @@ export default class AuthManager {
|
|||||||
|
|
||||||
if (this.closeModalBtn) {
|
if (this.closeModalBtn) {
|
||||||
this.closeModalBtn.addEventListener('click', () => {
|
this.closeModalBtn.addEventListener('click', () => {
|
||||||
if (!state.token) {
|
// Allow closing modal even without login
|
||||||
showToast('请先登录后再关闭', 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.hideAuthModal();
|
this.hideAuthModal();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.logoutBtn) {
|
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) {
|
if (this.authPassword) {
|
||||||
@@ -229,9 +232,7 @@ export default class AuthManager {
|
|||||||
if (this.authModal) {
|
if (this.authModal) {
|
||||||
this.authModal.style.display = 'flex';
|
this.authModal.style.display = 'flex';
|
||||||
}
|
}
|
||||||
if (this.mainContainer) {
|
// Don't hide main container anymore
|
||||||
this.mainContainer.style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
const serverValue = prefillServer || state.currentServer || window.location.origin;
|
const serverValue = prefillServer || state.currentServer || window.location.origin;
|
||||||
if (this.authServer) {
|
if (this.authServer) {
|
||||||
@@ -266,6 +267,10 @@ export default class AuthManager {
|
|||||||
if (this.userDisplay) {
|
if (this.userDisplay) {
|
||||||
this.userDisplay.textContent = state.user ? `用户: ${state.user.username}` : '未登录';
|
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) {
|
async handleServerSelection(server) {
|
||||||
@@ -275,9 +280,8 @@ export default class AuthManager {
|
|||||||
state.token = '';
|
state.token = '';
|
||||||
state.user = null;
|
state.user = null;
|
||||||
this.calendarView.clearData();
|
this.calendarView.clearData();
|
||||||
this.hideMainContainer();
|
|
||||||
this.showAuthModal();
|
|
||||||
this.updateUserDisplay();
|
this.updateUserDisplay();
|
||||||
|
// Keep main container visible
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,6 +303,8 @@ export default class AuthManager {
|
|||||||
state.user = null;
|
state.user = null;
|
||||||
this.calendarView.clearData();
|
this.calendarView.clearData();
|
||||||
this.updateUserDisplay();
|
this.updateUserDisplay();
|
||||||
|
// Show main container and auth modal together
|
||||||
|
this.showMainContainer();
|
||||||
this.showAuthModal(server);
|
this.showAuthModal(server);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,7 +318,7 @@ export default class AuthManager {
|
|||||||
this.calendarView.clearData();
|
this.calendarView.clearData();
|
||||||
this.updateUserDisplay();
|
this.updateUserDisplay();
|
||||||
showToast('已退出登录', 'success');
|
showToast('已退出登录', 'success');
|
||||||
this.hideMainContainer();
|
// Keep main container visible, just show auth modal
|
||||||
this.showAuthModal(state.currentServer || window.location.origin);
|
this.showAuthModal(state.currentServer || window.location.origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,15 +335,18 @@ export default class AuthManager {
|
|||||||
const storedToken = storedServer ? getToken(storedServer) : '';
|
const storedToken = storedServer ? getToken(storedServer) : '';
|
||||||
const storedUser = storedServer ? getUser(storedServer) : null;
|
const storedUser = storedServer ? getUser(storedServer) : null;
|
||||||
|
|
||||||
|
// Always show main container first
|
||||||
|
this.showMainContainer();
|
||||||
if (storedServer && storedToken && storedUser) {
|
if (storedServer && storedToken && storedUser) {
|
||||||
state.token = storedToken;
|
state.token = storedToken;
|
||||||
state.user = storedUser;
|
state.user = storedUser;
|
||||||
this.showMainContainer();
|
|
||||||
this.updateUserDisplay();
|
this.updateUserDisplay();
|
||||||
|
// Try to load data, will show login if it fails
|
||||||
this.calendarView.loadData();
|
this.calendarView.loadData();
|
||||||
} else {
|
} else {
|
||||||
this.hideMainContainer();
|
// Render empty calendar
|
||||||
this.showAuthModal(storedServer || window.location.origin);
|
this.updateUserDisplay();
|
||||||
|
this.calendarView.renderCalendar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ export default class CalendarView {
|
|||||||
|
|
||||||
async loadData() {
|
async loadData() {
|
||||||
if (!state.currentServer || !state.token) {
|
if (!state.currentServer || !state.token) {
|
||||||
|
// No server or token, just render calendar without loading
|
||||||
|
this.renderCalendar();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +76,8 @@ export default class CalendarView {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showToast(error.message || '加载失败', 'error');
|
showToast(error.message || '加载失败', 'error');
|
||||||
|
// Still render the calendar even if loading fails
|
||||||
|
this.renderCalendar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user