global.d.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import type {
  2. VNode,
  3. FunctionalComponent,
  4. PropType as VuePropType,
  5. ComponentPublicInstance
  6. } from "vue";
  7. import type { ECharts } from "echarts";
  8. import type { IconifyIcon } from "@iconify/vue";
  9. import type { TableColumns } from "@pureadmin/table";
  10. /**
  11. * 全局类型声明,无需引入直接在 `.vue` 、`.ts` 、`.tsx` 文件使用即可获得类型提示
  12. */
  13. declare global {
  14. /**
  15. * 平台的名称、版本、依赖、最后构建时间的类型提示
  16. */
  17. const __APP_INFO__: {
  18. pkg: {
  19. name: string;
  20. version: string;
  21. dependencies: Recordable<string>;
  22. devDependencies: Recordable<string>;
  23. };
  24. lastBuildTime: string;
  25. };
  26. /**
  27. * Window 的类型提示
  28. */
  29. interface Window {
  30. // Global vue app instance
  31. __APP__: App<Element>;
  32. webkitCancelAnimationFrame: (handle: number) => void;
  33. mozCancelAnimationFrame: (handle: number) => void;
  34. oCancelAnimationFrame: (handle: number) => void;
  35. msCancelAnimationFrame: (handle: number) => void;
  36. webkitRequestAnimationFrame: (callback: FrameRequestCallback) => number;
  37. mozRequestAnimationFrame: (callback: FrameRequestCallback) => number;
  38. oRequestAnimationFrame: (callback: FrameRequestCallback) => number;
  39. msRequestAnimationFrame: (callback: FrameRequestCallback) => number;
  40. }
  41. /**
  42. * 打包压缩格式的类型声明
  43. */
  44. type ViteCompression =
  45. | "none"
  46. | "gzip"
  47. | "brotli"
  48. | "both"
  49. | "gzip-clear"
  50. | "brotli-clear"
  51. | "both-clear";
  52. /**
  53. * 全局自定义环境变量的类型声明
  54. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#%E5%85%B7%E4%BD%93%E9%85%8D%E7%BD%AE}
  55. */
  56. interface ViteEnv {
  57. VITE_PORT: number;
  58. VITE_PUBLIC_PATH: string;
  59. VITE_ROUTER_HISTORY: string;
  60. VITE_CDN: boolean;
  61. VITE_HIDE_HOME: string;
  62. VITE_COMPRESSION: ViteCompression;
  63. }
  64. /**
  65. * 继承 `@pureadmin/table` 的 `TableColumns` ,方便全局直接调用
  66. */
  67. interface TableColumnList extends Array<TableColumns> {}
  68. /**
  69. * 对应 `public/serverConfig.json` 文件的类型声明
  70. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-json}
  71. */
  72. interface ServerConfigs {
  73. Version?: string;
  74. Title?: string;
  75. FixedHeader?: boolean;
  76. HiddenSideBar?: boolean;
  77. MultiTagsCache?: boolean;
  78. KeepAlive?: boolean;
  79. Locale?: string;
  80. Layout?: string;
  81. Theme?: string;
  82. DarkMode?: boolean;
  83. Grey?: boolean;
  84. Weak?: boolean;
  85. HideTabs?: boolean;
  86. SidebarStatus?: boolean;
  87. EpThemeColor?: string;
  88. ShowLogo?: boolean;
  89. ShowModel?: string;
  90. MenuArrowIconNoTransition?: boolean;
  91. CachingAsyncRoutes?: boolean;
  92. TooltipEffect?: Effect;
  93. ResponsiveStorageNameSpace?: string;
  94. }
  95. /**
  96. * 与 `ServerConfigs` 类型不同,这里是缓存到浏览器本地存储的类型声明
  97. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-json}
  98. */
  99. interface StorageConfigs {
  100. version?: string;
  101. title?: string;
  102. fixedHeader?: boolean;
  103. hiddenSideBar?: boolean;
  104. multiTagsCache?: boolean;
  105. keepAlive?: boolean;
  106. locale?: string;
  107. layout?: string;
  108. theme?: string;
  109. darkMode?: boolean;
  110. grey?: boolean;
  111. weak?: boolean;
  112. hideTabs?: boolean;
  113. sidebarStatus?: boolean;
  114. epThemeColor?: string;
  115. showLogo?: boolean;
  116. showModel?: string;
  117. username?: string;
  118. }
  119. /**
  120. * `responsive-storage` 本地响应式 `storage` 的类型声明
  121. */
  122. interface ResponsiveStorage {
  123. locale: {
  124. locale?: string;
  125. };
  126. layout: {
  127. layout?: string;
  128. theme?: string;
  129. darkMode?: boolean;
  130. sidebarStatus?: boolean;
  131. epThemeColor?: string;
  132. };
  133. configure: {
  134. grey?: boolean;
  135. weak?: boolean;
  136. hideTabs?: boolean;
  137. showLogo?: boolean;
  138. showModel?: string;
  139. multiTagsCache?: boolean;
  140. };
  141. tags?: Array<any>;
  142. }
  143. /**
  144. * 平台里所有组件实例都能访问到的全局属性对象的类型声明
  145. */
  146. interface GlobalPropertiesApi {
  147. $echarts: ECharts;
  148. $storage: ResponsiveStorage;
  149. $config: ServerConfigs;
  150. }
  151. }