vueHelper.ts 966 B

123456789101112131415161718192021222324252627282930
  1. import { App, Component } from 'vue';
  2. // import { IGlobalPopup } from '@/components/popup/types';
  3. // type GlobalPopupMethod = (component?: Component, options?: any) => IGlobalPopup;
  4. type GlobalPopoverMethod = (component?: Component, options?: any) => void;
  5. // export interface IGlobalProperties {
  6. // $popup: GlobalPopupMethod;
  7. // $popover: GlobalPopoverMethod;
  8. // [func: string]: any;
  9. // }
  10. let curApp: App;
  11. export function setGlobalApp(app: App): void {
  12. curApp = app;
  13. }
  14. export function getGlobal()/* : IGlobalProperties */ {
  15. if (!curApp) {
  16. throw new Error('没有正确注册全局app');
  17. }
  18. return curApp.config.globalProperties/* as IGlobalProperties */;
  19. }
  20. // export function createPopup<T = any>(component?: Component, options?: T): IGlobalPopup {
  21. // return getGlobal().$popup(component, options);
  22. // }
  23. export function createPopover<T = any>(component?: Component, options?: T): void {
  24. return getGlobal().$popover(component, options);
  25. }