global.d.ts 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. import { type RouteComponent, type RouteLocationNormalized } from "vue-router";
  11. /**
  12. * 全局类型声明,无需引入直接在 `.vue` 、`.ts` 、`.tsx` 文件使用即可获得类型提示
  13. */
  14. declare global {
  15. /**
  16. * 平台的名称、版本、依赖、最后构建时间的类型提示
  17. */
  18. const __APP_INFO__: {
  19. pkg: {
  20. name: string;
  21. version: string;
  22. dependencies: Recordable<string>;
  23. devDependencies: Recordable<string>;
  24. };
  25. lastBuildTime: string;
  26. };
  27. /**
  28. * Window 的类型提示
  29. */
  30. interface Window {
  31. // Global vue app instance
  32. __APP__: App<Element>;
  33. webkitCancelAnimationFrame: (handle: number) => void;
  34. mozCancelAnimationFrame: (handle: number) => void;
  35. oCancelAnimationFrame: (handle: number) => void;
  36. msCancelAnimationFrame: (handle: number) => void;
  37. webkitRequestAnimationFrame: (callback: FrameRequestCallback) => number;
  38. mozRequestAnimationFrame: (callback: FrameRequestCallback) => number;
  39. oRequestAnimationFrame: (callback: FrameRequestCallback) => number;
  40. msRequestAnimationFrame: (callback: FrameRequestCallback) => number;
  41. }
  42. /**
  43. * 打包压缩格式的类型声明
  44. */
  45. type ViteCompression =
  46. | "none"
  47. | "gzip"
  48. | "brotli"
  49. | "both"
  50. | "gzip-clear"
  51. | "brotli-clear"
  52. | "both-clear";
  53. /**
  54. * 全局自定义环境变量的类型声明
  55. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#%E5%85%B7%E4%BD%93%E9%85%8D%E7%BD%AE}
  56. */
  57. interface ViteEnv {
  58. VITE_PORT: number;
  59. VITE_PUBLIC_PATH: string;
  60. VITE_ROUTER_HISTORY: string;
  61. VITE_CDN: boolean;
  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. MapConfigure?: {
  94. amapKey?: string;
  95. options: {
  96. resizeEnable?: boolean;
  97. center?: number[];
  98. zoom?: number;
  99. };
  100. };
  101. }
  102. /**
  103. * 与 `ServerConfigs` 类型不同,这里是缓存到浏览器本地存储的类型声明
  104. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-json}
  105. */
  106. interface StorageConfigs {
  107. version?: string;
  108. title?: string;
  109. fixedHeader?: boolean;
  110. hiddenSideBar?: boolean;
  111. multiTagsCache?: boolean;
  112. keepAlive?: boolean;
  113. locale?: string;
  114. layout?: string;
  115. theme?: string;
  116. darkMode?: boolean;
  117. grey?: boolean;
  118. weak?: boolean;
  119. hideTabs?: boolean;
  120. sidebarStatus?: boolean;
  121. epThemeColor?: string;
  122. showLogo?: boolean;
  123. showModel?: string;
  124. mapConfigure?: {
  125. amapKey?: string;
  126. options: {
  127. resizeEnable?: boolean;
  128. center?: number[];
  129. zoom?: number;
  130. };
  131. };
  132. username?: string;
  133. }
  134. /**
  135. * `responsive-storage` 本地响应式 `storage` 的类型声明
  136. */
  137. interface ResponsiveStorage {
  138. locale: {
  139. locale?: string;
  140. };
  141. layout: {
  142. layout?: string;
  143. theme?: string;
  144. darkMode?: boolean;
  145. sidebarStatus?: boolean;
  146. epThemeColor?: string;
  147. };
  148. configure: {
  149. grey?: boolean;
  150. weak?: boolean;
  151. hideTabs?: boolean;
  152. showLogo?: boolean;
  153. showModel?: string;
  154. multiTagsCache?: boolean;
  155. };
  156. tags?: Array<any>;
  157. }
  158. /**
  159. * `src/router` 文件夹里的类型声明
  160. */
  161. interface toRouteType extends RouteLocationNormalized {
  162. meta: {
  163. roles: Array<string>;
  164. keepAlive?: boolean;
  165. dynamicLevel?: string;
  166. };
  167. }
  168. /**
  169. * @description 完整子路由配置表
  170. */
  171. interface RouteChildrenConfigsTable {
  172. /** 子路由地址 `必填` */
  173. path: string;
  174. /** 路由名字(对应不要重复,和当前组件的`name`保持一致)`必填` */
  175. name?: string;
  176. /** 路由重定向 `可选` */
  177. redirect?: string;
  178. /** 按需加载组件 `可选` */
  179. component?: RouteComponent;
  180. meta?: {
  181. /** 菜单名称(兼容国际化、非国际化,如何用国际化的写法就必须在根目录的`locales`文件夹下对应添加) `必填` */
  182. title: string;
  183. /** 菜单图标 `可选` */
  184. icon?: string | FunctionalComponent | IconifyIcon;
  185. /** 菜单名称右侧的额外图标 */
  186. extraIcon?: string | FunctionalComponent | IconifyIcon;
  187. /** 是否在菜单中显示(默认`true`)`可选` */
  188. showLink?: boolean;
  189. /** 是否显示父级菜单 `可选` */
  190. showParent?: boolean;
  191. /** 页面级别权限设置 `可选` */
  192. roles?: Array<string>;
  193. /** 按钮级别权限设置 `可选` */
  194. auths?: Array<string>;
  195. /** 路由组件缓存(开启 `true`、关闭 `false`)`可选` */
  196. keepAlive?: boolean;
  197. /** 内嵌的`iframe`链接 `可选` */
  198. frameSrc?: string;
  199. /** `iframe`页是否开启首次加载动画(默认`true`)`可选` */
  200. frameLoading?: boolean;
  201. /** 页面加载动画(有两种形式,一种直接采用vue内置的`transitions`动画,另一种是使用`animate.css`写进、离场动画)`可选` */
  202. transition?: {
  203. /**
  204. * @description 当前路由动画效果
  205. * @see {@link https://next.router.vuejs.org/guide/advanced/transitions.html#transitions}
  206. * @see animate.css {@link https://animate.style}
  207. */
  208. name?: string;
  209. /** 进场动画 */
  210. enterTransition?: string;
  211. /** 离场动画 */
  212. leaveTransition?: string;
  213. };
  214. // 是否不添加信息到标签页,(默认`false`)
  215. hiddenTag?: boolean;
  216. /** 动态路由可打开的最大数量 `可选` */
  217. dynamicLevel?: number;
  218. };
  219. /** 子路由配置项 */
  220. children?: Array<RouteChildrenConfigsTable>;
  221. }
  222. /**
  223. * @description 整体路由配置表(包括完整子路由)
  224. */
  225. interface RouteConfigsTable {
  226. /** 路由地址 `必填` */
  227. path: string;
  228. /** 路由名字(保持唯一)`可选` */
  229. name?: string;
  230. /** `Layout`组件 `可选` */
  231. component?: RouteComponent;
  232. /** 路由重定向 `可选` */
  233. redirect?: string;
  234. meta?: {
  235. /** 菜单名称(兼容国际化、非国际化,如何用国际化的写法就必须在根目录的`locales`文件夹下对应添加)`必填` */
  236. title: string;
  237. /** 菜单图标 `可选` */
  238. icon?: string | FunctionalComponent | IconifyIcon;
  239. /** 是否在菜单中显示(默认`true`)`可选` */
  240. showLink?: boolean;
  241. /** 菜单升序排序,值越高排的越后(只针对顶级路由)`可选` */
  242. rank?: number;
  243. };
  244. /** 子路由配置项 */
  245. children?: Array<RouteChildrenConfigsTable>;
  246. }
  247. /**
  248. * 平台里所有组件实例都能访问到的全局属性对象的类型声明
  249. */
  250. interface GlobalPropertiesApi {
  251. $echarts: ECharts;
  252. $storage: ResponsiveStorage;
  253. $config: ServerConfigs;
  254. }
  255. }