system.d.ts 9.4 KB

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