From a2736a63855a9bde732a31d4848af34f5dd7bc0c Mon Sep 17 00:00:00 2001 From: Jeffrey Hsu Date: Wed, 18 Dec 2024 08:42:26 +0800 Subject: [PATCH] use nuxt plugin instead of function --- composables/network.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composables/network.ts b/composables/network.ts index 7388e16..984b7fb 100644 --- a/composables/network.ts +++ b/composables/network.ts @@ -2,6 +2,7 @@ import type { AsyncData, UseFetchOptions } from '#app' export function requestCore(url: string, options: UseFetchOptions) { // const config = useRuntimeConfig() + const {$mitt} = useNuxtApp() return useFetch(url, { baseURL: "https://cantyonion.site", retry: false, @@ -25,7 +26,7 @@ export function requestCore(url: string, options: UseFetchOptions) // } }, onResponseError({ response }) { - emitter.emit('eventBus', { + $mitt.emit('eventBus', { level: 'error', title: `HTTP错误:${response.status}`, message: response.statusText