Skip to content

Commit

Permalink
fix: 使用 defineNuxtPlugin 包裹
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree committed Sep 12, 2024
1 parent deeed4e commit dfa2ae7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
7 changes: 3 additions & 4 deletions playground/app.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<template>
<div>
Nuxt module playground!
</div>
<div>{{ data?.toLocaleUpperCase() }} Nuxt module playground!</div>
</template>

<script setup>
<script setup lang="ts">
const { data } = await useFetch("/api/hello");
</script>
7 changes: 3 additions & 4 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default defineNuxtConfig({
modules: ['../src/module'],
myModule: {},
devtools: { enabled: true }
})
modules: ["../src/module"],
devtools: { enabled: true },
});
1 change: 1 addition & 0 deletions playground/server/api/hello.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default defineEventHandler(() => "hello");
5 changes: 3 additions & 2 deletions src/runtime/00.fetch.client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-nocheck
import destr from "destr";
import { defineNuxtPlugin } from "#app";

export interface ResponseMap {
blob: Blob;
Expand Down Expand Up @@ -43,7 +44,7 @@ export function detectResponseType(_contentType = ""): ResponseType {
return "blob";
}

export default () => {
export default defineNuxtPlugin(() => {
const nullBodyResponses = new Set([101, 204, 205, 304]);
const _fetch = globalThis.$fetch;
async function $$fetch(arg1, options = {}, ...rest) {
Expand Down Expand Up @@ -90,4 +91,4 @@ export default () => {
Object.keys(_fetch).forEach((key) => {
globalThis.$fetch[key] = _fetch[key];
});
};
});

0 comments on commit dfa2ae7

Please sign in to comment.