feat: 7.2

This commit is contained in:
skytek_xinliang
2026-08-17 11:26:13 +08:00
parent 347eb70d95
commit 332d00db75
8 changed files with 210 additions and 28 deletions
+7 -3
View File
@@ -236,8 +236,8 @@ export const useAppStore = defineStore("app", () => {
return Math.round((done / keys.length) * 100);
});
/** 手機門號登入;後端未完成時走模擬資料,完成後設 VITE_USE_MOCK=false 改打真實 API */
async function login(phone: string) {
/** 手機門號登入;密碼欄位將由登入頁在第 7.3 項補上。 */
async function login(phone: string, password = "") {
if (USE_MOCK) {
isLoggedIn.value = true;
userID.value = "MOCK-USER";
@@ -245,7 +245,11 @@ export const useAppStore = defineStore("app", () => {
return;
}
const response = await apiLogin(phone);
if (!password) {
throw new Error("請輸入登入密碼");
}
const response = await apiLogin({ phone, password });
isLoggedIn.value = true;
userID.value = response.userID;
+3 -6
View File
@@ -15,7 +15,6 @@ 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";
@@ -253,11 +252,9 @@ export const useCourseStore = defineStore("course", () => {
return;
}
// 真實後端:course/group 需要 userIDcourse/morning、noon、night 需要 group
// 兩者有相依順序,因此無法四支平行呼叫(與 doc/課程建議API規格.md 的示意圖不同,
// 以 doc/課程建議_API_前端使用說明_20260806.md 的建議測試流程為準)
const { userID } = useAppStore();
const groupValue = await fetchGroup(userID);
// 真實後端:course/group 由登入 Cookie 識別使用者;
// course/morning、noon、night 需要 group,兩者有相依順序。
const groupValue = await fetchGroup();
const [morningValue, noonValue, nightValue] = await Promise.all([
fetchMorning(groupValue),