parent
6a0801ba9f
commit
85443cbfa7
4 changed files with 68 additions and 33 deletions
@ -0,0 +1,24 @@ |
||||
import { defineStore } from 'pinia' |
||||
import { ref } from 'vue'; |
||||
import { getCourseDetailApi } from '@/api/configuration'; |
||||
|
||||
|
||||
|
||||
const useLearnPathStore = defineStore('learnPath', () => { |
||||
let item = sessionStorage.getItem('learnPath:itemData') |
||||
let course = sessionStorage.getItem('learnPath:courseData') |
||||
if (item) item = JSON.parse(item) |
||||
if (course) course = JSON.parse(course) |
||||
const itemData = ref<Record<string, any>>(item as {} || {}) |
||||
const courseData = ref<Record<string, any>>(course as {} || {}) |
||||
function setCourseData(item: any) { |
||||
courseData.value = item |
||||
sessionStorage.setItem('learnPath:itemData', JSON.stringify(item)) |
||||
getCourseDetailApi(item.id).then(res => { |
||||
courseData.value = res.data |
||||
sessionStorage.setItem('learnPath:courseData', JSON.stringify(res.data)) |
||||
}) |
||||
} |
||||
return { setCourseData, itemData, courseData } |
||||
}) |
||||
export default useLearnPathStore |
Loading…
Reference in new issue