global.d.ts 4.9 KB

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