feat: 後端API
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
fetchNight,
|
||||
fetchNoon,
|
||||
} from '@/api/course'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
|
||||
/** 後端尚未完成,預設走前端模擬資料;設定 VITE_USE_MOCK=false 即改打真實 API */
|
||||
const USE_MOCK = import.meta.env.VITE_USE_MOCK !== 'false'
|
||||
@@ -152,11 +153,16 @@ export const useCourseStore = defineStore('course', () => {
|
||||
return
|
||||
}
|
||||
|
||||
const [groupValue, morningValue, noonValue, nightValue] = await Promise.all([
|
||||
fetchGroup(),
|
||||
fetchMorning(),
|
||||
fetchNoon(),
|
||||
fetchNight(),
|
||||
// 真實後端:course/group 需要 userID,course/morning、noon、night 需要 group,
|
||||
// 兩者有相依順序,因此無法四支平行呼叫(與 doc/課程建議API規格.md 的示意圖不同,
|
||||
// 以 doc/課程建議_API_前端使用說明_20260806.md 的建議測試流程為準)
|
||||
const { userID } = useAppStore()
|
||||
const groupValue = await fetchGroup(userID)
|
||||
|
||||
const [morningValue, noonValue, nightValue] = await Promise.all([
|
||||
fetchMorning(groupValue),
|
||||
fetchNoon(groupValue),
|
||||
fetchNight(groupValue),
|
||||
])
|
||||
|
||||
group.value = groupValue
|
||||
|
||||
Reference in New Issue
Block a user