global.d.ts 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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_HIDE_HOME: string;
  63. VITE_COMPRESSION: ViteCompression;
  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. MapConfigure?: {
  95. amapKey?: string;
  96. options: {
  97. resizeEnable?: boolean;
  98. center?: number[];
  99. zoom?: number;
  100. };
  101. };
  102. }
  103. /**
  104. * 与 `ServerConfigs` 类型不同,这里是缓存到浏览器本地存储的类型声明
  105. * @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-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. sidebarStatus?: boolean;
  122. epThemeColor?: string;
  123. showLogo?: boolean;
  124. showModel?: string;
  125. mapConfigure?: {
  126. amapKey?: string;
  127. options: {
  128. resizeEnable?: boolean;
  129. center?: number[];
  130. zoom?: number;
  131. };
  132. };
  133. username?: string;
  134. }
  135. /**
  136. * `responsive-storage` 本地响应式 `storage` 的类型声明
  137. */
  138. interface ResponsiveStorage {
  139. locale: {
  140. locale?: string;
  141. };
  142. layout: {
  143. layout?: string;
  144. theme?: string;
  145. darkMode?: boolean;
  146. sidebarStatus?: boolean;
  147. epThemeColor?: string;
  148. };
  149. configure: {
  150. grey?: boolean;
  151. weak?: boolean;
  152. hideTabs?: boolean;
  153. showLogo?: boolean;
  154. showModel?: string;
  155. multiTagsCache?: boolean;
  156. };
  157. tags?: Array<any>;
  158. }
  159. /**
  160. * `src/router` 文件夹里的类型声明
  161. */
  162. interface toRouteType extends RouteLocationNormalized {
  163. meta: {
  164. roles: Array<string>;
  165. keepAlive?: boolean;
  166. dynamicLevel?: string;
  167. };
  168. }
  169. /**
  170. * @description 完整子路由配置表
  171. */
  172. interface RouteChildrenConfigsTable {
  173. /** 子路由地址 `必填` */
  174. path: string;
  175. /** 路由名字(对应不要重复,和当前组件的`name`保持一致)`必填` */
  176. name?: string;
  177. /** 路由重定向 `可选` */
  178. redirect?: string;
  179. /** 按需加载组件 `可选` */
  180. component?: RouteComponent;
  181. meta?: {
  182. /** 菜单名称(兼容国际化、非国际化,如何用国际化的写法就必须在根目录的`locales`文件夹下对应添加) `必填` */
  183. title: string;
  184. /** 菜单图标 `可选` */
  185. icon?: string | FunctionalComponent | IconifyIcon;
  186. /** 菜单名称右侧的额外图标 */
  187. extraIcon?: string | FunctionalComponent | IconifyIcon;
  188. /** 是否在菜单中显示(默认`true`)`可选` */
  189. showLink?: boolean;
  190. /** 是否显示父级菜单 `可选` */
  191. showParent?: boolean;
  192. /** 页面级别权限设置 `可选` */
  193. roles?: Array<string>;
  194. /** 按钮级别权限设置 `可选` */
  195. auths?: Array<string>;
  196. /** 路由组件缓存(开启 `true`、关闭 `false`)`可选` */
  197. keepAlive?: boolean;
  198. /** 内嵌的`iframe`链接 `可选` */
  199. frameSrc?: string;
  200. /** `iframe`页是否开启首次加载动画(默认`true`)`可选` */
  201. frameLoading?: boolean;
  202. /** 页面加载动画(有两种形式,一种直接采用vue内置的`transitions`动画,另一种是使用`animate.css`写进、离场动画)`可选` */
  203. transition?: {
  204. /**
  205. * @description 当前路由动画效果
  206. * @see {@link https://next.router.vuejs.org/guide/advanced/transitions.html#transitions}
  207. * @see animate.css {@link https://animate.style}
  208. */
  209. name?: string;
  210. /** 进场动画 */
  211. enterTransition?: string;
  212. /** 离场动画 */
  213. leaveTransition?: string;
  214. };
  215. // 是否不添加信息到标签页,(默认`false`)
  216. hiddenTag?: boolean;
  217. /** 动态路由可打开的最大数量 `可选` */
  218. dynamicLevel?: number;
  219. };
  220. /** 子路由配置项 */
  221. children?: Array<RouteChildrenConfigsTable>;
  222. }
  223. /**
  224. * @description 整体路由配置表(包括完整子路由)
  225. */
  226. interface RouteConfigsTable {
  227. /** 路由地址 `必填` */
  228. path: string;
  229. /** 路由名字(保持唯一)`可选` */
  230. name?: string;
  231. /** `Layout`组件 `可选` */
  232. component?: RouteComponent;
  233. /** 路由重定向 `可选` */
  234. redirect?: string;
  235. meta?: {
  236. /** 菜单名称(兼容国际化、非国际化,如何用国际化的写法就必须在根目录的`locales`文件夹下对应添加)`必填` */
  237. title: string;
  238. /** 菜单图标 `可选` */
  239. icon?: string | FunctionalComponent | IconifyIcon;
  240. /** 是否在菜单中显示(默认`true`)`可选` */
  241. showLink?: boolean;
  242. /** 菜单升序排序,值越高排的越后(只针对顶级路由)`可选` */
  243. rank?: number;
  244. };
  245. /** 子路由配置项 */
  246. children?: Array<RouteChildrenConfigsTable>;
  247. }
  248. /**
  249. * 平台里所有组件实例都能访问到的全局属性对象的类型声明
  250. */
  251. interface GlobalPropertiesApi {
  252. $echarts: ECharts;
  253. $storage: ResponsiveStorage;
  254. $config: ServerConfigs;
  255. }
  256. }