feat: update environment variables for development and production; add user store and authentication client
- Updated VITE_API_URL in .env.development to point to local server. - Retained VITE_API_URL in .env.production for production use. - Added user store for managing user profile and authentication state. - Created authentication client for handling user login and token management. - Introduced safeClient utility for making API requests with error handling. - Updated various components and views to utilize new user store and authentication logic. - Enhanced UI styles for better visual consistency across the application.
This commit is contained in:
@@ -2,6 +2,14 @@ import type { Router } from "vue-router";
|
||||
|
||||
export function createRouterGuard(router: Router) {
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const userStore = useUserStore();
|
||||
// if (to.meta.requiresAuth && !userStore.isAuthenticated) {
|
||||
// if (from.path === "/auth/login") {
|
||||
// return next("/");
|
||||
// }
|
||||
// const redirect = encodeURIComponent(to.fullPath);
|
||||
// return next({ path: "/auth/login", query: { redirect } });
|
||||
// }
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,18 +20,22 @@ const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: "home",
|
||||
component: () => import("@/views/home/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "service",
|
||||
component: () => import("@/views/service/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "product",
|
||||
component: () => import("@/views/product/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: "profile",
|
||||
component: () => import("@/views/profile/index.vue"),
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user