@pisell/core 1.0.0 → 1.0.1

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 (281) hide show
  1. package/es/app/app.d.ts +122 -0
  2. package/es/app/app.js +166 -0
  3. package/es/app/const.d.ts +4 -0
  4. package/es/app/const.js +6 -0
  5. package/es/app/index.d.ts +14 -0
  6. package/es/app/index.js +54 -0
  7. package/es/applicationManager/application.d.ts +50 -0
  8. package/es/applicationManager/application.js +226 -0
  9. package/es/applicationManager/index.d.ts +13 -0
  10. package/es/applicationManager/index.js +190 -0
  11. package/es/config.d.ts +3 -3
  12. package/es/cookie/index.d.ts +13 -0
  13. package/es/cookie/index.js +47 -0
  14. package/es/css/global.less +73 -0
  15. package/es/css/index.less +31 -0
  16. package/es/css/variables.css +84 -0
  17. package/es/data/index.d.ts +29 -0
  18. package/es/data/index.js +8 -0
  19. package/es/history/config.d.ts +24 -0
  20. package/es/history/config.js +43 -0
  21. package/es/history/index.d.ts +20 -0
  22. package/es/history/index.js +41 -0
  23. package/es/history/type.d.ts +2 -0
  24. package/es/hooks/index.d.ts +12 -0
  25. package/es/hooks/index.js +13 -0
  26. package/es/hooks/useDelayedValue/index.d.ts +2 -0
  27. package/es/hooks/useDelayedValue/index.js +26 -0
  28. package/es/hooks/useDispatch/index.d.ts +2 -0
  29. package/es/hooks/useDispatch/index.js +2 -0
  30. package/es/hooks/useLowCode/index.d.ts +13 -0
  31. package/es/hooks/useLowCode/index.js +74 -0
  32. package/es/hooks/useStore/index.d.ts +6 -0
  33. package/es/hooks/useStore/index.js +11 -0
  34. package/es/index.d.ts +7 -1
  35. package/es/index.js +8 -2
  36. package/es/indexDB/index.d.ts +176 -0
  37. package/es/indexDB/index.js +536 -0
  38. package/es/locales/config.js +10 -8
  39. package/es/locales/en.d.ts +2 -1
  40. package/es/locales/en.js +5 -1
  41. package/es/locales/index.d.ts +44 -1
  42. package/es/locales/index.js +192 -8
  43. package/es/locales/original.d.ts +3 -0
  44. package/es/locales/original.js +7 -0
  45. package/es/locales/type.d.ts +15 -5
  46. package/es/locales/zh-CN.d.ts +2 -1
  47. package/es/locales/zh-CN.js +5 -1
  48. package/es/locales/zh-HK.d.ts +2 -1
  49. package/es/locales/zh-HK.js +5 -1
  50. package/es/logger/feishu.d.ts +11 -0
  51. package/es/logger/feishu.js +50 -0
  52. package/es/logger/index.d.ts +122 -0
  53. package/es/logger/index.js +531 -0
  54. package/es/menuManager/hooks.d.ts +8 -0
  55. package/es/menuManager/hooks.js +138 -0
  56. package/es/menuManager/index.d.ts +28 -0
  57. package/es/menuManager/index.js +142 -0
  58. package/es/models/global.d.ts +32 -0
  59. package/es/models/global.js +65 -0
  60. package/es/models/index.d.ts +45 -0
  61. package/es/models/index.js +66 -0
  62. package/es/models/tasks.d.ts +31 -0
  63. package/es/models/tasks.js +331 -0
  64. package/es/models/tasksUtils.d.ts +65 -0
  65. package/es/models/tasksUtils.js +179 -0
  66. package/es/models/type.d.ts +2 -0
  67. package/es/models/type.js +1 -0
  68. package/es/plugin/index.d.ts +0 -0
  69. package/es/plugin/index.js +0 -0
  70. package/es/pubsub/example.d.ts +5 -0
  71. package/es/pubsub/example.js +92 -0
  72. package/es/pubsub/index.d.ts +63 -0
  73. package/es/pubsub/index.js +144 -0
  74. package/es/request/cache.d.ts +46 -0
  75. package/es/request/cache.js +310 -0
  76. package/es/request/cancelToken.d.ts +38 -0
  77. package/es/request/cancelToken.js +59 -0
  78. package/es/request/config.d.ts +3 -0
  79. package/es/request/config.js +58 -0
  80. package/es/request/constants.d.ts +2 -0
  81. package/es/request/constants.js +6 -0
  82. package/es/request/index.d.ts +24 -0
  83. package/es/request/index.js +175 -0
  84. package/es/request/pisell2Request.d.ts +6 -0
  85. package/es/request/pisell2Request.js +62 -0
  86. package/es/request/type.d.ts +40 -0
  87. package/es/request/type.js +1 -0
  88. package/es/request/utils.d.ts +46 -0
  89. package/es/request/utils.js +145 -0
  90. package/es/routes/config.d.ts +7 -0
  91. package/es/routes/config.js +17 -0
  92. package/es/routes/index.d.ts +28 -0
  93. package/es/routes/index.js +154 -0
  94. package/es/socket/components/SocketMonitorPage.d.ts +6 -0
  95. package/es/socket/components/SocketMonitorPage.js +692 -0
  96. package/es/socket/components/index.d.ts +2 -0
  97. package/es/socket/components/index.js +2 -0
  98. package/es/socket/constants.d.ts +33 -0
  99. package/es/socket/constants.js +39 -0
  100. package/es/socket/events.d.ts +31 -0
  101. package/es/socket/events.js +19 -0
  102. package/es/socket/heartbeat.d.ts +66 -0
  103. package/es/socket/heartbeat.js +185 -0
  104. package/es/socket/index.d.ts +61 -0
  105. package/es/socket/index.js +246 -0
  106. package/es/socket/monitor.d.ts +169 -0
  107. package/es/socket/monitor.js +438 -0
  108. package/es/socket/reconnect.d.ts +61 -0
  109. package/es/socket/reconnect.js +199 -0
  110. package/es/socket/socket.d.ts +129 -0
  111. package/es/socket/socket.js +597 -0
  112. package/es/socket/types.d.ts +84 -0
  113. package/es/socket/types.js +19 -0
  114. package/es/storage/config.d.ts +3 -0
  115. package/es/{date → storage}/config.js +1 -6
  116. package/es/storage/index.d.ts +42 -0
  117. package/es/storage/index.js +62 -0
  118. package/es/storage/type.d.ts +5 -0
  119. package/es/storage/type.js +1 -0
  120. package/es/tasks/index.d.ts +77 -0
  121. package/es/tasks/index.js +719 -0
  122. package/es/tasks/type.d.ts +62 -0
  123. package/es/tasks/type.js +1 -0
  124. package/es/tasks/useTasks.d.ts +4 -0
  125. package/es/tasks/useTasks.js +25 -0
  126. package/es/type.d.ts +1 -1
  127. package/es/variables/VariablesProvider.d.ts +7 -0
  128. package/es/variables/VariablesProvider.js +14 -0
  129. package/es/variables/config.d.ts +3 -0
  130. package/es/{date/index.js → variables/config.js} +8 -14
  131. package/es/variables/index.d.ts +6 -0
  132. package/es/variables/index.js +5 -0
  133. package/es/variables/type.d.ts +2 -0
  134. package/es/variables/type.js +1 -0
  135. package/es/website/index.d.ts +6 -0
  136. package/es/website/index.js +65 -0
  137. package/lib/app/app.d.ts +122 -0
  138. package/lib/app/app.js +128 -0
  139. package/lib/app/const.d.ts +4 -0
  140. package/lib/app/const.js +33 -0
  141. package/lib/app/index.d.ts +14 -0
  142. package/lib/app/index.js +76 -0
  143. package/lib/applicationManager/application.d.ts +50 -0
  144. package/lib/applicationManager/application.js +110 -0
  145. package/lib/applicationManager/index.d.ts +13 -0
  146. package/lib/applicationManager/index.js +76 -0
  147. package/lib/config.d.ts +3 -3
  148. package/lib/cookie/index.d.ts +13 -0
  149. package/lib/cookie/index.js +64 -0
  150. package/lib/css/global.less +73 -0
  151. package/lib/css/index.less +31 -0
  152. package/lib/css/variables.css +84 -0
  153. package/lib/data/index.d.ts +29 -0
  154. package/lib/{date → data}/index.js +19 -20
  155. package/lib/history/config.d.ts +24 -0
  156. package/lib/history/config.js +41 -0
  157. package/lib/history/index.d.ts +20 -0
  158. package/lib/history/index.js +58 -0
  159. package/lib/history/type.d.ts +2 -0
  160. package/lib/history/type.js +17 -0
  161. package/lib/hooks/index.d.ts +12 -0
  162. package/lib/hooks/index.js +44 -0
  163. package/lib/hooks/useDelayedValue/index.d.ts +2 -0
  164. package/lib/hooks/useDelayedValue/index.js +36 -0
  165. package/lib/hooks/useDispatch/index.d.ts +2 -0
  166. package/lib/hooks/useDispatch/index.js +26 -0
  167. package/lib/hooks/useLowCode/index.d.ts +13 -0
  168. package/lib/hooks/useLowCode/index.js +75 -0
  169. package/lib/hooks/useStore/index.d.ts +6 -0
  170. package/lib/hooks/useStore/index.js +33 -0
  171. package/lib/index.d.ts +7 -1
  172. package/lib/index.js +23 -5
  173. package/lib/indexDB/index.d.ts +176 -0
  174. package/lib/indexDB/index.js +287 -0
  175. package/lib/locales/config.js +10 -7
  176. package/lib/locales/en.d.ts +2 -1
  177. package/lib/locales/en.js +5 -1
  178. package/lib/locales/index.d.ts +44 -1
  179. package/lib/locales/index.js +106 -4
  180. package/lib/locales/original.d.ts +3 -0
  181. package/lib/locales/original.js +31 -0
  182. package/lib/locales/type.d.ts +15 -5
  183. package/lib/locales/zh-CN.d.ts +2 -1
  184. package/lib/locales/zh-CN.js +5 -1
  185. package/lib/locales/zh-HK.d.ts +2 -1
  186. package/lib/locales/zh-HK.js +5 -1
  187. package/lib/logger/feishu.d.ts +11 -0
  188. package/lib/logger/feishu.js +52 -0
  189. package/lib/logger/index.d.ts +122 -0
  190. package/lib/logger/index.js +288 -0
  191. package/lib/menuManager/hooks.d.ts +8 -0
  192. package/lib/menuManager/hooks.js +135 -0
  193. package/lib/menuManager/index.d.ts +28 -0
  194. package/lib/menuManager/index.js +110 -0
  195. package/lib/models/global.d.ts +32 -0
  196. package/lib/models/global.js +62 -0
  197. package/lib/models/index.d.ts +45 -0
  198. package/lib/models/index.js +70 -0
  199. package/lib/models/tasks.d.ts +31 -0
  200. package/lib/models/tasks.js +199 -0
  201. package/lib/models/tasksUtils.d.ts +65 -0
  202. package/lib/models/tasksUtils.js +160 -0
  203. package/lib/models/type.d.ts +2 -0
  204. package/lib/models/type.js +17 -0
  205. package/lib/plugin/index.d.ts +0 -0
  206. package/lib/plugin/index.js +0 -0
  207. package/lib/pubsub/example.d.ts +5 -0
  208. package/lib/pubsub/example.js +61 -0
  209. package/lib/pubsub/index.d.ts +63 -0
  210. package/lib/pubsub/index.js +129 -0
  211. package/lib/request/cache.d.ts +46 -0
  212. package/lib/request/cache.js +159 -0
  213. package/lib/request/cancelToken.d.ts +38 -0
  214. package/lib/request/cancelToken.js +59 -0
  215. package/lib/request/config.d.ts +3 -0
  216. package/lib/request/config.js +74 -0
  217. package/lib/request/constants.d.ts +2 -0
  218. package/lib/request/constants.js +34 -0
  219. package/lib/request/index.d.ts +24 -0
  220. package/lib/request/index.js +143 -0
  221. package/lib/request/pisell2Request.d.ts +6 -0
  222. package/lib/request/pisell2Request.js +75 -0
  223. package/lib/request/type.d.ts +40 -0
  224. package/lib/request/type.js +17 -0
  225. package/lib/request/utils.d.ts +46 -0
  226. package/lib/request/utils.js +111 -0
  227. package/lib/routes/config.d.ts +7 -0
  228. package/lib/routes/config.js +50 -0
  229. package/lib/routes/index.d.ts +28 -0
  230. package/lib/routes/index.js +118 -0
  231. package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
  232. package/lib/socket/components/SocketMonitorPage.js +346 -0
  233. package/lib/socket/components/index.d.ts +2 -0
  234. package/lib/socket/components/index.js +39 -0
  235. package/lib/socket/constants.d.ts +33 -0
  236. package/lib/socket/constants.js +62 -0
  237. package/lib/socket/events.d.ts +31 -0
  238. package/lib/socket/events.js +44 -0
  239. package/lib/socket/heartbeat.d.ts +66 -0
  240. package/lib/socket/heartbeat.js +152 -0
  241. package/lib/socket/index.d.ts +61 -0
  242. package/lib/socket/index.js +200 -0
  243. package/lib/socket/monitor.d.ts +169 -0
  244. package/lib/socket/monitor.js +346 -0
  245. package/lib/socket/reconnect.d.ts +61 -0
  246. package/lib/socket/reconnect.js +153 -0
  247. package/lib/socket/socket.d.ts +129 -0
  248. package/lib/socket/socket.js +410 -0
  249. package/lib/socket/types.d.ts +84 -0
  250. package/lib/socket/types.js +36 -0
  251. package/lib/storage/config.d.ts +3 -0
  252. package/lib/{date → storage}/config.js +2 -7
  253. package/lib/storage/index.d.ts +42 -0
  254. package/lib/storage/index.js +66 -0
  255. package/lib/storage/type.d.ts +5 -0
  256. package/lib/storage/type.js +17 -0
  257. package/lib/tasks/index.d.ts +77 -0
  258. package/lib/tasks/index.js +438 -0
  259. package/lib/tasks/type.d.ts +62 -0
  260. package/lib/{date → tasks}/type.js +1 -1
  261. package/lib/tasks/useTasks.d.ts +4 -0
  262. package/lib/tasks/useTasks.js +37 -0
  263. package/lib/type.d.ts +1 -1
  264. package/lib/variables/VariablesProvider.d.ts +7 -0
  265. package/lib/variables/VariablesProvider.js +51 -0
  266. package/lib/variables/config.d.ts +3 -0
  267. package/lib/variables/config.js +38 -0
  268. package/lib/variables/index.d.ts +6 -0
  269. package/lib/variables/index.js +29 -0
  270. package/lib/variables/type.d.ts +2 -0
  271. package/lib/variables/type.js +17 -0
  272. package/lib/website/index.d.ts +6 -0
  273. package/lib/website/index.js +75 -0
  274. package/package.json +13 -3
  275. package/es/date/config.d.ts +0 -3
  276. package/es/date/index.d.ts +0 -7
  277. package/es/date/type.d.ts +0 -7
  278. package/lib/date/config.d.ts +0 -3
  279. package/lib/date/index.d.ts +0 -7
  280. package/lib/date/type.d.ts +0 -7
  281. /package/es/{date → history}/type.js +0 -0
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @Title: 请求列表
3
+ * @Describe:
4
+ * @Author: Wzw
5
+ */
6
+ export declare let requestList: {
7
+ [key: string]: AbortController;
8
+ };
9
+ /**
10
+ * @Title: 创建一个控制器
11
+ * @Describe:
12
+ * @Author: Wzw
13
+ * @param {string} key
14
+ */
15
+ export declare const createController: (key: string) => AbortController;
16
+ /**
17
+ * @Title: 储存请求
18
+ * @Describe:
19
+ * @Author: Wzw
20
+ * @param {AbortController} controller
21
+ * @param {string} key
22
+ */
23
+ export declare const setRequestList: (controller: AbortController, key: string) => void;
24
+ /**
25
+ * @Title: 取消请求
26
+ * @Describe:
27
+ * @Author: Wzw
28
+ * @param {string} key
29
+ */
30
+ export declare const abortRequest: (key: string) => void;
31
+ /**
32
+ * @Title: 创建signal
33
+ * @Describe:
34
+ * @Author: Wzw
35
+ * @param {string} isAbort
36
+ * @param {string} url
37
+ */
38
+ export declare const createSignal: (isAbort: boolean, url: string) => AbortSignal | null;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @Title: 请求列表
3
+ * @Describe:
4
+ * @Author: Wzw
5
+ */
6
+ export var requestList = {};
7
+
8
+ /**
9
+ * @Title: 创建一个控制器
10
+ * @Describe:
11
+ * @Author: Wzw
12
+ * @param {string} key
13
+ */
14
+ export var createController = function createController(key) {
15
+ var controller = new AbortController(); // 创建一个控制器
16
+ setRequestList(controller, key);
17
+ return controller;
18
+ };
19
+
20
+ /**
21
+ * @Title: 储存请求
22
+ * @Describe:
23
+ * @Author: Wzw
24
+ * @param {AbortController} controller
25
+ * @param {string} key
26
+ */
27
+ export var setRequestList = function setRequestList(controller, key) {
28
+ requestList[key] = controller;
29
+ };
30
+
31
+ /**
32
+ * @Title: 取消请求
33
+ * @Describe:
34
+ * @Author: Wzw
35
+ * @param {string} key
36
+ */
37
+ export var abortRequest = function abortRequest(key) {
38
+ if (requestList[key]) {
39
+ requestList[key].abort();
40
+ delete requestList[key];
41
+ }
42
+ };
43
+
44
+ /**
45
+ * @Title: 创建signal
46
+ * @Describe:
47
+ * @Author: Wzw
48
+ * @param {string} isAbort
49
+ * @param {string} url
50
+ */
51
+ export var createSignal = function createSignal(isAbort, url) {
52
+ var signal = null;
53
+ //@ts-ignore
54
+ if (isAbort) {
55
+ abortRequest(url);
56
+ signal = createController(url).signal;
57
+ }
58
+ return signal;
59
+ };
@@ -0,0 +1,3 @@
1
+ import { RequestConfig } from './type';
2
+ export declare const setConfig: (newConfig: Partial<RequestConfig>) => void;
3
+ export declare const getConfig: () => RequestConfig;
@@ -0,0 +1,58 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import { axiosConfig } from "./constants";
8
+ import storage from "../storage";
9
+ import { mergeWith } from 'lodash';
10
+ var defaultConfig = {
11
+ axiosConfig: axiosConfig,
12
+ storage: storage,
13
+ requestCallbacks: {
14
+ 200: function _(resData) {
15
+ var res = resData.res,
16
+ props = resData.props,
17
+ resolve = resData.resolve,
18
+ reject = resData.reject,
19
+ err = resData.err;
20
+ resolve(res);
21
+ return res;
22
+ },
23
+ 401: function _(resData) {
24
+ var res = resData.res,
25
+ props = resData.props,
26
+ resolve = resData.resolve,
27
+ reject = resData.reject,
28
+ err = resData.err;
29
+ resolve(res);
30
+ return res;
31
+ },
32
+ 403: function _(resData) {
33
+ var res = resData.res,
34
+ props = resData.props,
35
+ resolve = resData.resolve,
36
+ reject = resData.reject,
37
+ err = resData.err;
38
+ resolve(res);
39
+ return res;
40
+ },
41
+ other: function other(resData) {
42
+ var res = resData.res,
43
+ props = resData.props,
44
+ resolve = resData.resolve,
45
+ reject = resData.reject,
46
+ err = resData.err;
47
+ resolve(res);
48
+ return res;
49
+ }
50
+ }
51
+ };
52
+ var config = _objectSpread({}, defaultConfig);
53
+ export var setConfig = function setConfig(newConfig) {
54
+ config = mergeWith(config, newConfig);
55
+ };
56
+ export var getConfig = function getConfig() {
57
+ return config;
58
+ };
@@ -0,0 +1,2 @@
1
+ import { CreateAxiosDefaults } from "axios";
2
+ export declare const axiosConfig: CreateAxiosDefaults;
@@ -0,0 +1,6 @@
1
+ export var axiosConfig = {
2
+ timeout: 1000 * 60,
3
+ headers: {
4
+ "Content-Type": "application/json"
5
+ }
6
+ };
@@ -0,0 +1,24 @@
1
+ import { RequestWrapperProps, RequestConfig } from "./type";
2
+ export declare const createRequest: (props: RequestWrapperProps) => Promise<unknown>;
3
+ /**
4
+ * 请求
5
+ * @param props
6
+ * @returns
7
+ */
8
+ export declare const request: (props: RequestWrapperProps) => Promise<any>;
9
+ export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
10
+ export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
11
+ export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
12
+ export declare const remove: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
13
+ export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => Promise<any>;
14
+ export * from "./type";
15
+ declare const _default: {
16
+ get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
17
+ post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
18
+ put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
19
+ remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
20
+ custom: (url: string, config: import("./type").RequestSetting | undefined) => Promise<any>;
21
+ setConfig: (newConfig: Partial<RequestConfig>) => void;
22
+ getConfig: () => RequestConfig;
23
+ };
24
+ export default _default;
@@ -0,0 +1,175 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
+ import { createSignal } from "./cancelToken";
11
+ import { axiosConfig } from "./constants";
12
+ import { cacheFn } from "./cache";
13
+ import { interceptorsRequest, interceptorsResponse, interceptorsRequestError, interceptorsResponseError, requestCallback } from "./utils";
14
+ import axios from "axios";
15
+ import { getConfig, setConfig } from "./config";
16
+ // 实例
17
+ var axiosInstance = axios.create(axiosConfig);
18
+
19
+ // 请求拦截器
20
+ axiosInstance.interceptors.request.use(interceptorsRequest, interceptorsRequestError);
21
+
22
+ // 响应拦截器
23
+ axiosInstance.interceptors.response.use(interceptorsResponse, interceptorsResponseError);
24
+ export var createRequest = function createRequest(props) {
25
+ var data = props.data,
26
+ config = props.config,
27
+ method = props.method;
28
+ var _getConfig = getConfig(),
29
+ getUrl = _getConfig.getUrl;
30
+ return new Promise(function (resolve, reject) {
31
+ var _method = method === "remove" ? "delete" : method;
32
+ var _url = getUrl === null || getUrl === void 0 ? void 0 : getUrl(props);
33
+
34
+ //@ts-ignore
35
+ axiosInstance[_method](_url, ["post", "put"].includes(_method) ? data : _objectSpread({
36
+ params: data
37
+ }, config), _objectSpread({
38
+ params: !["post", "put"].includes(_method) ? data : null
39
+ }, config)).then(function (res) {
40
+ requestCallback({
41
+ res: res,
42
+ reject: reject,
43
+ resolve: resolve,
44
+ props: props
45
+ });
46
+ }).catch(function (err) {
47
+ requestCallback({
48
+ err: err,
49
+ reject: reject,
50
+ resolve: resolve,
51
+ props: props
52
+ });
53
+ });
54
+ });
55
+ };
56
+
57
+ /**
58
+ * 请求
59
+ * @param props
60
+ * @returns
61
+ */
62
+ export var request = function request(props) {
63
+ var config = props.config,
64
+ url = props.url;
65
+ // 请求防抖
66
+ if (config !== null && config !== void 0 && config.abort) {
67
+ var signal = createSignal(config.abort, url);
68
+ config.signal = signal;
69
+ }
70
+
71
+ // 缓存函数
72
+ return cacheFn(props, createRequest);
73
+ };
74
+ export var get = /*#__PURE__*/function () {
75
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, data, config) {
76
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
77
+ while (1) switch (_context.prev = _context.next) {
78
+ case 0:
79
+ return _context.abrupt("return", request({
80
+ method: "get",
81
+ url: url,
82
+ data: data,
83
+ config: config
84
+ }));
85
+ case 1:
86
+ case "end":
87
+ return _context.stop();
88
+ }
89
+ }, _callee);
90
+ }));
91
+ return function get(_x, _x2, _x3) {
92
+ return _ref.apply(this, arguments);
93
+ };
94
+ }();
95
+ export var post = /*#__PURE__*/function () {
96
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(url, data, config) {
97
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
98
+ while (1) switch (_context2.prev = _context2.next) {
99
+ case 0:
100
+ return _context2.abrupt("return", request({
101
+ method: "post",
102
+ url: url,
103
+ data: data,
104
+ config: config
105
+ }));
106
+ case 1:
107
+ case "end":
108
+ return _context2.stop();
109
+ }
110
+ }, _callee2);
111
+ }));
112
+ return function post(_x4, _x5, _x6) {
113
+ return _ref2.apply(this, arguments);
114
+ };
115
+ }();
116
+ export var put = /*#__PURE__*/function () {
117
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(url, data, config) {
118
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
119
+ while (1) switch (_context3.prev = _context3.next) {
120
+ case 0:
121
+ return _context3.abrupt("return", request({
122
+ method: "put",
123
+ url: url,
124
+ data: data,
125
+ config: config
126
+ }));
127
+ case 1:
128
+ case "end":
129
+ return _context3.stop();
130
+ }
131
+ }, _callee3);
132
+ }));
133
+ return function put(_x7, _x8, _x9) {
134
+ return _ref3.apply(this, arguments);
135
+ };
136
+ }();
137
+ export var remove = /*#__PURE__*/function () {
138
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(url, data, config) {
139
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
140
+ while (1) switch (_context4.prev = _context4.next) {
141
+ case 0:
142
+ return _context4.abrupt("return", request({
143
+ method: "remove",
144
+ url: url,
145
+ data: data,
146
+ config: config
147
+ }));
148
+ case 1:
149
+ case "end":
150
+ return _context4.stop();
151
+ }
152
+ }, _callee4);
153
+ }));
154
+ return function remove(_x10, _x11, _x12) {
155
+ return _ref4.apply(this, arguments);
156
+ };
157
+ }();
158
+ export var custom = function custom(url, config) {
159
+ return request({
160
+ url: url,
161
+ method: config === null || config === void 0 ? void 0 : config.method,
162
+ data: config === null || config === void 0 ? void 0 : config.data,
163
+ config: config
164
+ });
165
+ };
166
+ export * from "./type";
167
+ export default {
168
+ get: get,
169
+ post: post,
170
+ put: put,
171
+ remove: remove,
172
+ custom: custom,
173
+ setConfig: setConfig,
174
+ getConfig: getConfig
175
+ };
@@ -0,0 +1,6 @@
1
+ declare type RequestMethod = any;
2
+ declare const pisell2Get: RequestMethod;
3
+ declare const pisell2Post: RequestMethod;
4
+ declare const pisell2Put: RequestMethod;
5
+ declare const pisell2Remove: RequestMethod;
6
+ export { pisell2Get as get, pisell2Post as post, pisell2Put as put, pisell2Remove as remove, };
@@ -0,0 +1,62 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ import { get, post, put, remove } from "./index";
8
+ var pisell2Get = function pisell2Get(url) {
9
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
10
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
11
+ return get(url, data, _objectSpread(_objectSpread({}, config), {}, {
12
+ pisell2: true,
13
+ headers: _objectSpread(_objectSpread({}, (config === null || config === void 0 ? void 0 : config.headers) || {}), {}, {
14
+ Accept: '*/json'
15
+ })
16
+ }));
17
+ };
18
+ var pisell2Post = function pisell2Post(url) {
19
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
20
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
21
+ return post(url, data, _objectSpread(_objectSpread({}, config), {}, {
22
+ pisell2: true,
23
+ headers: _objectSpread(_objectSpread({}, (config === null || config === void 0 ? void 0 : config.headers) || {}), {}, {
24
+ Accept: '*/json'
25
+ })
26
+ }));
27
+ };
28
+ var pisell2Put = function pisell2Put(url) {
29
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
30
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
31
+ return put(url, data, _objectSpread(_objectSpread({}, config), {}, {
32
+ pisell2: true,
33
+ headers: _objectSpread(_objectSpread({}, (config === null || config === void 0 ? void 0 : config.headers) || {}), {}, {
34
+ Accept: '*/json'
35
+ })
36
+ }));
37
+ };
38
+ var pisell2Remove = function pisell2Remove(url) {
39
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
40
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
41
+ return remove(url, data, _objectSpread(_objectSpread({}, config), {}, {
42
+ pisell2: true,
43
+ headers: _objectSpread(_objectSpread({}, (config === null || config === void 0 ? void 0 : config.headers) || {}), {}, {
44
+ Accept: '*/json'
45
+ })
46
+ }));
47
+ };
48
+
49
+ // const pisell2Custom: RequestMethod = <T>(url: string, config: any) => {
50
+ // return custom(url, {
51
+ // ...config,
52
+ // pisell2: true,
53
+ // headers: {
54
+ // ...((config as any)?.headers || {}),
55
+ // Accept: '*/json',
56
+ // },
57
+ // });
58
+ // };
59
+
60
+ export { pisell2Get as get, pisell2Post as post, pisell2Put as put, pisell2Remove as remove
61
+ // pisell2Custom as custom,
62
+ };
@@ -0,0 +1,40 @@
1
+ import { CreateAxiosDefaults } from "axios";
2
+ import { CacheType } from './cache';
3
+ export interface RequestConfig {
4
+ interceptorsRequest?: ((value: any) => any | Promise<any>) | null;
5
+ interceptorsRequestError?: ((error: any) => any) | null;
6
+ interceptorsResponse?: any;
7
+ interceptorsResponseError?: ((error: any) => any) | null;
8
+ axiosConfig?: CreateAxiosDefaults;
9
+ storage?: any;
10
+ getToken?: () => string | null;
11
+ setToken?: (token: string) => void;
12
+ getLocale?: () => string | null;
13
+ getUrl?: (config: any) => string;
14
+ requestCallbacks?: {
15
+ 200?: (data: any) => void;
16
+ 401?: (data: any) => void;
17
+ 403?: (data: any) => void;
18
+ other?: (data: any) => void;
19
+ [key: string]: any;
20
+ };
21
+ }
22
+ export interface CacheProps {
23
+ key?: string;
24
+ type?: CacheType;
25
+ updateCache?: boolean;
26
+ }
27
+ export interface RequestSetting {
28
+ abort?: boolean;
29
+ headers?: any;
30
+ cache?: CacheProps;
31
+ signal?: any;
32
+ token?: string;
33
+ [key: string]: any;
34
+ }
35
+ export interface RequestWrapperProps {
36
+ url: string;
37
+ method: 'get' | 'post' | 'remove' | 'put';
38
+ data?: any;
39
+ config?: RequestSetting;
40
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ import { InternalAxiosRequestConfig } from "axios";
2
+ import { RequestSetting, RequestConfig, RequestWrapperProps } from "./type";
3
+ export declare const getRequestHeaders: (config: InternalAxiosRequestConfig<RequestSetting> & Record<string, any>) => Record<string, string | null>;
4
+ /**
5
+ * @title: 请求前拦截
6
+ * @description:
7
+ * @param {any} config
8
+ * @return {*}
9
+ * @Author: zhiwei.Wang
10
+ * @Date: 2024-07-04 10:51
11
+ */
12
+ export declare const interceptorsRequest: (config: InternalAxiosRequestConfig<RequestSetting> & Record<string, any>) => Promise<InternalAxiosRequestConfig<RequestSetting> & Record<string, any>>;
13
+ /**
14
+ * @title: 请求前error
15
+ * @description:
16
+ * @param {any} err
17
+ * @return {*}
18
+ * @Author: zhiwei.Wang
19
+ * @Date: 2024-07-04 10:51
20
+ */
21
+ export declare const interceptorsRequestError: (err: RequestConfig["interceptorsRequestError"]) => any;
22
+ /**
23
+ * @title: 请求后拦截
24
+ * @description:
25
+ * @param {any} response
26
+ * @return {*}
27
+ * @Author: zhiwei.Wang
28
+ * @Date: 2024-07-04 10:51
29
+ */
30
+ export declare const interceptorsResponse: (response: RequestConfig["interceptorsResponse"]) => any;
31
+ /**
32
+ * @title: 请求后错误拦截
33
+ * @description:
34
+ * @param {any} response
35
+ * @return {*}
36
+ * @Author: zhiwei.Wang
37
+ * @Date: 2024-07-04 10:51
38
+ */
39
+ export declare const interceptorsResponseError: (response: RequestConfig["interceptorsResponseError"]) => any;
40
+ export declare const requestCallback: (resData: {
41
+ res?: any;
42
+ props: RequestWrapperProps;
43
+ resolve: (value: unknown) => void;
44
+ reject: () => void;
45
+ err?: any;
46
+ }) => void;