From 23c9c32f3b06e3b3b71481243a9ba3e6ce295a11 Mon Sep 17 00:00:00 2001 From: wangcch Date: Sat, 8 Apr 2023 20:21:21 +0800 Subject: [PATCH] feat(content): provide_key to Symbol --- src/context.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/context.ts b/src/context.ts index 5234235..6d80610 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,10 +1,9 @@ -import type { App } from "vue"; +import type { App, InjectionKey } from "vue"; import { getCurrentInstance, inject } from "vue"; import type { AxiosInstance } from "axios"; import axios from "axios"; -export const AXIOS_USE_VUE_PROVIDE_KEY = "__axios_use_vue_config"; const INJECT_INSIDE_WARN_MSG = "[@axios-use/vue warn]: getUseRequestConfig() can only be used inside setup() or functional components."; @@ -13,6 +12,10 @@ export type RequestConfigType = { instance?: AxiosInstance; }; +export const AXIOS_USE_VUE_PROVIDE_KEY = Symbol( + "axios_use_vue_config", +) as InjectionKey; + export const setUseRequestConfig = (app: App, options?: RequestConfigType) => { const _version = Number(app.version.split(".")[0]); // for vue2 @@ -26,7 +29,7 @@ export const setUseRequestConfig = (app: App, options?: RequestConfigType) => { set: (v) => Object.assign(_cache, v), }); } - this._provided[AXIOS_USE_VUE_PROVIDE_KEY] = options; + this._provided[AXIOS_USE_VUE_PROVIDE_KEY as any] = options; }, }); } else {