This commit is contained in:
team3
2026-06-25 18:17:37 +02:00
parent e0a5f4956f
commit 2a2026c9ae
2 changed files with 7 additions and 21 deletions

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, computed, watch, onMounted, nextTick } from 'vue'
import { ref, computed, watch, onMounted } from 'vue'
import { fetchGuides, fetchTopics, createTopic as apiCreateTopic, deleteTopic as apiDeleteTopic, createGuide as apiCreate, deleteGuide, cancelGuide as apiCancel, fetchBausteineStatus, fetchActiveBausteine, createBausteine as apiCreateBausteine, cancelBausteine as apiCancelBausteine, deleteBausteine as apiDeleteBausteine, fetchProviders, fetchStats, fetchTopicFortschritt, fetchGuideLocks, fetchGuideSteps, fetchFolders, updateQuelle as apiUpdateQuelle } from './api.js'
import { usePolling } from './composables/usePolling.js'
import TopicSidebar from './components/TopicSidebar.vue'
@@ -185,31 +185,17 @@ async function loadBausteine() {
}
}
const FORMAT_ORDER = ['Guide', 'FullGuide', 'Rest']
function autoPreview() {
const map = doneByFormat.value
for (const f of FORMAT_ORDER) {
if (map[f]) {
previewGuide.value = map[f]
return
}
}
previewGuide.value = null
}
function selectTopic(topic) {
selectedTopic.value = topic
previewGuide.value = null
sidebarSticky.value = false
elementsOpen.value = false
elementsView.value = false
bausteineView.value = false
bausteineView.value = true // Thema-Klick → Baustein-Übersicht (Guide erst auf Pill-Klick)
elementOpenId.value = null
ansichtModus.value = localStorage.getItem('ansicht_' + topic) === 'erklärend' ? 'erklärend' : 'kompakt'
localStorage.setItem('lastTopic', topic)
loadBausteine()
nextTick(autoPreview)
}
// Beim Reload dort landen, wo man vorher war (Thema + Format)
@@ -362,12 +348,8 @@ async function handleDeleteTopic(topic) {
onMounted(async () => {
await Promise.all([loadGuides(), loadTopics(), loadProviders(), loadFolders()])
const savedTopic = localStorage.getItem('lastTopic')
const savedFormat = localStorage.getItem('lastFormat')
if (savedTopic && topics.value.includes(savedTopic)) {
selectTopic(savedTopic)
await nextTick()
const g = doneByFormat.value[savedFormat]
if (g) previewGuide.value = g
selectTopic(savedTopic) // landet auf der Baustein-Übersicht
} else if (!selectedTopic.value && topics.value.length) {
selectTopic(topics.value[0])
}

View File

@@ -81,6 +81,10 @@ async function loadContent() {
try {
lernstand.value = (await fetchBausteinLernstand(g.topic)).bausteine || {}
} catch { /* offline → leer */ }
// Beim Öffnen zum ersten noch nicht gemeisterten prüfbaren Baustein scrollen.
await nextTick()
const ziel = bausteine.value.find((s) => istPruefbar(s) && stufeVon(s.title)?.key !== 'meister')
if (ziel) scrollEl.value?.querySelector(`[data-num="${ziel.num}"]`)?.scrollIntoView({ block: 'start' })
}
// --- Baustein-Lernen: Prüfungs-Stand pro Baustein-Titel (lernstand oben deklariert) ---