import { InjectionKey, provide, inject, reactive, readonly } from 'vue'; export const createContext = ( context: any, contextInjectKey: InjectionKey = Symbol(), _readonly = true ) => { const state = reactive({ ...context, }); const provideData = _readonly ? readonly(state) : state; provide(contextInjectKey, provideData); }; export const useContext = ( contextInjectKey: InjectionKey = Symbol(), defaultValue?: any, _readonly = true ): T => { const state = inject(contextInjectKey, defaultValue || {}); return _readonly ? readonly(state) : state; };