diff --git a/src/api/customFetch.ts b/src/api/customFetch.ts index 85931ae..1659322 100644 --- a/src/api/customFetch.ts +++ b/src/api/customFetch.ts @@ -1,3 +1,5 @@ +import { useUserStore } from "@/store/user"; + /* * @Author: HideInMatrix * @Date: 2024-07-15 @@ -26,8 +28,11 @@ const apiClient = (method: HttpMethod) => { data?: unknown, options: FetchOptions = {} ): Promise => { + const userStore = useUserStore(); + const accessToken = userStore.getAccessToken const config: FetchOptions = { method, + headers:{ Authorization: `Bearer ${accessToken}`}, ...options, }; diff --git a/src/views/login.vue b/src/views/login.vue index 0bcf180..ac1a96c 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -1,7 +1,10 @@