feat: feature switch

This commit is contained in:
skytek_xinliang
2026-09-14 09:35:56 +08:00
parent a6042b993a
commit bcaaf8797c
7 changed files with 41 additions and 13 deletions
+11
View File
@@ -9,6 +9,7 @@ import Login from "@/pages/login.vue";
import Profile from "@/pages/profile.vue";
import Register from "@/pages/register.vue";
import SelfAssessment from "@/pages/self-assessment.vue";
import { APPOINTMENT_ENABLED, CHECKIN_ENABLED } from "@/config/features";
import { useAppStore } from "@/stores/app";
import { useCourseStore } from "@/stores/course";
import { getApiErrorStatus } from "@/utils/api-error";
@@ -83,8 +84,18 @@ const router = createRouter({
],
});
const APPOINTMENT_PATH = /^\/appointment(?:\/|$)/;
const CHECKIN_PATH = /^\/checkin(?:\/|$)/;
// 簡單的導航守衛:只有標記需要登入的頁面會導向登入頁
router.beforeEach(async (to) => {
if (
(!APPOINTMENT_ENABLED && APPOINTMENT_PATH.test(to.path)) ||
(!CHECKIN_ENABLED && CHECKIN_PATH.test(to.path))
) {
return { name: "home" };
}
const store = useAppStore();
await store.initializeAuthentication();