Skip to content

Commit

Permalink
feat: 去除useHttp方法入参
Browse files Browse the repository at this point in the history
  • Loading branch information
gxmari007 committed Nov 8, 2023
1 parent 4f9ae60 commit 993d040
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ Find and replace all on all files (CMD+SHIFT+F):
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?file=playground%2Fapp.vue) -->
<!-- - [📖 &nbsp;Documentation](https://example.com) -->

## Features

<!-- Highlight some of the features your module provide here -->
-&nbsp;Foo
- 🚠 &nbsp;Bar
- 🌲 &nbsp;Baz

## 使用

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@roshan-labs/http",
"version": "0.0.1",
"description": "My new Nuxt module",
"repository": "your-org/my-module",
"description": "Nuxt module for http",
"repository": "https://github.com/roshan-labs/http",
"license": "MIT",
"type": "module",
"exports": {
Expand Down Expand Up @@ -52,4 +52,4 @@
"nuxt": "^3.7.4",
"vitest": "^0.33.0"
}
}
}
1 change: 0 additions & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default defineNuxtConfig({
ssr: false,
modules: ['../src/module'],
http: {},
devtools: { enabled: true },
Expand Down
8 changes: 2 additions & 6 deletions src/runtime/use-http.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { FetchOptions } from './types'
import { Http } from './http'
import { useRuntimeConfig, effectScope } from '#imports'

Expand All @@ -17,12 +16,9 @@ const createGlobalState = <F extends (...args: any[]) => any>(func: F): F => {
}) as F
}

export const useHttp = createGlobalState((options: FetchOptions = {}) => {
export const useHttp = createGlobalState(() => {
const config = useRuntimeConfig()
const http = new Http({
...config.public.http,
...options,
})
const http = new Http(config.public.http)

return http
})

0 comments on commit 993d040

Please sign in to comment.