models.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. export type ApiMethod = 'get' | 'post';
  2. export type PageKind =
  3. | 'home'
  4. | 'account'
  5. | 'article'
  6. | 'login'
  7. | 'resource'
  8. | 'form'
  9. | 'learning'
  10. | 'game'
  11. | 'product'
  12. | 'productList'
  13. | 'checkout'
  14. | 'order'
  15. | 'finance'
  16. | 'appointment'
  17. | 'courseCenter'
  18. | 'studyRecords'
  19. | 'team'
  20. | 'merchant'
  21. | 'webview'
  22. | 'support'
  23. | 'supportFeedback';
  24. export interface ApiEnvelope<T = unknown> {
  25. retcode: number;
  26. retmsg?: string;
  27. result: T;
  28. addon?: unknown;
  29. page?: {
  30. itemCount?: number;
  31. pageCount?: number;
  32. pageIndex?: number;
  33. pageSize?: number;
  34. [key: string]: unknown;
  35. };
  36. }
  37. export interface AppUser {
  38. userId: number;
  39. userName?: string;
  40. honeyName?: string;
  41. userFace?: string;
  42. mobile?: string;
  43. groupId?: number;
  44. groupName?: string;
  45. purse?: number;
  46. point?: number;
  47. silverCoin?: number;
  48. [key: string]: unknown;
  49. }
  50. export interface ApiBinding {
  51. action: string;
  52. method?: ApiMethod;
  53. params?: Record<string, string | number | boolean>;
  54. resultPath?: string;
  55. queryMap?: Record<string, string>;
  56. }
  57. export interface FormField {
  58. key: string;
  59. label: string;
  60. type?: 'text' | 'password' | 'tel' | 'number' | 'email' | 'textarea' | 'select' | 'date' | 'file' | 'checkbox';
  61. required?: boolean;
  62. placeholder?: string;
  63. options?: Array<{ label: string; value: string | number }>;
  64. }
  65. export interface PageAction {
  66. key?: string;
  67. label: string;
  68. action: string;
  69. method?: ApiMethod;
  70. tone?: 'primary' | 'danger' | 'quiet';
  71. confirm?: string;
  72. fields?: FormField[];
  73. scope?: 'page' | 'item';
  74. params?: Record<string, string | number | boolean>;
  75. when?: Record<string, string | number | boolean>;
  76. success?: 'reload' | 'remove-item' | 'none';
  77. }
  78. export interface PageMeta {
  79. path: string;
  80. title: string;
  81. domain: 'home' | 'shop' | 'learn' | 'history' | 'member' | 'support' | 'game' | 'system';
  82. kind: PageKind;
  83. auth?: boolean;
  84. hideHeader?: boolean;
  85. hideBack?: boolean;
  86. hideTabbar?: boolean;
  87. api?: ApiBinding;
  88. fields?: FormField[];
  89. saveAction?: string;
  90. deleteAction?: string;
  91. itemRoute?: string;
  92. queryKey?: string;
  93. emptyText?: string;
  94. description?: string;
  95. actions?: PageAction[];
  96. tabs?: string[];
  97. tabActions?: string[];
  98. tabParams?: Array<Record<string, string | number | boolean>>;
  99. onLoadActions?: ApiBinding[];
  100. }
  101. export interface NavItem {
  102. path: string;
  103. label: string;
  104. icon: string;
  105. roles?: number[];
  106. }