applicationConfigPlugin.ts 708 B

12345678910111213141516171819202122232425
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { useApplicationStore } from '#shared/stores/application.ts'
  3. import type { ConfigList } from '#shared/types/store.ts'
  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