global.d.ts 7.8 KB

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