fix: improve session initialization and save logic

- Fixed onMounted to properly set currentSession after creating default
- startNewChat now creates a new session when called
- Ensure authToken before all session API calls
This commit is contained in:
2026-10-27 06:11:28 +08:00
parent ac281b0766
commit f5dd8577b2
2 changed files with 12 additions and 7 deletions

Binary file not shown.

View File

@@ -600,19 +600,24 @@ function closeDropdowns(e: MouseEvent) {
onMounted(async () => {
document.addEventListener('click', closeDropdowns)
await ensureFiles()
await loadSessions()
loadBookmarks()
// Auto-login and load sessions
await loadSessions()
// Auto-create default session if none exists
if (!sessionList.value.length) {
await createSession('Default', 'keyword')
await loadSessions()
const defaultSession = await createSession('Default', 'keyword')
if (defaultSession) {
setCurrentSession(defaultSession)
}
} else {
await loadSessions()
// Set first session as current
if (sessionList.value.length && !currentSession.value) {
setCurrentSession(sessionList.value[0])
}
}
// Restore session from localStorage
try {