You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
504 B
19 lines
504 B
10 months ago
|
import { createRequest } from '@/utils/http'
|
||
|
|
||
|
export default defineNuxtPlugin(() => {
|
||
|
const request = createRequest()
|
||
|
//@ts-ignore 添加
|
||
|
globalThis.$request = request
|
||
|
|
||
|
const $fetchOriginal = globalThis.$fetch
|
||
|
const $fetch: any = (url: string, opts?: any) => {
|
||
|
opts = opts ?? {}
|
||
|
opts.url = url
|
||
|
return request.request(opts, opts.requestOptions)
|
||
|
}
|
||
|
$fetch.raw = $fetchOriginal.raw
|
||
|
$fetch.create = $fetchOriginal.create
|
||
|
//@ts-ignore 重写$fetch
|
||
|
globalThis.$fetch = $fetch
|
||
|
})
|