system.d.ts 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. /** 请求的相关类型 */
  2. declare namespace Service {
  3. /**
  4. * 请求的错误类型:
  5. * - axios: axios错误:网络错误, 请求超时, 默认的兜底错误
  6. * - http: 请求成功,响应的http状态码非200的错误
  7. * - backend: 请求成功,响应的http状态码为200,由后端定义的业务错误
  8. */
  9. type RequestErrorType = 'axios' | 'http' | 'backend';
  10. /** 请求错误 */
  11. interface RequestError {
  12. /** 请求服务的错误类型 */
  13. type: RequestErrorType;
  14. /** 错误码 */
  15. code: string | number;
  16. /** 错误信息 */
  17. msg: string;
  18. }
  19. /** 后端接口返回的数据结构配置 */
  20. interface BackendResultConfig {
  21. /** 表示后端请求状态码的属性字段 */
  22. codeKey: string;
  23. /** 表示后端请求数据的属性字段 */
  24. dataKey: string;
  25. /** 表示后端消息的属性字段 */
  26. msgKey: string;
  27. /** 后端业务上定义的成功请求的状态 */
  28. successCode: boolean;
  29. }
  30. /** 自定义的请求成功结果 */
  31. interface SuccessResult<T = any> {
  32. /** 请求错误 */
  33. error: null;
  34. /** 请求数据 */
  35. data: T;
  36. }
  37. /** 自定义的请求失败结果 */
  38. interface FailedResult {
  39. /** 请求错误 */
  40. error: RequestError;
  41. /** 请求数据 */
  42. data: null;
  43. }
  44. /** 自定义的请求结果 */
  45. type RequestResult<T = any> = SuccessResult<T> | FailedResult;
  46. /** 多个请求数据结果 */
  47. type MultiRequestResult<T extends any[]> = T extends [infer First, ...infer Rest]
  48. ? [First] extends [any]
  49. ? Rest extends any[]
  50. ? [Service.RequestResult<First>, ...MultiRequestResult<Rest>]
  51. : [Service.RequestResult<First>]
  52. : Rest extends any[]
  53. ? MultiRequestResult<Rest>
  54. : []
  55. : [];
  56. /** 请求结果的适配器函数 */
  57. type ServiceAdapter<T = any, A extends any[] = any> = (...args: A) => T;
  58. /** mock示例接口类型:后端接口返回的数据的类型 */
  59. interface MockServiceResult<T = any> {
  60. /** 状态码 */
  61. code: string | number;
  62. /** 接口数据 */
  63. data: T;
  64. /** 接口消息 */
  65. message: string;
  66. }
  67. /** mock的响应option */
  68. interface MockOption {
  69. url: Record<string, any>;
  70. body: Record<string, any>;
  71. query: Record<string, any>;
  72. headers: Record<string, any>;
  73. }
  74. }
  75. /** 主题相关类型 */
  76. declare namespace Theme {
  77. /** 主题配置 */
  78. interface Setting {
  79. /** 暗黑模式 */
  80. darkMode: boolean;
  81. /** 是否自动跟随系统主题 */
  82. followSystemTheme: boolean;
  83. /** 布局样式 */
  84. layout: Layout;
  85. /** 滚动模式 */
  86. scrollMode: UnionKey.ThemeScrollMode;
  87. /** 滚动模式列表 */
  88. scrollModeList: Common.OptionWithKey<UnionKey.ThemeScrollMode>[];
  89. /** 主题颜色 */
  90. themeColor: string;
  91. /** 主题颜色列表 */
  92. themeColorList: string[];
  93. /** 其他颜色 */
  94. otherColor: OtherColor;
  95. /** 是否自定义info的颜色(默认取比主题色深一级的颜色) */
  96. isCustomizeInfoColor: boolean;
  97. /** 固定头部和多页签 */
  98. fixedHeaderAndTab: boolean;
  99. /** 显示重载按钮 */
  100. showReload: boolean;
  101. /** 头部样式 */
  102. header: Header;
  103. /** 标多页签样式 */
  104. tab: Tab;
  105. /** 侧边栏样式 */
  106. sider: Sider;
  107. /** 菜单样式 */
  108. menu: Menu;
  109. /** 底部样式 */
  110. footer: Footer;
  111. /** 页面样式 */
  112. page: Page;
  113. }
  114. /** 布局样式 */
  115. interface Layout {
  116. /** 最小宽度 */
  117. minWidth: number;
  118. /** 布局模式 */
  119. mode: UnionKey.ThemeLayoutMode;
  120. /** 布局模式列表 */
  121. modeList: Common.OptionWithKey<UnionKey.ThemeLayoutMode>[];
  122. }
  123. /** 其他主题颜色 */
  124. interface OtherColor {
  125. /** 信息 */
  126. info: string;
  127. /** 成功 */
  128. success: string;
  129. /** 警告 */
  130. warning: string;
  131. /** 错误 */
  132. error: string;
  133. }
  134. /** 头部样式 */
  135. interface Header {
  136. /** 头部反转色 */
  137. inverted: boolean;
  138. /** 头部高度 */
  139. height: number;
  140. /** 面包屑样式 */
  141. crumb: Crumb;
  142. }
  143. /** 面包屑样式 */
  144. interface Crumb {
  145. /** 面包屑可见 */
  146. visible: boolean;
  147. /** 显示图标 */
  148. showIcon: boolean;
  149. }
  150. /** 标多页签样式 */
  151. export interface Tab {
  152. /** 多页签可见 */
  153. visible: boolean;
  154. /** 多页签高度 */
  155. height: number;
  156. /** 多页签风格 */
  157. mode: UnionKey.ThemeTabMode;
  158. /** 多页签风格列表 */
  159. modeList: Common.OptionWithKey<UnionKey.ThemeTabMode>[];
  160. /** 开启多页签缓存 */
  161. isCache: boolean;
  162. }
  163. /** 侧边栏样式 */
  164. interface Sider {
  165. /** 侧边栏反转色 */
  166. inverted: boolean;
  167. /** 侧边栏宽度 */
  168. width: number;
  169. /** 侧边栏折叠时的宽度 */
  170. collapsedWidth: number;
  171. /** vertical-mix模式下侧边栏宽度 */
  172. mixWidth: number;
  173. /** vertical-mix模式下侧边栏折叠时的宽度 */
  174. mixCollapsedWidth: number;
  175. /** vertical-mix模式下侧边栏的子菜单的宽度 */
  176. mixChildMenuWidth: number;
  177. }
  178. /** 菜单样式 */
  179. interface Menu {
  180. /** 水平模式的菜单的位置 */
  181. horizontalPosition: UnionKey.ThemeHorizontalMenuPosition;
  182. /** 水平模式的菜单的位置列表 */
  183. horizontalPositionList: Common.OptionWithKey<UnionKey.ThemeHorizontalMenuPosition>[];
  184. }
  185. /** 底部样式 */
  186. interface Footer {
  187. /* 底部是否可见 */
  188. visible: boolean;
  189. /** 是否固定底部 */
  190. fixed: boolean;
  191. /** 底部是否居右(顶部混合菜单模式有效) */
  192. right: boolean;
  193. /** 底部高度 */
  194. height: number;
  195. /** 底部反转色 */
  196. inverted: boolean;
  197. }
  198. /** 页面样式 */
  199. interface Page {
  200. /** 页面是否开启动画 */
  201. animate: boolean;
  202. /** 动画类型 */
  203. animateMode: UnionKey.ThemeAnimateMode;
  204. /** 动画类型列表 */
  205. animateModeList: Common.OptionWithKey<UnionKey.ThemeAnimateMode>[];
  206. }
  207. }
  208. declare namespace App {
  209. /** 全局头部属性 */
  210. interface GlobalHeaderProps {
  211. /** 显示logo */
  212. showLogo: boolean;
  213. /** 显示头部菜单 */
  214. showHeaderMenu: boolean;
  215. /** 显示菜单折叠按钮 */
  216. showMenuCollapse: boolean;
  217. }
  218. /** 菜单项配置 */
  219. type GlobalMenuOption = import('naive-ui').MenuOption & {
  220. key: string;
  221. label: string;
  222. routeName: string;
  223. routePath: string;
  224. icon?: () => import('vue').VNodeChild;
  225. children?: GlobalMenuOption[];
  226. i18nTitle?: string;
  227. };
  228. /** 面包屑 */
  229. type GlobalBreadcrumb = Omit<import('naive-ui').DropdownOption, 'icon'> & {
  230. key: string;
  231. label: string;
  232. disabled: boolean;
  233. routeName: string;
  234. hasChildren: boolean;
  235. icon?: import('vue').Component;
  236. i18nTitle?: string;
  237. options?: import('naive-ui/es/dropdown/src/interface').DropdownMixedOption[];
  238. };
  239. /** 多页签Tab的路由 */
  240. interface GlobalTabRoute
  241. extends Pick<import('vue-router').RouteLocationNormalizedLoaded, 'name' | 'fullPath' | 'meta'> {
  242. /** 滚动的位置 */
  243. scrollPosition: {
  244. left: number;
  245. top: number;
  246. };
  247. }
  248. interface MessageTab {
  249. /** tab的key */
  250. key: number;
  251. /** tab名称 */
  252. name: string;
  253. /** badge类型 */
  254. badgeProps?: import('naive-ui').BadgeProps;
  255. /** 消息数据 */
  256. list: MessageList[];
  257. }
  258. interface MessageList {
  259. /** 数据唯一值 */
  260. id: number;
  261. /** 头像 */
  262. avatar?: string;
  263. /** 消息icon */
  264. icon?: string;
  265. svgIcon?: string;
  266. /** 消息标题 */
  267. title: string;
  268. /** 消息发送时间 */
  269. date?: string;
  270. /** 消息是否已读 */
  271. isRead?: boolean;
  272. /** 消息描述 */
  273. description?: string;
  274. /** 标签名称 */
  275. tagTitle?: string;
  276. /** 标签props */
  277. tagProps?: import('naive-ui').TagProps;
  278. }
  279. }
  280. declare namespace I18nType {
  281. type langType = 'en' | 'zh-CN';
  282. interface Schema {
  283. system: {
  284. title: string;
  285. };
  286. routes: {
  287. dashboard: {
  288. dashboard: string;
  289. analysis: string;
  290. workbench: string;
  291. };
  292. document: {
  293. _value: string;
  294. vue: string;
  295. vite: string;
  296. naive: string;
  297. project: string;
  298. 'project-link': string;
  299. };
  300. component: {
  301. _value: string;
  302. button: string;
  303. card: string;
  304. table: string;
  305. };
  306. plugin: {
  307. _value: string;
  308. charts: {
  309. _value: string;
  310. antv: string;
  311. echarts: string;
  312. };
  313. copy: string;
  314. editor: {
  315. _value: string;
  316. markdown: string;
  317. quill: string;
  318. };
  319. icon: string;
  320. map: string;
  321. print: string;
  322. swiper: string;
  323. video: string;
  324. };
  325. 'auth-demo': {
  326. _value: string;
  327. permission: string;
  328. super: string;
  329. };
  330. function: {
  331. _value: string;
  332. tab: string;
  333. };
  334. exception: {
  335. _value: string;
  336. 403: string;
  337. 404: string;
  338. 500: string;
  339. };
  340. 'multi-menu': {
  341. _value: string;
  342. first: {
  343. _value: string;
  344. second: string;
  345. 'second-new': {
  346. _value: string;
  347. third: string;
  348. };
  349. };
  350. };
  351. management: {
  352. _value: string;
  353. auth: string;
  354. role: string;
  355. route: string;
  356. user: string;
  357. };
  358. about: string;
  359. };
  360. }
  361. }