use nuxt plugin instead of function
This commit is contained in:
parent
7efa425c85
commit
a2736a6385
@ -2,6 +2,7 @@ import type { AsyncData, UseFetchOptions } from '#app'
|
|||||||
|
|
||||||
export function requestCore<DataT>(url: string, options: UseFetchOptions<DataT>) {
|
export function requestCore<DataT>(url: string, options: UseFetchOptions<DataT>) {
|
||||||
// const config = useRuntimeConfig()
|
// const config = useRuntimeConfig()
|
||||||
|
const {$mitt} = useNuxtApp()
|
||||||
return useFetch(url, {
|
return useFetch(url, {
|
||||||
baseURL: "https://cantyonion.site",
|
baseURL: "https://cantyonion.site",
|
||||||
retry: false,
|
retry: false,
|
||||||
@ -25,7 +26,7 @@ export function requestCore<DataT>(url: string, options: UseFetchOptions<DataT>)
|
|||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
onResponseError({ response }) {
|
onResponseError({ response }) {
|
||||||
emitter.emit('eventBus', {
|
$mitt.emit('eventBus', {
|
||||||
level: 'error',
|
level: 'error',
|
||||||
title: `HTTP错误:${response.status}`,
|
title: `HTTP错误:${response.status}`,
|
||||||
message: response.statusText
|
message: response.statusText
|
||||||
|
Loading…
x
Reference in New Issue
Block a user