diff --git a/src/api/configuration.ts b/src/api/configuration.ts index 37cfc6e..bfcdfab 100644 --- a/src/api/configuration.ts +++ b/src/api/configuration.ts @@ -64,3 +64,8 @@ export const getCourseListApi = (params: CourseListParams) => { params, }) } + +// 根据id获取课程详情 +export const getCourseDetailApi = (id: string) => { + return request.get(`/api/coursesteacher/${id}`) +} diff --git a/src/store/module/learnPath.ts b/src/store/module/learnPath.ts new file mode 100644 index 0000000..2172e47 --- /dev/null +++ b/src/store/module/learnPath.ts @@ -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>(item as {} || {}) + const courseData = ref>(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 \ No newline at end of file diff --git a/src/views/professionalListProfile/index.vue b/src/views/professionalListProfile/index.vue index 393d134..f7105af 100644 --- a/src/views/professionalListProfile/index.vue +++ b/src/views/professionalListProfile/index.vue @@ -1,9 +1,12 @@