41 lines
976 B
JavaScript
41 lines
976 B
JavaScript
import {defineStore} from "pinia";
|
|
import {computed, ref} from "vue";
|
|
import {tours} from "../config/tours.js";
|
|
|
|
export const useOnboardingStore = defineStore('onboarding', () => {
|
|
const activeTourId = ref(null)
|
|
const activeStepIndex = ref(0)
|
|
const isActive = ref(false)
|
|
|
|
const currentTourSteps = computed(() => {
|
|
if (!activeTourId.value) return []
|
|
return tours[activeTourId.value]?.steps || []
|
|
})
|
|
|
|
const startTour = (tourId, startFrom = 0) => {
|
|
activeTourId.value = tourId
|
|
activeStepIndex.value = startFrom
|
|
isActive.value = true
|
|
}
|
|
|
|
const setStep = (index) => {
|
|
activeStepIndex.value = index
|
|
}
|
|
|
|
const finish = () => {
|
|
activeTourId.value = null
|
|
activeStepIndex.value = 0
|
|
isActive.value = false
|
|
}
|
|
|
|
return {
|
|
activeTourId,
|
|
activeStepIndex,
|
|
isActive,
|
|
currentTourSteps,
|
|
startTour,
|
|
finish,
|
|
setStep
|
|
}
|
|
})
|