global.d.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. * Document 的类型提示
  40. */
  41. interface Document {
  42. webkitFullscreenElement?: Element;
  43. mozFullScreenElement?: Element;
  44. msFullscreenElement?: Element;
  45. }
  46. /**
  47. * 打包压缩格式的类型声明
  48. */
  49. type ViteCompression =
  50. | "none"
  51. | "gzip"
  52. | "brotli"
  53. | "both"
  54. | "gzip-clear"
  55. | "brotli-clear"
  56. | "both-clear";
  57. /**
  58. * 全局自定义环境变量的类型声明
  59. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#%E5%85%B7%E4%BD%93%E9%85%8D%E7%BD%AE}
  60. */
  61. interface ViteEnv {
  62. VITE_PORT: number;
  63. VITE_PUBLIC_PATH: string;
  64. VITE_ROUTER_HISTORY: string;
  65. VITE_CDN: boolean;
  66. VITE_HIDE_HOME: string;
  67. VITE_COMPRESSION: ViteCompression;
  68. }
  69. /**
  70. * 继承 `@pureadmin/table` 的 `TableColumns` ,方便全局直接调用
  71. */
  72. interface TableColumnList extends Array<TableColumns> {}
  73. /**
  74. * 对应 `public/platform-config.json` 文件的类型声明
  75. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#platform-config-json}
  76. */
  77. interface PlatformConfigs {
  78. Version?: string;
  79. Title?: string;
  80. FixedHeader?: boolean;
  81. HiddenSideBar?: boolean;
  82. MultiTagsCache?: boolean;
  83. KeepAlive?: boolean;
  84. Locale?: string;
  85. Layout?: string;
  86. Theme?: string;
  87. DarkMode?: boolean;
  88. OverallStyle?: string;
  89. Grey?: boolean;
  90. Weak?: boolean;
  91. HideTabs?: boolean;
  92. HideFooter?: boolean;
  93. SidebarStatus?: boolean;
  94. EpThemeColor?: string;
  95. ShowLogo?: boolean;
  96. ShowModel?: string;
  97. MenuArrowIconNoTransition?: boolean;
  98. CachingAsyncRoutes?: boolean;
  99. TooltipEffect?: Effect;
  100. ResponsiveStorageNameSpace?: string;
  101. MenuSearchHistory?: number;
  102. MapConfigure?: {
  103. amapKey?: string;
  104. options: {
  105. resizeEnable?: boolean;
  106. center?: number[];
  107. zoom?: number;
  108. };
  109. };
  110. }
  111. /**
  112. * 与 `PlatformConfigs` 类型不同,这里是缓存到浏览器本地存储的类型声明
  113. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#platform-config-json}
  114. */
  115. interface StorageConfigs {
  116. version?: string;
  117. title?: string;
  118. fixedHeader?: boolean;
  119. hiddenSideBar?: boolean;
  120. multiTagsCache?: boolean;
  121. keepAlive?: boolean;
  122. locale?: string;
  123. layout?: string;
  124. theme?: string;
  125. darkMode?: boolean;
  126. grey?: boolean;
  127. weak?: boolean;
  128. hideTabs?: boolean;
  129. hideFooter?: boolean;
  130. sidebarStatus?: boolean;
  131. epThemeColor?: string;
  132. themeColor?: string;
  133. overallStyle?: string;
  134. showLogo?: boolean;
  135. showModel?: string;
  136. menuSearchHistory?: number;
  137. mapConfigure?: {
  138. amapKey?: string;
  139. options: {
  140. resizeEnable?: boolean;
  141. center?: number[];
  142. zoom?: number;
  143. };
  144. };
  145. username?: string;
  146. }
  147. /**
  148. * `responsive-storage` 本地响应式 `storage` 的类型声明
  149. */
  150. interface ResponsiveStorage {
  151. locale: {
  152. locale?: string;
  153. };
  154. layout: {
  155. layout?: string;
  156. theme?: string;
  157. darkMode?: boolean;
  158. sidebarStatus?: boolean;
  159. epThemeColor?: string;
  160. themeColor?: string;
  161. overallStyle?: string;
  162. };
  163. configure: {
  164. grey?: boolean;
  165. weak?: boolean;
  166. hideTabs?: boolean;
  167. hideFooter?: boolean;
  168. showLogo?: boolean;
  169. showModel?: string;
  170. multiTagsCache?: boolean;
  171. };
  172. tags?: Array<any>;
  173. }
  174. /**
  175. * 平台里所有组件实例都能访问到的全局属性对象的类型声明
  176. */
  177. interface GlobalPropertiesApi {
  178. $echarts: ECharts;
  179. $storage: ResponsiveStorage;
  180. $config: PlatformConfigs;
  181. }
  182. /**
  183. * 扩展 `Element`
  184. */
  185. interface Element {
  186. // v-ripple 作用于 src/directives/ripple/index.ts 文件
  187. _ripple?: {
  188. enabled?: boolean;
  189. centered?: boolean;
  190. class?: string;
  191. circle?: boolean;
  192. touched?: boolean;
  193. };
  194. }
  195. }