applicationConfigPlugin.ts 702 B

12345678910111213141516171819202122232425
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import { useApplicationStore } from '@shared/stores/application'
  3. import type { ConfigList } from '@shared/types/store'
  4. import { storeToRefs } from 'pinia'
  5. import type { App } from 'vue'
  6. import { unref } 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