| | |
| | | /* eslint-disable no-param-reassign */ |
| | | import qs from 'qs' |
| | | import { useUserStore } from '@/store' |
| | | import { useAccessStore } from '@/store' |
| | | import { platform } from '@/utils/platform' |
| | | import { getEnvBaseUrl } from '@/utils' |
| | | const clientId = import.meta.env.VITE_APP_CLIENT_ID |
| | | |
| | | export type CustomRequestOptions = UniApp.RequestOptions & { |
| | | query?: Record<string, any> |
| | |
| | | ...options.header, |
| | | } |
| | | // 3. 添加 token 请求头标识 |
| | | const userStore = useUserStore() |
| | | const { token } = userStore.userInfo as unknown as IUserInfo |
| | | const accessStore = useAccessStore() |
| | | const token = accessStore.accessInfo.access_token |
| | | if (token) { |
| | | options.header.Authorization = `Bearer ${token}` |
| | | options.header.clientid = clientId |
| | | } |
| | | }, |
| | | } |