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. VITE_API_SERVER: string;
  64. }
  65. /**
  66. * 继承 `@pureadmin/table` 的 `TableColumns` ,方便全局直接调用
  67. */
  68. interface TableColumnList extends Array<TableColumns> {}
  69. /**
  70. * 对应 `public/serverConfig.json` 文件的类型声明
  71. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-json}
  72. */
  73. interface ServerConfigs {
  74. Version?: string;
  75. Title?: string;
  76. FixedHeader?: boolean;
  77. HiddenSideBar?: boolean;
  78. MultiTagsCache?: boolean;
  79. KeepAlive?: boolean;
  80. Locale?: string;
  81. Layout?: string;
  82. Theme?: string;
  83. DarkMode?: boolean;
  84. Grey?: boolean;
  85. Weak?: boolean;
  86. HideTabs?: boolean;
  87. SidebarStatus?: boolean;
  88. EpThemeColor?: string;
  89. ShowLogo?: boolean;
  90. ShowModel?: string;
  91. MenuArrowIconNoTransition?: boolean;
  92. CachingAsyncRoutes?: boolean;
  93. TooltipEffect?: Effect;
  94. ResponsiveStorageNameSpace?: string;
  95. }
  96. /**
  97. * 与 `ServerConfigs` 类型不同,这里是缓存到浏览器本地存储的类型声明
  98. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-json}
  99. */
  100. interface StorageConfigs {
  101. version?: string;
  102. title?: string;
  103. fixedHeader?: boolean;
  104. hiddenSideBar?: boolean;
  105. multiTagsCache?: boolean;
  106. keepAlive?: boolean;
  107. locale?: string;
  108. layout?: string;
  109. theme?: string;
  110. darkMode?: boolean;
  111. grey?: boolean;
  112. weak?: boolean;
  113. hideTabs?: boolean;
  114. sidebarStatus?: boolean;
  115. epThemeColor?: string;
  116. showLogo?: boolean;
  117. showModel?: string;
  118. username?: string;
  119. }
  120. /**
  121. * `responsive-storage` 本地响应式 `storage` 的类型声明
  122. */
  123. interface ResponsiveStorage {
  124. locale: {
  125. locale?: string;
  126. };
  127. layout: {
  128. layout?: string;
  129. theme?: string;
  130. darkMode?: boolean;
  131. sidebarStatus?: boolean;
  132. epThemeColor?: string;
  133. };
  134. configure: {
  135. grey?: boolean;
  136. weak?: boolean;
  137. hideTabs?: boolean;
  138. showLogo?: boolean;
  139. showModel?: string;
  140. multiTagsCache?: boolean;
  141. };
  142. tags?: Array<any>;
  143. }
  144. /**
  145. * 平台里所有组件实例都能访问到的全局属性对象的类型声明
  146. */
  147. interface GlobalPropertiesApi {
  148. $echarts: ECharts;
  149. $storage: ResponsiveStorage;
  150. $config: ServerConfigs;
  151. }
  152. }