feat: feature switch
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user