@fecommunity/reactpress-toolkit 1.0.0-beta.2 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +221 -6
  2. package/dist/api/Article.d.ts +43 -28
  3. package/dist/api/Article.js +42 -31
  4. package/dist/api/Auth.d.ts +12 -7
  5. package/dist/api/Auth.js +12 -10
  6. package/dist/api/Category.d.ts +19 -12
  7. package/dist/api/Category.js +18 -15
  8. package/dist/api/Comment.d.ts +22 -14
  9. package/dist/api/Comment.js +21 -17
  10. package/dist/api/File.d.ts +16 -10
  11. package/dist/api/File.js +15 -13
  12. package/dist/{HttpClient.d.ts → api/HttpClient.d.ts} +2 -2
  13. package/dist/{HttpClient.js → api/HttpClient.js} +4 -2
  14. package/dist/api/Knowledge.d.ts +28 -18
  15. package/dist/api/Knowledge.js +27 -22
  16. package/dist/api/Page.d.ts +22 -14
  17. package/dist/api/Page.js +21 -17
  18. package/dist/api/Search.d.ts +12 -7
  19. package/dist/api/Search.js +12 -10
  20. package/dist/api/Setting.d.ts +10 -6
  21. package/dist/api/Setting.js +9 -9
  22. package/dist/api/Smtp.d.ts +13 -8
  23. package/dist/api/Smtp.js +12 -11
  24. package/dist/api/Tag.d.ts +22 -14
  25. package/dist/api/Tag.js +21 -17
  26. package/dist/api/User.d.ts +17 -10
  27. package/dist/api/User.js +16 -16
  28. package/dist/api/View.d.ts +19 -12
  29. package/dist/api/View.js +18 -15
  30. package/dist/api/index.d.ts +13 -18
  31. package/dist/api/index.js +28 -40
  32. package/dist/api/instance.d.ts +47 -0
  33. package/dist/api/instance.js +71 -0
  34. package/dist/config/env.d.ts +1 -0
  35. package/dist/config/env.js +93 -0
  36. package/dist/config/global.d.ts +34 -0
  37. package/dist/config/global.js +382 -0
  38. package/dist/config/i18n.d.ts +5 -0
  39. package/dist/config/i18n.js +47 -0
  40. package/dist/config/index.d.ts +14 -0
  41. package/dist/config/index.js +30 -0
  42. package/dist/index.d.ts +7 -4
  43. package/dist/index.js +21 -18
  44. package/dist/locales/en.json +97 -0
  45. package/dist/locales/zh.json +97 -0
  46. package/dist/types/index.d.ts +245 -1
  47. package/dist/types/index.js +10 -17
  48. package/dist/utils/index.d.ts +33 -2
  49. package/dist/utils/index.js +57 -18
  50. package/package.json +12 -5
  51. package/dist/Article.d.ts +0 -121
  52. package/dist/Article.js +0 -189
  53. package/dist/Auth.d.ts +0 -30
  54. package/dist/Auth.js +0 -59
  55. package/dist/Category.d.ts +0 -49
  56. package/dist/Category.js +0 -85
  57. package/dist/Comment.d.ts +0 -58
  58. package/dist/Comment.js +0 -98
  59. package/dist/File.d.ts +0 -40
  60. package/dist/File.js +0 -72
  61. package/dist/Knowledge.d.ts +0 -76
  62. package/dist/Knowledge.js +0 -124
  63. package/dist/Page.d.ts +0 -58
  64. package/dist/Page.js +0 -98
  65. package/dist/Search.d.ts +0 -30
  66. package/dist/Search.js +0 -59
  67. package/dist/Setting.d.ts +0 -22
  68. package/dist/Setting.js +0 -46
  69. package/dist/Smtp.d.ts +0 -31
  70. package/dist/Smtp.js +0 -59
  71. package/dist/Tag.d.ts +0 -58
  72. package/dist/Tag.js +0 -98
  73. package/dist/User.d.ts +0 -41
  74. package/dist/User.js +0 -73
  75. package/dist/View.d.ts +0 -49
  76. package/dist/View.js +0 -85
  77. package/dist/api/Admin.d.ts +0 -14
  78. package/dist/api/Admin.js +0 -32
  79. package/dist/api/All.d.ts +0 -14
  80. package/dist/api/All.js +0 -32
  81. package/dist/api/ApiInstance.d.ts +0 -39
  82. package/dist/api/ApiInstance.js +0 -46
  83. package/dist/api/Archives.d.ts +0 -14
  84. package/dist/api/Archives.js +0 -32
  85. package/dist/api/ArticleRoute.d.ts +0 -201
  86. package/dist/api/ArticleRoute.js +0 -12
  87. package/dist/api/AuthRoute.d.ts +0 -44
  88. package/dist/api/AuthRoute.js +0 -12
  89. package/dist/api/Book.d.ts +0 -15
  90. package/dist/api/Book.js +0 -33
  91. package/dist/api/CategoryRoute.d.ts +0 -79
  92. package/dist/api/CategoryRoute.js +0 -12
  93. package/dist/api/Chapter.d.ts +0 -15
  94. package/dist/api/Chapter.js +0 -33
  95. package/dist/api/CommentRoute.d.ts +0 -95
  96. package/dist/api/CommentRoute.js +0 -12
  97. package/dist/api/FileRoute.d.ts +0 -63
  98. package/dist/api/FileRoute.js +0 -12
  99. package/dist/api/Get.d.ts +0 -14
  100. package/dist/api/Get.js +0 -32
  101. package/dist/api/Github.d.ts +0 -14
  102. package/dist/api/Github.js +0 -32
  103. package/dist/api/Host.d.ts +0 -14
  104. package/dist/api/Host.js +0 -32
  105. package/dist/api/Id.d.ts +0 -284
  106. package/dist/api/Id.js +0 -422
  107. package/dist/api/KnowledgeRoute.d.ts +0 -125
  108. package/dist/api/KnowledgeRoute.js +0 -12
  109. package/dist/api/Login.d.ts +0 -14
  110. package/dist/api/Login.js +0 -32
  111. package/dist/api/PageRoute.d.ts +0 -95
  112. package/dist/api/PageRoute.js +0 -12
  113. package/dist/api/Password.d.ts +0 -15
  114. package/dist/api/Password.js +0 -33
  115. package/dist/api/Recommend.d.ts +0 -14
  116. package/dist/api/Recommend.js +0 -32
  117. package/dist/api/Register.d.ts +0 -15
  118. package/dist/api/Register.js +0 -33
  119. package/dist/api/SearchRoute.d.ts +0 -46
  120. package/dist/api/SearchRoute.js +0 -12
  121. package/dist/api/SettingRoute.d.ts +0 -31
  122. package/dist/api/SettingRoute.js +0 -12
  123. package/dist/api/SmtpRoute.d.ts +0 -47
  124. package/dist/api/SmtpRoute.js +0 -12
  125. package/dist/api/TagRoute.d.ts +0 -95
  126. package/dist/api/TagRoute.js +0 -12
  127. package/dist/api/Update.d.ts +0 -15
  128. package/dist/api/Update.js +0 -33
  129. package/dist/api/Upload.d.ts +0 -15
  130. package/dist/api/Upload.js +0 -33
  131. package/dist/api/Url.d.ts +0 -14
  132. package/dist/api/Url.js +0 -32
  133. package/dist/api/UserRoute.d.ts +0 -60
  134. package/dist/api/UserRoute.js +0 -12
  135. package/dist/api/ViewRoute.d.ts +0 -77
  136. package/dist/api/ViewRoute.js +0 -12
  137. package/dist/api/api-instance.d.ts +0 -39
  138. package/dist/api/api-instance.js +0 -46
  139. package/dist/api/http-client.d.ts +0 -41
  140. package/dist/api/http-client.js +0 -94
  141. package/dist/api/httpClient.d.ts +0 -42
  142. package/dist/api/httpClient.js +0 -95
  143. package/dist/data-contracts.d.ts +0 -245
  144. package/dist/data-contracts.js +0 -12
  145. package/dist/types/data-contracts.d.ts +0 -177
  146. package/dist/types/data-contracts.js +0 -12
  147. package/dist/utils/common.d.ts +0 -21
  148. package/dist/utils/common.js +0 -52
  149. package/dist/utils/http.d.ts +0 -3
  150. package/dist/utils/http.js +0 -45
@@ -1,245 +0,0 @@
1
- export interface IUser {
2
- name: string;
3
- password: string;
4
- avatar: string;
5
- email: string;
6
- role: string;
7
- status: string;
8
- type: string;
9
- /** @format date-time */
10
- createAt: string;
11
- /** @format date-time */
12
- updateAt: string;
13
- }
14
- export interface ISetting {
15
- id: string;
16
- i18n: string;
17
- globalSetting: string;
18
- systemUrl: string;
19
- systemTitle: string;
20
- systemSubTitle: string;
21
- systemLogo: string;
22
- systemBg: string;
23
- systemFavicon: string;
24
- systemNoticeInfo: string;
25
- systemFooterInfo: string;
26
- adminSystemUrl: string;
27
- baiduAnalyticsId: string;
28
- googleAnalyticsId: string;
29
- seoKeyword: string;
30
- seoDesc: string;
31
- oss: string;
32
- smtpHost: string;
33
- smtpPort: string;
34
- smtpUser: string;
35
- smtpPass: string;
36
- smtpFromUser: string;
37
- /** @format date-time */
38
- createAt: string;
39
- /** @format date-time */
40
- updateAt: string;
41
- }
42
- export interface I_SMTP {
43
- id: string;
44
- from: string;
45
- to: string;
46
- subject: string;
47
- text: string;
48
- html: string;
49
- /** @format date-time */
50
- createAt: string;
51
- }
52
- export interface IFile {
53
- id: string;
54
- originalname: string;
55
- filename: string;
56
- type: string;
57
- size: number;
58
- url: string;
59
- /** @format date-time */
60
- createAt: string;
61
- }
62
- export interface ITag {
63
- label: string;
64
- value: string;
65
- articles: string[];
66
- /** @format date-time */
67
- createAt: string;
68
- /** @format date-time */
69
- updateAt: string;
70
- }
71
- export interface ICategory {
72
- id: string;
73
- label: string;
74
- value: string;
75
- articles: string[];
76
- /** @format date-time */
77
- createAt: string;
78
- /** @format date-time */
79
- updateAt: string;
80
- }
81
- export interface IArticle {
82
- id: string;
83
- title: string;
84
- cover: string;
85
- summary: string;
86
- content: string;
87
- html: string;
88
- toc: string;
89
- category: ICategory;
90
- tags: string[];
91
- status: string;
92
- views: number;
93
- likes: number;
94
- isRecommended: boolean;
95
- password: string;
96
- needPassword: boolean;
97
- isCommentable: boolean;
98
- /** @format date-time */
99
- publishAt: string;
100
- /** @format date-time */
101
- createAt: string;
102
- /** @format date-time */
103
- updateAt: string;
104
- }
105
- export interface IKnowledge {
106
- id: string;
107
- parentId: string;
108
- order: number;
109
- title: string;
110
- cover: string;
111
- summary: string;
112
- content: string;
113
- html: string;
114
- toc: string;
115
- status: string;
116
- views: number;
117
- likes: number;
118
- isCommentable: boolean;
119
- /** @format date-time */
120
- publishAt: string;
121
- /** @format date-time */
122
- createAt: string;
123
- /** @format date-time */
124
- updateAt: string;
125
- }
126
- export interface IComment {
127
- id: string;
128
- name: string;
129
- email: string;
130
- avatar: string;
131
- content: string;
132
- html: string;
133
- pass: boolean;
134
- userAgent: string;
135
- hostId: string;
136
- url: string;
137
- parentCommentId: string;
138
- replyUserName: string;
139
- replyUserEmail: string;
140
- /** @format date-time */
141
- createAt: string;
142
- /** @format date-time */
143
- updateAt: string;
144
- }
145
- export interface IPage {
146
- id: string;
147
- cover: string;
148
- name: string;
149
- path: string;
150
- order: number;
151
- content: string;
152
- html: string;
153
- toc: string;
154
- status: string;
155
- /** @format date-time */
156
- publishAt: string;
157
- views: number;
158
- /** @format date-time */
159
- createAt: string;
160
- /** @format date-time */
161
- updateAt: string;
162
- }
163
- export interface IView {
164
- ip: string;
165
- userAgent: string;
166
- url: string;
167
- count: number;
168
- address: string;
169
- browser: string;
170
- engine: string;
171
- os: string;
172
- device: string;
173
- /** @format date-time */
174
- createAt: string;
175
- /** @format date-time */
176
- updateAt: string;
177
- }
178
- export declare type IUserControllerFindAllData = IUser[];
179
- export declare type IUserControllerRegisterData = IUser[];
180
- export declare type IUserControllerUpdateData = IUser[];
181
- export declare type IUserControllerUpdatePasswordData = IUser[];
182
- export declare type IAuthControllerLoginData = any;
183
- export declare type IAuthControllerCreateBookData = any;
184
- export declare type IAuthControllerLoginWithGithubData = any;
185
- export declare type ISettingControllerUpdateData = ISetting[];
186
- export declare type ISettingControllerFindAllData = any;
187
- export declare type ISmtpControllerCreateData = I_SMTP[];
188
- export declare type ISmtpControllerFindAllData = any;
189
- export declare type ISmtpControllerDeleteByIdData = any;
190
- export declare type IFileControllerUploadFileData = IFile[];
191
- export declare type IFileControllerFindAllData = any;
192
- export declare type IFileControllerFindByIdData = any;
193
- export declare type IFileControllerDeleteByIdData = any;
194
- export declare type ITagControllerCreateData = ITag[];
195
- export declare type ITagControllerFindAllData = any;
196
- export declare type ITagControllerFindByIdData = any;
197
- export declare type ITagControllerUpdateByIdData = any;
198
- export declare type ITagControllerDeleteByIdData = any;
199
- export declare type ITagControllerGetArticleByIdData = any;
200
- export declare type IArticleControllerCreateData = IArticle[];
201
- export declare type IArticleControllerFindAllData = any;
202
- export declare type IArticleControllerFindArticlesByCategoryData = any;
203
- export declare type IArticleControllerFindArticlesByTagData = any;
204
- export declare type IArticleControllerGetRecommendArticlesData = any;
205
- export declare type IArticleControllerGetArchivesData = any;
206
- export declare type IArticleControllerRecommendData = any;
207
- export declare type IArticleControllerFindByIdData = any;
208
- export declare type IArticleControllerUpdateByIdData = any;
209
- export declare type IArticleControllerDeleteByIdData = any;
210
- export declare type IArticleControllerCheckPasswordData = any;
211
- export declare type IArticleControllerUpdateViewsByIdData = any;
212
- export declare type IArticleControllerUpdateLikesByIdData = any;
213
- export declare type ICategoryControllerCreateData = ICategory[];
214
- export declare type ICategoryControllerFindAllData = any;
215
- export declare type ICategoryControllerFindByIdData = any;
216
- export declare type ICategoryControllerUpdateByIdData = any;
217
- export declare type ICategoryControllerDeleteByIdData = any;
218
- export declare type IKnowledgeControllerCreateBookData = IKnowledge[];
219
- export declare type IKnowledgeControllerCreateChapterData = IKnowledge[];
220
- export declare type IKnowledgeControllerDeleteByIdData = any;
221
- export declare type IKnowledgeControllerUpdateByIdData = any;
222
- export declare type IKnowledgeControllerFindByIdData = any;
223
- export declare type IKnowledgeControllerFindAllData = any;
224
- export declare type IKnowledgeControllerUpdateViewsByIdData = any;
225
- export declare type IKnowledgeControllerUpdateLikesByIdData = any;
226
- export declare type ICommentControllerCreateData = IComment[];
227
- export declare type ICommentControllerFindAllData = any;
228
- export declare type ICommentControllerFindByIdData = any;
229
- export declare type ICommentControllerUpdateByIdData = any;
230
- export declare type ICommentControllerDeleteByIdData = any;
231
- export declare type ICommentControllerGetArticleCommentsData = any;
232
- export declare type IPageControllerCreateData = IPage[];
233
- export declare type IPageControllerFindAllData = any;
234
- export declare type IPageControllerFindByIdData = any;
235
- export declare type IPageControllerUpdateByIdData = any;
236
- export declare type IPageControllerDeleteByIdData = any;
237
- export declare type IPageControllerUpdateViewsByIdData = any;
238
- export declare type IViewControllerCreateData = IView[];
239
- export declare type IViewControllerFindAllData = any;
240
- export declare type IViewControllerFindByUrlData = any;
241
- export declare type IViewControllerFindByIdData = any;
242
- export declare type IViewControllerDeleteByIdData = any;
243
- export declare type ISearchControllerSearchArticleData = any;
244
- export declare type ISearchControllerFindAllData = any;
245
- export declare type ISearchControllerDeleteByIdData = any;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,177 +0,0 @@
1
- export interface IUser {
2
- name: string;
3
- password: string;
4
- avatar: string;
5
- email: string;
6
- role: string;
7
- status: string;
8
- type: string;
9
- /** @format date-time */
10
- createAt: string;
11
- /** @format date-time */
12
- updateAt: string;
13
- }
14
- export interface ISetting {
15
- id: string;
16
- i18n: string;
17
- globalSetting: string;
18
- systemUrl: string;
19
- systemTitle: string;
20
- systemSubTitle: string;
21
- systemLogo: string;
22
- systemBg: string;
23
- systemFavicon: string;
24
- systemNoticeInfo: string;
25
- systemFooterInfo: string;
26
- adminSystemUrl: string;
27
- baiduAnalyticsId: string;
28
- googleAnalyticsId: string;
29
- seoKeyword: string;
30
- seoDesc: string;
31
- oss: string;
32
- smtpHost: string;
33
- smtpPort: string;
34
- smtpUser: string;
35
- smtpPass: string;
36
- smtpFromUser: string;
37
- /** @format date-time */
38
- createAt: string;
39
- /** @format date-time */
40
- updateAt: string;
41
- }
42
- export interface I_SMTP {
43
- id: string;
44
- from: string;
45
- to: string;
46
- subject: string;
47
- text: string;
48
- html: string;
49
- /** @format date-time */
50
- createAt: string;
51
- }
52
- export interface IFile {
53
- id: string;
54
- originalname: string;
55
- filename: string;
56
- type: string;
57
- size: number;
58
- url: string;
59
- /** @format date-time */
60
- createAt: string;
61
- }
62
- export interface ITag {
63
- label: string;
64
- value: string;
65
- articles: string[];
66
- /** @format date-time */
67
- createAt: string;
68
- /** @format date-time */
69
- updateAt: string;
70
- }
71
- export interface ICategory {
72
- id: string;
73
- label: string;
74
- value: string;
75
- articles: string[];
76
- /** @format date-time */
77
- createAt: string;
78
- /** @format date-time */
79
- updateAt: string;
80
- }
81
- export interface IArticle {
82
- id: string;
83
- title: string;
84
- cover: string;
85
- summary: string;
86
- content: string;
87
- html: string;
88
- toc: string;
89
- category: ICategory;
90
- tags: string[];
91
- status: string;
92
- views: number;
93
- likes: number;
94
- isRecommended: boolean;
95
- password: string;
96
- needPassword: boolean;
97
- isCommentable: boolean;
98
- /** @format date-time */
99
- publishAt: string;
100
- /** @format date-time */
101
- createAt: string;
102
- /** @format date-time */
103
- updateAt: string;
104
- }
105
- export interface IKnowledge {
106
- id: string;
107
- parentId: string;
108
- order: number;
109
- title: string;
110
- cover: string;
111
- summary: string;
112
- content: string;
113
- html: string;
114
- toc: string;
115
- status: string;
116
- views: number;
117
- likes: number;
118
- isCommentable: boolean;
119
- /** @format date-time */
120
- publishAt: string;
121
- /** @format date-time */
122
- createAt: string;
123
- /** @format date-time */
124
- updateAt: string;
125
- }
126
- export interface IComment {
127
- id: string;
128
- name: string;
129
- email: string;
130
- avatar: string;
131
- content: string;
132
- html: string;
133
- pass: boolean;
134
- userAgent: string;
135
- hostId: string;
136
- url: string;
137
- parentCommentId: string;
138
- replyUserName: string;
139
- replyUserEmail: string;
140
- /** @format date-time */
141
- createAt: string;
142
- /** @format date-time */
143
- updateAt: string;
144
- }
145
- export interface IPage {
146
- id: string;
147
- cover: string;
148
- name: string;
149
- path: string;
150
- order: number;
151
- content: string;
152
- html: string;
153
- toc: string;
154
- status: string;
155
- /** @format date-time */
156
- publishAt: string;
157
- views: number;
158
- /** @format date-time */
159
- createAt: string;
160
- /** @format date-time */
161
- updateAt: string;
162
- }
163
- export interface IView {
164
- ip: string;
165
- userAgent: string;
166
- url: string;
167
- count: number;
168
- address: string;
169
- browser: string;
170
- engine: string;
171
- os: string;
172
- device: string;
173
- /** @format date-time */
174
- createAt: string;
175
- /** @format date-time */
176
- updateAt: string;
177
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,21 +0,0 @@
1
- export declare const formatDate: (date: Date, format?: string) => string;
2
- export declare const deepClone: <T>(obj: T) => T;
3
- export interface ApiResponse<T = any> {
4
- code: number;
5
- message: string;
6
- data: T;
7
- timestamp: number;
8
- }
9
- export interface PaginatedResponse<T = any> {
10
- items: T[];
11
- total: number;
12
- page: number;
13
- limit: number;
14
- totalPages: number;
15
- }
16
- export declare class ApiError extends Error {
17
- code: number;
18
- details?: any;
19
- constructor(code: number, message: string, details?: any);
20
- static isInstance(error: any): error is ApiError;
21
- }
@@ -1,52 +0,0 @@
1
- "use strict";
2
- // 通用工具函数
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ApiError = exports.deepClone = exports.formatDate = void 0;
5
- // 日期格式化
6
- const formatDate = (date, format = 'YYYY-MM-DD') => {
7
- const year = date.getFullYear();
8
- const month = String(date.getMonth() + 1).padStart(2, '0');
9
- const day = String(date.getDate()).padStart(2, '0');
10
- return format
11
- .replace('YYYY', String(year))
12
- .replace('MM', month)
13
- .replace('DD', day);
14
- };
15
- exports.formatDate = formatDate;
16
- // 深度克隆
17
- const deepClone = (obj) => {
18
- if (obj === null || typeof obj !== 'object') {
19
- return obj;
20
- }
21
- if (obj instanceof Date) {
22
- return new Date(obj.getTime());
23
- }
24
- if (Array.isArray(obj)) {
25
- return obj.map(item => (0, exports.deepClone)(item));
26
- }
27
- if (typeof obj === 'object') {
28
- const cloned = {};
29
- for (const key in obj) {
30
- if (obj.hasOwnProperty(key)) {
31
- cloned[key] = (0, exports.deepClone)(obj[key]);
32
- }
33
- }
34
- return cloned;
35
- }
36
- return obj;
37
- };
38
- exports.deepClone = deepClone;
39
- // 错误处理
40
- class ApiError extends Error {
41
- constructor(code, message, details) {
42
- super(message);
43
- this.code = code;
44
- this.details = details;
45
- this.name = 'ApiError';
46
- }
47
- // 检查是否为 ApiError 实例
48
- static isInstance(error) {
49
- return error instanceof ApiError;
50
- }
51
- }
52
- exports.ApiError = ApiError;
@@ -1,3 +0,0 @@
1
- export declare const createHttpClient: (baseURL?: string) => import("axios").AxiosInstance;
2
- export declare const httpClient: import("axios").AxiosInstance;
3
- export default httpClient;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.httpClient = exports.createHttpClient = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- // 创建自定义 axios 实例
9
- const createHttpClient = (baseURL) => {
10
- const instance = axios_1.default.create({
11
- baseURL: baseURL || process.env.API_BASE_URL || 'http://localhost:3002',
12
- timeout: 30000,
13
- headers: {
14
- 'Content-Type': 'application/json',
15
- },
16
- });
17
- // 请求拦截器 - 修复类型错误
18
- instance.interceptors.request.use((config) => {
19
- // 添加认证令牌
20
- const token = localStorage.getItem('auth_token');
21
- if (token && config.headers) {
22
- config.headers.Authorization = `Bearer ${token}`;
23
- }
24
- return config;
25
- }, (error) => {
26
- return Promise.reject(error);
27
- });
28
- // 响应拦截器
29
- instance.interceptors.response.use((response) => {
30
- return response.data;
31
- }, (error) => {
32
- // 统一错误处理
33
- if (error.response?.status === 401) {
34
- // 未授权处理
35
- localStorage.removeItem('auth_token');
36
- window.location.href = '/login';
37
- }
38
- return Promise.reject(error.response?.data || error);
39
- });
40
- return instance;
41
- };
42
- exports.createHttpClient = createHttpClient;
43
- // 默认 HTTP 客户端实例
44
- exports.httpClient = (0, exports.createHttpClient)();
45
- exports.default = exports.httpClient;