Skip to content

Commit 23c9c32

Browse files
committed
feat(content): provide_key to Symbol
1 parent 7371c47 commit 23c9c32

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/context.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import type { App } from "vue";
1+
import type { App, InjectionKey } from "vue";
22
import { getCurrentInstance, inject } from "vue";
33

44
import type { AxiosInstance } from "axios";
55
import axios from "axios";
66

7-
export const AXIOS_USE_VUE_PROVIDE_KEY = "__axios_use_vue_config";
87
const INJECT_INSIDE_WARN_MSG =
98
"[@axios-use/vue warn]: getUseRequestConfig() can only be used inside setup() or functional components.";
109

@@ -13,6 +12,10 @@ export type RequestConfigType = {
1312
instance?: AxiosInstance;
1413
};
1514

15+
export const AXIOS_USE_VUE_PROVIDE_KEY = Symbol(
16+
"axios_use_vue_config",
17+
) as InjectionKey<RequestConfigType>;
18+
1619
export const setUseRequestConfig = (app: App, options?: RequestConfigType) => {
1720
const _version = Number(app.version.split(".")[0]);
1821
// for vue2
@@ -26,7 +29,7 @@ export const setUseRequestConfig = (app: App, options?: RequestConfigType) => {
2629
set: (v) => Object.assign(_cache, v),
2730
});
2831
}
29-
this._provided[AXIOS_USE_VUE_PROVIDE_KEY] = options;
32+
this._provided[AXIOS_USE_VUE_PROVIDE_KEY as any] = options;
3033
},
3134
});
3235
} else {

0 commit comments

Comments
 (0)