models.ts 2.4 KB

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