import type { InjectionKey } from 'vue' /** 创建共享上下文状态 */ export default function useContext(contextName = 'context') { const injectKey: InjectionKey = Symbol(contextName) function useProvide(context: T) { provide(injectKey, context) } function useInject() { return inject(injectKey) as T } return { useProvide, useInject } }