module.d.ts 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import modal from '@/plugins/modal';
  2. import tab from '@/plugins/tab';
  3. import download from '@/plugins/download';
  4. import auth from '@/plugins/auth';
  5. import cache from '@/plugins/cache';
  6. import animate from '@/animate';
  7. import { useDict } from '@/utils/dict';
  8. import { handleTree, addDateRange, selectDictLabel, selectDictLabels, parseTime } from '@/utils/ruoyi';
  9. import { getConfigKey, updateConfigByKey } from '@/api/system/config';
  10. import { download as rd } from '@/utils/request';
  11. import type { LanguageType } from '@/lang';
  12. export {};
  13. declare module 'vue' {
  14. interface ComponentCustomProperties {
  15. // 全局方法声明
  16. $modal: typeof modal;
  17. $tab: typeof tab;
  18. $download: typeof download;
  19. $auth: typeof auth;
  20. $cache: typeof cache;
  21. animate: typeof animate;
  22. /**
  23. * i18n $t方法支持ts类型提示
  24. * @param key i18n key
  25. */
  26. $t(key: ObjKeysToUnion<LanguageType>): string;
  27. useDict: typeof useDict;
  28. addDateRange: typeof addDateRange;
  29. download: typeof rd;
  30. handleTree: typeof handleTree;
  31. getConfigKey: typeof getConfigKey;
  32. updateConfigByKey: typeof updateConfigByKey;
  33. selectDictLabel: typeof selectDictLabel;
  34. selectDictLabels: typeof selectDictLabels;
  35. parseTime: typeof parseTime;
  36. }
  37. }
  38. /**
  39. * { a: 1, b: { ba: { baa: 1, bab: 2 }, bb: 2} } ---> a | b.ba.baa | b.ba.bab | b.bb
  40. * https://juejin.cn/post/7280062870670606397
  41. */
  42. export type ObjKeysToUnion<T, P extends string = ''> = T extends object
  43. ? {
  44. [K in keyof T]: ObjKeysToUnion<T[K], P extends '' ? `${K & string}` : `${P}.${K & string}`>;
  45. }[keyof T]
  46. : P;