From 85443cbfa7cbbb50766447e54b4f0789f957fc32 Mon Sep 17 00:00:00 2001 From: significative <163999932+significative@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:06:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E4=B9=A0=E8=B7=AF=E5=BE=84=E6=8E=A8?= =?UTF-8?q?=E8=8D=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/configuration.ts | 5 ++ src/store/module/learnPath.ts | 24 +++++++++ src/views/professionalListProfile/index.vue | 12 ++++- src/views/roadbedRecommendation/index.vue | 60 ++++++++++----------- 4 files changed, 68 insertions(+), 33 deletions(-) create mode 100644 src/store/module/learnPath.ts 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 @@