优化提现手续费动态配置
This commit is contained in:
@ -1,18 +1,20 @@
|
||||
import { useFetch } from '#app'
|
||||
import type { UseFetchOptions } from '#app'
|
||||
import { isArray } from '~/utils/utils'
|
||||
import useUserStore from '~/stores/user'
|
||||
|
||||
const useServerRequest = async <T>(url: string, opts?: UseFetchOptions<T, unknown>) => {
|
||||
const token = useToken()
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const defaultOptions: UseFetchOptions<unknown> = {
|
||||
baseURL: runtimeConfig.public.apiBase,
|
||||
onRequest({ options }) {
|
||||
options.headers = options.headers || {}
|
||||
|
||||
if (token.value) {
|
||||
options.headers.set('Authorization', `Bearer ${token.value}`)
|
||||
if (token.value || userStore.token) {
|
||||
options.headers.set('Authorization', `Bearer ${token.value || userStore.token}`)
|
||||
}
|
||||
},
|
||||
onResponse({ response }) {
|
||||
|
||||
Reference in New Issue
Block a user