honor-dialog.ts 540 B

1234567891011121314151617181920
  1. import { inject, InjectionKey } from 'vue'
  2. export interface DialogShowOptions {
  3. title: string
  4. content: string
  5. path: string
  6. image: string
  7. }
  8. export const HonorDialogSymbol: InjectionKey<{
  9. show: (options: DialogShowOptions) => void
  10. }> = Symbol.for('HonorDialogContext')
  11. export const useHonorDialog = () => {
  12. const honorDialog = inject(HonorDialogSymbol)
  13. // if (!honorDialog) {
  14. // throw new Error('useHonorDialog must be used inside setup()')
  15. // }
  16. const show = computed(() => honorDialog?.show)
  17. return {
  18. show,
  19. }
  20. }