applicationConfigPlugin.ts 710 B

123456789101112131415161718192021222324252627
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { storeToRefs } from 'pinia'
  3. import { unref } from 'vue'
  4. import { useApplicationStore } from '#shared/stores/application.ts'
  5. import type { ConfigList } from '#shared/types/store.ts'
  6. import type { App } from 'vue'
  7. declare module '@vue/runtime-core' {
  8. export interface ComponentCustomProperties {
  9. $c: ConfigList
  10. }
  11. }
  12. const applicationConfigPlugin = (app: App) => {
  13. const application = useApplicationStore()
  14. const { config } = storeToRefs(application)
  15. Object.defineProperty(app.config.globalProperties, '$c', {
  16. enumerable: true,
  17. get: () => unref(config),
  18. })
  19. }
  20. export default applicationConfigPlugin