加入注销登录功能
This commit is contained in:
@@ -139,9 +139,14 @@
|
||||
</svg>
|
||||
<h2>小财记账</h2>
|
||||
</div>
|
||||
<div style="display:flex; gap:2px;">
|
||||
<button class="icon-btn" id="create-room-btn" onclick="openCreateRoom()" title="新建群聊">
|
||||
<svg viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
|
||||
</button>
|
||||
<button class="icon-btn" id="logout-btn" onclick="logout()" title="注销登录">
|
||||
<svg viewBox="0 0 24 24"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="chat-list" id="chat-list-container"></div>
|
||||
<div class="summary-card" onclick="openSummary()">
|
||||
@@ -248,6 +253,16 @@
|
||||
localStorage.removeItem('currentUser');
|
||||
localStorage.removeItem('isAdmin');
|
||||
}
|
||||
function logout() {
|
||||
if (ws) { ws.close(); ws = null; }
|
||||
clearAuth();
|
||||
document.getElementById('login-page').classList.remove('hidden');
|
||||
document.getElementById('main-page').classList.add('hidden');
|
||||
currentRoom = null;
|
||||
rooms = [];
|
||||
document.getElementById('chat-list-container').innerHTML = '';
|
||||
document.getElementById('messages-container').innerHTML = '';
|
||||
}
|
||||
|
||||
if (typeof marked !== 'undefined') marked.setOptions({ breaks: true, gfm: true, sanitize: false });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user