context.js 665 B

1234567891011121314151617181920
  1. import { provide, inject, reactive } from 'vue';
  2. export const AppConfigContextKey = Symbol('appConfigContext');
  3. export const useProvideAppConfigContext = appConfigContext => {
  4. return provide(AppConfigContextKey, appConfigContext);
  5. };
  6. export const useInjectAppConfigContext = () => {
  7. return inject(AppConfigContextKey, {});
  8. };
  9. export const AppContextKey = Symbol('appContext');
  10. export const useProvideAppContext = appContext => {
  11. return provide(AppContextKey, appContext);
  12. };
  13. const defaultAppContext = reactive({
  14. message: {},
  15. notification: {},
  16. modal: {}
  17. });
  18. export const useInjectAppContext = () => {
  19. return inject(AppContextKey, defaultAppContext);
  20. };