@pisell/pisellos 0.0.569 → 0.10.2

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 (328) hide show
  1. package/dist/core/index.js +10 -6
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -3
  4. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
  6. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  7. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  8. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  9. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  10. package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
  11. package/dist/model/strategy/strategy-example.js +19 -5
  12. package/dist/modules/BaseModule.d.ts +1 -1
  13. package/dist/modules/BaseModule.js +8 -10
  14. package/dist/modules/Cart/index.js +3 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  16. package/dist/modules/Cart/utils/cartResource.js +0 -2
  17. package/dist/modules/Cart/utils/changePrice.js +9 -16
  18. package/dist/modules/Date/index.js +5 -1
  19. package/dist/modules/Discount/index.d.ts +0 -1
  20. package/dist/modules/Discount/index.js +7 -22
  21. package/dist/modules/Discount/types.d.ts +0 -1
  22. package/dist/modules/OpenData/index.js +2 -0
  23. package/dist/modules/Order/index.js +70 -40
  24. package/dist/modules/Payment/index.js +162 -97
  25. package/dist/modules/Payment/types.d.ts +4 -8
  26. package/dist/modules/Payment/walletpass.d.ts +0 -2
  27. package/dist/modules/Payment/walletpass.js +5 -4
  28. package/dist/modules/ProductList/index.d.ts +1 -1
  29. package/dist/modules/ProductList/index.js +3 -12
  30. package/dist/modules/ProductList/types.d.ts +0 -1
  31. package/dist/modules/Rules/index.js +126 -427
  32. package/dist/modules/SalesSummary/utils.js +1 -2
  33. package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
  34. package/dist/modules/Schedule/index.js +1 -0
  35. package/dist/modules/Schedule/utils.js +1 -0
  36. package/dist/modules/Step/index.js +1 -0
  37. package/dist/modules/Summary/utils.js +22 -43
  38. package/dist/plugins/request.js +4 -1
  39. package/dist/plugins/window.js +6 -2
  40. package/dist/server/index.js +129 -97
  41. package/dist/server/modules/menu/index.js +41 -32
  42. package/dist/server/modules/order/index.js +4 -2
  43. package/dist/server/modules/products/index.js +42 -24
  44. package/dist/server/modules/quotation/index.js +38 -29
  45. package/dist/server/modules/resource/index.js +4 -3
  46. package/dist/server/modules/schedule/index.js +35 -27
  47. package/dist/server/utils/product.js +1 -0
  48. package/dist/solution/BaseSales/index.js +41 -38
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingByStep/index.js +60 -11
  51. package/dist/solution/BookingByStep/utils/capacity.js +11 -1
  52. package/dist/solution/BookingByStep/utils/resources.js +3 -1
  53. package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
  54. package/dist/solution/BookingTicket/index.d.ts +1 -1
  55. package/dist/solution/BookingTicket/index.js +2 -0
  56. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
  57. package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
  58. package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
  59. package/dist/solution/BuyTickets/index.js +12 -9
  60. package/dist/solution/Checkout/index.js +252 -177
  61. package/dist/solution/Checkout/utils/index.js +16 -4
  62. package/dist/solution/RegisterAndLogin/index.js +76 -30
  63. package/dist/solution/ScanOrder/index.js +60 -50
  64. package/dist/solution/ShopDiscount/index.js +14 -15
  65. package/dist/solution/ShopDiscount/types.d.ts +4 -5
  66. package/dist/solution/ShopDiscount/utils.d.ts +0 -9
  67. package/dist/solution/ShopDiscount/utils.js +0 -9
  68. package/dist/solution/VenueBooking/index.d.ts +3 -31
  69. package/dist/solution/VenueBooking/index.js +496 -651
  70. package/dist/solution/VenueBooking/types.d.ts +1 -3
  71. package/dist/solution/VenueBooking/types.js +0 -1
  72. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  73. package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
  74. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  75. package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/utils/task.js +18 -15
  78. package/dist/utils/watch.js +1 -0
  79. package/lib/apis/picoding.js +0 -2
  80. package/lib/core/index.js +132 -130
  81. package/lib/effects/index.js +57 -46
  82. package/lib/index.d.ts +0 -1
  83. package/lib/index.js +50 -92
  84. package/lib/model/index.js +21 -14
  85. package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
  86. package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
  87. package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
  88. package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
  89. package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
  90. package/lib/model/strategy/adapter/index.js +64 -100
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
  92. package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
  93. package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
  94. package/lib/model/strategy/adapter/itemRule/index.js +57 -83
  95. package/lib/model/strategy/adapter/itemRule/type.js +36 -97
  96. package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
  97. package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
  98. package/lib/model/strategy/adapter/promotion/examples.js +159 -139
  99. package/lib/model/strategy/adapter/promotion/index.js +49 -1
  100. package/lib/model/strategy/adapter/promotion/type.js +35 -199
  101. package/lib/model/strategy/adapter/type.js +16 -4
  102. package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
  103. package/lib/model/strategy/adapter/walletPass/example.js +190 -217
  104. package/lib/model/strategy/adapter/walletPass/index.js +51 -75
  105. package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
  106. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
  107. package/lib/model/strategy/adapter/walletPass/type.js +16 -4
  108. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  109. package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
  110. package/lib/model/strategy/engine.js +168 -270
  111. package/lib/model/strategy/index.js +34 -49
  112. package/lib/model/strategy/strategy-example.js +239 -243
  113. package/lib/model/strategy/type.js +40 -100
  114. package/lib/modules/Account/index.js +53 -39
  115. package/lib/modules/Account/types.js +33 -20
  116. package/lib/modules/AccountList/index.js +154 -116
  117. package/lib/modules/AccountList/types.js +31 -30
  118. package/lib/modules/AccountList/utils.js +30 -18
  119. package/lib/modules/BaseModule.d.ts +1 -1
  120. package/lib/modules/BaseModule.js +46 -25
  121. package/lib/modules/BookingContext/index.js +136 -158
  122. package/lib/modules/BookingContext/types.js +32 -46
  123. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
  124. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
  125. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
  126. package/lib/modules/BookingContext/utils/flexible.js +55 -38
  127. package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
  128. package/lib/modules/BookingContext/utils/index.js +41 -124
  129. package/lib/modules/BookingContext/utils/noResource.js +70 -58
  130. package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
  131. package/lib/modules/BookingContext/utils/productExtend.js +155 -202
  132. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  133. package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
  134. package/lib/modules/BookingContext/utils/resources.js +167 -209
  135. package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
  136. package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
  137. package/lib/modules/Cart/index.js +124 -170
  138. package/lib/modules/Cart/types.js +51 -46
  139. package/lib/modules/Cart/utils/cartAccount.js +39 -40
  140. package/lib/modules/Cart/utils/cartDate.js +61 -56
  141. package/lib/modules/Cart/utils/cartDiscount.js +33 -28
  142. package/lib/modules/Cart/utils/cartNote.js +32 -27
  143. package/lib/modules/Cart/utils/cartProduct.js +251 -321
  144. package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
  145. package/lib/modules/Cart/utils/cartResource.js +78 -72
  146. package/lib/modules/Cart/utils/changePrice.js +50 -28
  147. package/lib/modules/Cart/utils/index.js +48 -106
  148. package/lib/modules/Customer/constants.js +34 -13
  149. package/lib/modules/Customer/index.js +169 -232
  150. package/lib/modules/Customer/types.js +35 -38
  151. package/lib/modules/Date/index.js +115 -116
  152. package/lib/modules/Date/types.js +28 -16
  153. package/lib/modules/Date/utils.js +123 -174
  154. package/lib/modules/Discount/index.d.ts +0 -1
  155. package/lib/modules/Discount/index.js +128 -130
  156. package/lib/modules/Discount/types.d.ts +0 -1
  157. package/lib/modules/Discount/types.js +31 -9
  158. package/lib/modules/Guests/index.js +56 -30
  159. package/lib/modules/Guests/types.js +33 -23
  160. package/lib/modules/Holder/index.js +189 -209
  161. package/lib/modules/Holder/types.js +16 -4
  162. package/lib/modules/Holder/utils.js +49 -20
  163. package/lib/modules/OpenData/index.js +76 -69
  164. package/lib/modules/OpenData/types.js +16 -4
  165. package/lib/modules/OpenData/utils.js +78 -44
  166. package/lib/modules/Order/index.js +1909 -1572
  167. package/lib/modules/Order/types.js +35 -78
  168. package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
  169. package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
  170. package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
  171. package/lib/modules/Order/utils.js +634 -799
  172. package/lib/modules/Payment/cash.js +33 -20
  173. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  174. package/lib/modules/Payment/eftpos.js +30 -16
  175. package/lib/modules/Payment/index.js +378 -518
  176. package/lib/modules/Payment/mx51.js +0 -1
  177. package/lib/modules/Payment/types.d.ts +4 -8
  178. package/lib/modules/Payment/types.js +107 -216
  179. package/lib/modules/Payment/utils.js +48 -51
  180. package/lib/modules/Payment/walletpass.d.ts +0 -2
  181. package/lib/modules/Payment/walletpass.js +211 -226
  182. package/lib/modules/Product/index.js +46 -51
  183. package/lib/modules/Product/types.js +16 -4
  184. package/lib/modules/Product/utils.js +33 -32
  185. package/lib/modules/ProductList/index.d.ts +1 -1
  186. package/lib/modules/ProductList/index.js +117 -117
  187. package/lib/modules/ProductList/types.d.ts +0 -1
  188. package/lib/modules/ProductList/types.js +31 -9
  189. package/lib/modules/Quotation/index.js +100 -66
  190. package/lib/modules/Quotation/types.js +16 -4
  191. package/lib/modules/Resource/index.js +59 -27
  192. package/lib/modules/Resource/types.js +32 -22
  193. package/lib/modules/Resource/utils.js +38 -30
  194. package/lib/modules/ResourcePlanner/index.js +61 -60
  195. package/lib/modules/ResourcePlanner/planner.js +384 -346
  196. package/lib/modules/ResourcePlanner/types.js +16 -4
  197. package/lib/modules/Rules/index.js +903 -1475
  198. package/lib/modules/Rules/types.js +40 -17
  199. package/lib/modules/SalesSummary/index.js +90 -85
  200. package/lib/modules/SalesSummary/types.js +16 -4
  201. package/lib/modules/SalesSummary/utils.js +427 -351
  202. package/lib/modules/ScanOrderLogger/index.js +79 -59
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  204. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  205. package/lib/modules/ScanOrderLogger/types.js +16 -4
  206. package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
  207. package/lib/modules/Schedule/index.js +114 -100
  208. package/lib/modules/Schedule/type.js +16 -4
  209. package/lib/modules/Schedule/types.js +16 -4
  210. package/lib/modules/Schedule/utils.js +291 -433
  211. package/lib/modules/Step/index.js +52 -40
  212. package/lib/modules/Step/tyeps.js +16 -4
  213. package/lib/modules/Summary/index.js +71 -66
  214. package/lib/modules/Summary/types.js +16 -4
  215. package/lib/modules/Summary/utils.js +418 -791
  216. package/lib/modules/SurchargeList/index.js +60 -46
  217. package/lib/modules/SurchargeList/types.js +16 -4
  218. package/lib/modules/index.js +63 -245
  219. package/lib/plugins/app.js +16 -4
  220. package/lib/plugins/index.js +25 -36
  221. package/lib/plugins/request.js +126 -137
  222. package/lib/plugins/shopStore.js +16 -4
  223. package/lib/plugins/user.js +16 -4
  224. package/lib/plugins/window.js +179 -171
  225. package/lib/server/index.js +2337 -2675
  226. package/lib/server/modules/floor-plan/index.js +123 -102
  227. package/lib/server/modules/floor-plan/types.js +30 -15
  228. package/lib/server/modules/index.js +68 -106
  229. package/lib/server/modules/menu/index.js +122 -146
  230. package/lib/server/modules/menu/types.js +31 -18
  231. package/lib/server/modules/order/index.js +642 -567
  232. package/lib/server/modules/order/types.js +32 -117
  233. package/lib/server/modules/order/utils/filterBookings.js +194 -219
  234. package/lib/server/modules/order/utils/filterOrders.js +92 -118
  235. package/lib/server/modules/payment/index.js +83 -59
  236. package/lib/server/modules/payment/types.js +16 -4
  237. package/lib/server/modules/products/index.js +459 -575
  238. package/lib/server/modules/products/types.js +34 -44
  239. package/lib/server/modules/quotation/index.js +172 -137
  240. package/lib/server/modules/quotation/types.js +31 -21
  241. package/lib/server/modules/resource/index.js +184 -213
  242. package/lib/server/modules/resource/types.js +33 -42
  243. package/lib/server/modules/schedule/index.js +123 -135
  244. package/lib/server/modules/schedule/types.js +21 -14
  245. package/lib/server/modules/schedule/utils.js +163 -334
  246. package/lib/server/types.js +16 -4
  247. package/lib/server/utils/index.js +23 -25
  248. package/lib/server/utils/product.js +139 -196
  249. package/lib/server/utils/schedule.js +41 -34
  250. package/lib/server/utils/small-ticket.js +456 -478
  251. package/lib/server/utils/time.js +49 -40
  252. package/lib/solution/BaseSales/index.js +1016 -850
  253. package/lib/solution/BaseSales/types.js +37 -41
  254. package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
  255. package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
  256. package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
  257. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
  258. package/lib/solution/BaseSales/utils.js +140 -155
  259. package/lib/solution/BookingByStep/index.d.ts +1 -1
  260. package/lib/solution/BookingByStep/index.js +1340 -1530
  261. package/lib/solution/BookingByStep/types.js +99 -40
  262. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  263. package/lib/solution/BookingByStep/utils/products.js +52 -42
  264. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  265. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  266. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  267. package/lib/solution/BookingTicket/index.d.ts +1 -1
  268. package/lib/solution/BookingTicket/index.js +459 -543
  269. package/lib/solution/BookingTicket/types.js +77 -99
  270. package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
  271. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
  272. package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
  273. package/lib/solution/BookingTicket/utils/cartView.js +94 -110
  274. package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
  275. package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
  276. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
  277. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
  278. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
  279. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
  280. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
  281. package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
  282. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  283. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
  284. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
  285. package/lib/solution/BuyTickets/index.js +70 -67
  286. package/lib/solution/BuyTickets/types.js +38 -22
  287. package/lib/solution/Checkout/index.js +1158 -1451
  288. package/lib/solution/Checkout/types.js +61 -91
  289. package/lib/solution/Checkout/utils/index.js +156 -228
  290. package/lib/solution/PlaceOrder/index.js +0 -55
  291. package/lib/solution/RegisterAndLogin/config.js +460 -493
  292. package/lib/solution/RegisterAndLogin/index.js +630 -633
  293. package/lib/solution/RegisterAndLogin/types.js +76 -189
  294. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  295. package/lib/solution/Sales/index.js +320 -317
  296. package/lib/solution/Sales/types.js +33 -27
  297. package/lib/solution/ScanOrder/index.js +862 -831
  298. package/lib/solution/ScanOrder/types.js +34 -33
  299. package/lib/solution/ScanOrder/utils.js +371 -406
  300. package/lib/solution/ShopDiscount/index.js +233 -235
  301. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  302. package/lib/solution/ShopDiscount/types.js +37 -15
  303. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  304. package/lib/solution/ShopDiscount/utils.js +172 -309
  305. package/lib/solution/UnifiedBookingSales/index.js +405 -379
  306. package/lib/solution/UnifiedBookingSales/types.js +31 -12
  307. package/lib/solution/VenueBooking/index.d.ts +3 -31
  308. package/lib/solution/VenueBooking/index.js +916 -967
  309. package/lib/solution/VenueBooking/types.d.ts +1 -3
  310. package/lib/solution/VenueBooking/types.js +39 -20
  311. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  312. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  313. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  314. package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
  315. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  316. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  317. package/lib/solution/VenueBooking/utils.js +67 -130
  318. package/lib/solution/index.js +41 -124
  319. package/lib/store/createStore.js +29 -32
  320. package/lib/types/index.d.ts +1 -1
  321. package/lib/types/index.js +16 -4
  322. package/lib/utils/task.js +36 -36
  323. package/lib/utils/watch.js +47 -81
  324. package/package.json +2 -4
  325. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  326. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  327. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  328. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -1,66 +1,52 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- RegisterAndLoginImpl: true
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
8
  };
9
- exports.RegisterAndLoginImpl = void 0;
10
- var _BaseModule = require("../../modules/BaseModule");
11
- var _types = require("./types");
12
- Object.keys(_types).forEach(function (key) {
13
- if (key === "default" || key === "__esModule") return;
14
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
15
- if (key in exports && exports[key] === _types[key]) return;
16
- Object.defineProperty(exports, key, {
17
- enumerable: true,
18
- get: function () {
19
- return _types[key];
20
- }
21
- });
22
- });
23
- var _config = require("./config");
24
- Object.keys(_config).forEach(function (key) {
25
- if (key === "default" || key === "__esModule") return;
26
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
27
- if (key in exports && exports[key] === _config[key]) return;
28
- Object.defineProperty(exports, key, {
29
- enumerable: true,
30
- get: function () {
31
- return _config[key];
32
- }
33
- });
34
- });
35
- /**
36
- * 注册登录解决方案实现
37
- */
38
- class RegisterAndLoginImpl extends _BaseModule.BaseModule {
39
- // 提供给 baseModule 用的默认名称和默认版本
40
- defaultName = 'registerAndLogin';
41
- defaultVersion = '1.0.0';
42
- isSolution = true;
43
- request;
44
- window;
45
- store;
46
- apiCaller;
47
- otherParams = {};
48
- channel = 'default';
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
49
19
 
50
- // 内存缓存
51
- countriesCache = null;
20
+ // src/solution/RegisterAndLogin/index.ts
21
+ var RegisterAndLogin_exports = {};
22
+ __export(RegisterAndLogin_exports, {
23
+ RegisterAndLoginImpl: () => RegisterAndLoginImpl
24
+ });
25
+ module.exports = __toCommonJS(RegisterAndLogin_exports);
26
+ var import_BaseModule = require("../../modules/BaseModule");
27
+ var import_types = require("./types");
28
+ var import_config = require("./config");
29
+ __reExport(RegisterAndLogin_exports, require("./types"), module.exports);
30
+ __reExport(RegisterAndLogin_exports, require("./config"), module.exports);
31
+ var RegisterAndLoginImpl = class extends import_BaseModule.BaseModule {
52
32
  constructor(name, version) {
53
33
  super(name, version);
34
+ // 提供给 baseModule 用的默认名称和默认版本
35
+ this.defaultName = "registerAndLogin";
36
+ this.defaultVersion = "1.0.0";
37
+ this.isSolution = true;
38
+ this.otherParams = {};
39
+ this.channel = "default";
40
+ // 内存缓存
41
+ this.countriesCache = null;
54
42
  }
55
-
56
43
  /**
57
44
  * 重新发送邮箱注册链接
58
45
  */
59
46
  async resendEmailRegisterLink() {
60
47
  try {
61
- // 检查是否有保存的 code
62
48
  if (!this.store.emailRegisterLinkCode) {
63
- const error = '没有找到邮箱注册链接的 code,请先调用 sendEmailRegisterLink';
49
+ const error = "没有找到邮箱注册链接的 code,请先调用 sendEmailRegisterLink";
64
50
  this.store.error = error;
65
51
  return {
66
52
  status: false,
@@ -69,34 +55,43 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
69
55
  }
70
56
  this.store.isLoading = true;
71
57
  this.store.error = null;
72
- const response = await this.apiCaller.call('resendEmailRegisterLink', {
73
- code: this.store.emailRegisterLinkCode
74
- });
58
+ const response = await this.apiCaller.call(
59
+ "resendEmailRegisterLink",
60
+ { code: this.store.emailRegisterLinkCode }
61
+ );
75
62
  if (response.status) {
76
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationSent, {
77
- target: 'resend',
78
- purpose: _types.VerificationPurpose.REGISTER
79
- });
63
+ await this.core.effects.emit(
64
+ import_types.RegisterAndLoginHooks.onEmailVerificationSent,
65
+ {
66
+ target: "resend",
67
+ purpose: import_types.VerificationPurpose.REGISTER
68
+ }
69
+ );
80
70
  } else {
81
- this.store.error = response.message || '重新发送注册邀请链接失败';
82
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
83
- target: 'resend',
84
- error: this.store.error
85
- });
71
+ this.store.error = response.message || "重新发送注册邀请链接失败";
72
+ await this.core.effects.emit(
73
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
74
+ {
75
+ target: "resend",
76
+ error: this.store.error
77
+ }
78
+ );
86
79
  }
87
80
  return response;
88
81
  } catch (error) {
89
- this.store.error = '重新发送注册邀请链接失败';
90
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
91
- target: 'resend',
92
- error: this.store.error
93
- });
82
+ this.store.error = "重新发送注册邀请链接失败";
83
+ await this.core.effects.emit(
84
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
85
+ {
86
+ target: "resend",
87
+ error: this.store.error
88
+ }
89
+ );
94
90
  return error;
95
91
  } finally {
96
92
  this.store.isLoading = false;
97
93
  }
98
94
  }
99
-
100
95
  /**
101
96
  * 邮箱验证码注册
102
97
  * @param params 注册参数
@@ -106,40 +101,35 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
106
101
  try {
107
102
  this.store.isLoading = true;
108
103
  this.store.error = null;
109
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterStarted, params);
110
- const response = await this.apiCaller.call('emailCodeRegister', params);
104
+ await this.core.effects.emit(
105
+ import_types.RegisterAndLoginHooks.onRegisterStarted,
106
+ params
107
+ );
108
+ const response = await this.apiCaller.call(
109
+ "emailCodeRegister",
110
+ params
111
+ );
111
112
  if (response.status && response.data) {
112
- const {
113
- user,
114
- token,
115
- refreshToken,
116
- expiresAt
117
- } = response.data;
118
-
119
- // 如果注册成功并返回了 token,说明可以直接登录
113
+ const { user, token, refreshToken, expiresAt } = response.data;
120
114
  if (token) {
121
115
  this.store.currentUser = user;
122
116
  this.store.isLoggedIn = true;
123
-
124
- // 保存到本地存储
125
- // this.window.localStorage.setItem('auth_token', token);
126
- // this.window.localStorage.setItem('user_info', JSON.stringify(user));
127
- // if (refreshToken) {
128
- // this.window.localStorage.setItem('refresh_token', refreshToken);
129
- // }
130
117
  }
131
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterSuccess, response.data);
118
+ await this.core.effects.emit(
119
+ import_types.RegisterAndLoginHooks.onRegisterSuccess,
120
+ response.data
121
+ );
132
122
  } else {
133
- this.store.error = response.message || '邮箱验证码注册失败';
134
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterFailed, {
123
+ this.store.error = response.message || "邮箱验证码注册失败";
124
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onRegisterFailed, {
135
125
  error: this.store.error,
136
126
  params
137
127
  });
138
128
  }
139
129
  return response;
140
130
  } catch (error) {
141
- this.store.error = '邮箱验证码注册失败';
142
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterFailed, {
131
+ this.store.error = "邮箱验证码注册失败";
132
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onRegisterFailed, {
143
133
  error: this.store.error,
144
134
  params
145
135
  });
@@ -148,7 +138,6 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
148
138
  this.store.isLoading = false;
149
139
  }
150
140
  }
151
-
152
141
  /**
153
142
  * 手机验证码注册
154
143
  */
@@ -156,40 +145,35 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
156
145
  try {
157
146
  this.store.isLoading = true;
158
147
  this.store.error = null;
159
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterStarted, params);
160
- const response = await this.apiCaller.call('phoneCodeRegister', params);
148
+ await this.core.effects.emit(
149
+ import_types.RegisterAndLoginHooks.onRegisterStarted,
150
+ params
151
+ );
152
+ const response = await this.apiCaller.call(
153
+ "phoneCodeRegister",
154
+ params
155
+ );
161
156
  if (response.status && response.data) {
162
- const {
163
- user,
164
- token,
165
- refreshToken,
166
- expiresAt
167
- } = response.data;
168
-
169
- // 如果注册成功并返回了 token,说明可以直接登录
157
+ const { user, token, refreshToken, expiresAt } = response.data;
170
158
  if (token) {
171
159
  this.store.currentUser = user;
172
160
  this.store.isLoggedIn = true;
173
-
174
- // 保存到本地存储
175
- // this.window.localStorage.setItem('auth_token', token);
176
- // this.window.localStorage.setItem('user_info', JSON.stringify(user));
177
- // if (refreshToken) {
178
- // this.window.localStorage.setItem('refresh_token', refreshToken);
179
- // }
180
161
  }
181
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterSuccess, response.data);
162
+ await this.core.effects.emit(
163
+ import_types.RegisterAndLoginHooks.onRegisterSuccess,
164
+ response.data
165
+ );
182
166
  } else {
183
- this.store.error = response.message || '注册失败';
184
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterFailed, {
167
+ this.store.error = response.message || "注册失败";
168
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onRegisterFailed, {
185
169
  error: this.store.error,
186
170
  params
187
171
  });
188
172
  }
189
173
  return response;
190
174
  } catch (error) {
191
- this.store.error = error.message || '注册失败';
192
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterFailed, {
175
+ this.store.error = error.message || "注册失败";
176
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onRegisterFailed, {
193
177
  error: this.store.error,
194
178
  params
195
179
  });
@@ -200,8 +184,6 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
200
184
  }
201
185
  async initialize(core, options) {
202
186
  this.core = core;
203
-
204
- // 初始化状态
205
187
  this.store = {
206
188
  currentUser: null,
207
189
  isLoggedIn: false,
@@ -212,58 +194,48 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
212
194
  ...options.store
213
195
  };
214
196
  this.otherParams = options.otherParams || {};
215
-
216
- // 获取渠道信息
217
- this.channel = this.otherParams.channel || 'default';
218
-
219
- // 获取依赖的插件
220
- this.request = core.getPlugin('request');
221
- this.window = core.getPlugin('window');
197
+ this.channel = this.otherParams.channel || "default";
198
+ this.request = core.getPlugin("request");
199
+ this.window = core.getPlugin("window");
222
200
  if (!this.request) {
223
- throw new Error('RegisterAndLogin 模块需要 request 插件支持');
201
+ throw new Error("RegisterAndLogin 模块需要 request 插件支持");
224
202
  }
225
203
  if (!this.window) {
226
- throw new Error('RegisterAndLogin 模块需要 window 插件支持');
204
+ throw new Error("RegisterAndLogin 模块需要 window 插件支持");
227
205
  }
228
-
229
- // 创建 API 调用器
230
- this.apiCaller = (0, _config.createApiCaller)(this.request, this.channel);
231
-
232
- // 尝试从本地存储恢复登录状态
206
+ this.apiCaller = (0, import_config.createApiCaller)(this.request, this.channel);
233
207
  await this.restoreLoginState();
234
-
235
- // 预先调用获取区号的方法,初始内存缓存
236
208
  this.getCountries();
237
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onInited, {});
209
+ console.log("[RegisterAndLogin] 初始化完成");
210
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onInited, {});
238
211
  }
239
-
240
212
  /**
241
213
  * 从本地存储恢复登录状态
242
214
  */
243
215
  async restoreLoginState() {
244
216
  try {
245
- const token = this.window.localStorage.getItem('auth_token');
246
- const userInfo = this.window.localStorage.getItem('user_info');
217
+ const token = this.window.localStorage.getItem("auth_token");
218
+ const userInfo = this.window.localStorage.getItem("user_info");
247
219
  if (token && userInfo) {
248
220
  const user = JSON.parse(userInfo);
249
221
  this.store.currentUser = user;
250
222
  this.store.isLoggedIn = true;
251
-
252
- // 验证 token 是否仍然有效
253
223
  await this.validateToken(token);
254
224
  }
255
225
  } catch (error) {
256
- console.warn('[RegisterAndLogin] 恢复登录状态失败:', error);
226
+ console.warn("[RegisterAndLogin] 恢复登录状态失败:", error);
257
227
  this.clearLoginState();
258
228
  }
259
229
  }
260
-
261
230
  /**
262
231
  * 验证 token 有效性
263
232
  */
264
233
  async validateToken(token) {
265
234
  try {
266
- const response = await this.apiCaller.call('validateToken', token);
235
+ const response = await this.apiCaller.call(
236
+ "validateToken",
237
+ token
238
+ );
267
239
  if (response.status && response.data) {
268
240
  this.store.currentUser = response.data;
269
241
  return true;
@@ -272,23 +244,21 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
272
244
  return false;
273
245
  }
274
246
  } catch (error) {
275
- console.warn('[RegisterAndLogin] Token 验证失败:', error);
247
+ console.warn("[RegisterAndLogin] Token 验证失败:", error);
276
248
  this.clearLoginState();
277
249
  return false;
278
250
  }
279
251
  }
280
-
281
252
  /**
282
253
  * 清除登录状态
283
254
  */
284
255
  clearLoginState() {
285
256
  this.store.currentUser = null;
286
257
  this.store.isLoggedIn = false;
287
- this.window.localStorage.removeItem('auth_token');
288
- this.window.localStorage.removeItem('user_info');
289
- this.window.localStorage.removeItem('refresh_token');
258
+ this.window.localStorage.removeItem("auth_token");
259
+ this.window.localStorage.removeItem("user_info");
260
+ this.window.localStorage.removeItem("refresh_token");
290
261
  }
291
-
292
262
  /**
293
263
  * 发送邮箱验证码
294
264
  */
@@ -296,39 +266,50 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
296
266
  try {
297
267
  this.store.isLoading = true;
298
268
  this.store.error = null;
299
- const response = await this.apiCaller.call('sendEmailVerificationCode', params);
269
+ const response = await this.apiCaller.call(
270
+ "sendEmailVerificationCode",
271
+ params
272
+ );
300
273
  if (response.status) {
301
- // 记录验证码发送状态
302
274
  const now = Date.now();
303
275
  this.store.verificationCodeSent[params.target] = {
304
276
  sent: true,
305
277
  sentAt: now,
306
- expiresAt: now + 5 * 60 * 1000 // 5分钟过期
278
+ expiresAt: now + 5 * 60 * 1e3
279
+ // 5分钟过期
307
280
  };
308
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationSent, {
309
- target: params.target,
310
- purpose: params.purpose
311
- });
281
+ await this.core.effects.emit(
282
+ import_types.RegisterAndLoginHooks.onEmailVerificationSent,
283
+ {
284
+ target: params.target,
285
+ purpose: params.purpose
286
+ }
287
+ );
312
288
  } else {
313
- this.store.error = response.message || '发送验证码失败';
314
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
315
- target: params.target,
316
- error: this.store.error
317
- });
289
+ this.store.error = response.message || "发送验证码失败";
290
+ await this.core.effects.emit(
291
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
292
+ {
293
+ target: params.target,
294
+ error: this.store.error
295
+ }
296
+ );
318
297
  }
319
298
  return response;
320
299
  } catch (error) {
321
- this.store.error = '发送验证码失败';
322
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
323
- target: params.target,
324
- error: this.store.error
325
- });
300
+ this.store.error = "发送验证码失败";
301
+ await this.core.effects.emit(
302
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
303
+ {
304
+ target: params.target,
305
+ error: this.store.error
306
+ }
307
+ );
326
308
  return error;
327
309
  } finally {
328
310
  this.store.isLoading = false;
329
311
  }
330
312
  }
331
-
332
313
  /**
333
314
  * 发送邮箱登录验证码
334
315
  */
@@ -336,39 +317,50 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
336
317
  try {
337
318
  this.store.isLoading = true;
338
319
  this.store.error = null;
339
- const response = await this.apiCaller.call('sendEmailLoginCode', params);
320
+ const response = await this.apiCaller.call(
321
+ "sendEmailLoginCode",
322
+ params
323
+ );
340
324
  if (response.status) {
341
- // 记录验证码发送状态
342
325
  const now = Date.now();
343
326
  this.store.verificationCodeSent[params.target] = {
344
327
  sent: true,
345
328
  sentAt: now,
346
- expiresAt: now + 5 * 60 * 1000 // 5分钟过期
329
+ expiresAt: now + 5 * 60 * 1e3
330
+ // 5分钟过期
347
331
  };
348
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationSent, {
349
- target: params.target,
350
- purpose: params.purpose
351
- });
332
+ await this.core.effects.emit(
333
+ import_types.RegisterAndLoginHooks.onEmailVerificationSent,
334
+ {
335
+ target: params.target,
336
+ purpose: params.purpose
337
+ }
338
+ );
352
339
  } else {
353
- this.store.error = response.message || '发送验证码失败';
354
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
355
- target: params.target,
356
- error: this.store.error
357
- });
340
+ this.store.error = response.message || "发送验证码失败";
341
+ await this.core.effects.emit(
342
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
343
+ {
344
+ target: params.target,
345
+ error: this.store.error
346
+ }
347
+ );
358
348
  }
359
349
  return response;
360
350
  } catch (error) {
361
- this.store.error = '发送验证码失败';
362
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
363
- target: params.target,
364
- error: this.store.error
365
- });
351
+ this.store.error = "发送验证码失败";
352
+ await this.core.effects.emit(
353
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
354
+ {
355
+ target: params.target,
356
+ error: this.store.error
357
+ }
358
+ );
366
359
  return error;
367
360
  } finally {
368
361
  this.store.isLoading = false;
369
362
  }
370
363
  }
371
-
372
364
  /**
373
365
  * 发送手机号注册验证码
374
366
  */
@@ -376,84 +368,105 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
376
368
  try {
377
369
  this.store.isLoading = true;
378
370
  this.store.error = null;
379
- const response = await this.apiCaller.call('sendSmsRegisterCode', params);
371
+ const response = await this.apiCaller.call(
372
+ "sendSmsRegisterCode",
373
+ params
374
+ );
380
375
  if (response.status) {
381
- // 记录验证码发送状态
382
376
  const now = Date.now();
383
377
  this.store.verificationCodeSent[params.phone] = {
384
378
  sent: true,
385
379
  sentAt: now,
386
- expiresAt: now + 5 * 60 * 1000 // 5分钟过期
380
+ expiresAt: now + 5 * 60 * 1e3
381
+ // 5分钟过期
387
382
  };
388
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onSmsVerificationSent, {
389
- target: params.phone,
390
- purpose: _types.VerificationPurpose.REGISTER
391
- });
383
+ await this.core.effects.emit(
384
+ import_types.RegisterAndLoginHooks.onSmsVerificationSent,
385
+ {
386
+ target: params.phone,
387
+ purpose: import_types.VerificationPurpose.REGISTER
388
+ }
389
+ );
392
390
  } else {
393
- this.store.error = response.message || '发送注册验证码失败';
394
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onSmsVerificationFailed, {
395
- target: params.phone,
396
- error: this.store.error
397
- });
391
+ this.store.error = response.message || "发送注册验证码失败";
392
+ await this.core.effects.emit(
393
+ import_types.RegisterAndLoginHooks.onSmsVerificationFailed,
394
+ {
395
+ target: params.phone,
396
+ error: this.store.error
397
+ }
398
+ );
398
399
  }
399
400
  return response;
400
401
  } catch (error) {
401
- this.store.error = '发送注册验证码失败';
402
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onSmsVerificationFailed, {
403
- target: params.phone,
404
- error: this.store.error
405
- });
402
+ this.store.error = "发送注册验证码失败";
403
+ await this.core.effects.emit(
404
+ import_types.RegisterAndLoginHooks.onSmsVerificationFailed,
405
+ {
406
+ target: params.phone,
407
+ error: this.store.error
408
+ }
409
+ );
406
410
  return error;
407
411
  } finally {
408
412
  this.store.isLoading = false;
409
413
  }
410
414
  }
411
-
412
415
  /**
413
416
  * 发送邮箱注册邀请链接
414
417
  */
415
418
  async sendEmailRegisterLink(email) {
419
+ var _a;
416
420
  try {
417
421
  this.store.isLoading = true;
418
422
  this.store.error = null;
419
- const response = await this.apiCaller.call('sendEmailRegisterLink', email);
423
+ const response = await this.apiCaller.call(
424
+ "sendEmailRegisterLink",
425
+ email
426
+ );
420
427
  if (response.status) {
421
- // 保存返回的 code
422
- if (response.data?.code) {
428
+ if ((_a = response.data) == null ? void 0 : _a.code) {
423
429
  this.store.emailRegisterLinkCode = response.data.code;
424
430
  }
425
-
426
- // 记录邀请链接发送状态
427
431
  const now = Date.now();
428
432
  this.store.verificationCodeSent[email] = {
429
433
  sent: true,
430
434
  sentAt: now,
431
- expiresAt: now + 24 * 60 * 60 * 1000 // 24小时过期
435
+ expiresAt: now + 24 * 60 * 60 * 1e3
436
+ // 24小时过期
432
437
  };
433
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationSent, {
434
- target: email,
435
- purpose: _types.VerificationPurpose.REGISTER
436
- });
438
+ await this.core.effects.emit(
439
+ import_types.RegisterAndLoginHooks.onEmailVerificationSent,
440
+ {
441
+ target: email,
442
+ purpose: import_types.VerificationPurpose.REGISTER
443
+ }
444
+ );
437
445
  } else {
438
- this.store.error = response.message || '发送注册邀请链接失败';
439
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
440
- target: email,
441
- error: this.store.error
442
- });
446
+ this.store.error = response.message || "发送注册邀请链接失败";
447
+ await this.core.effects.emit(
448
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
449
+ {
450
+ target: email,
451
+ error: this.store.error
452
+ }
453
+ );
443
454
  }
444
455
  return response;
445
456
  } catch (error) {
446
- this.store.error = '发送注册邀请链接失败';
447
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
448
- target: email,
449
- error: this.store.error
450
- });
457
+ this.store.error = "发送注册邀请链接失败";
458
+ await this.core.effects.emit(
459
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
460
+ {
461
+ target: email,
462
+ error: this.store.error
463
+ }
464
+ );
451
465
  return error;
452
466
  } finally {
453
467
  this.store.isLoading = false;
454
468
  }
455
469
  }
456
-
457
470
  /**
458
471
  * 验证邮箱注册链接
459
472
  */
@@ -461,32 +474,43 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
461
474
  try {
462
475
  this.store.isLoading = true;
463
476
  this.store.error = null;
464
- const response = await this.apiCaller.call('verifyEmailRegistrationLink', params);
477
+ const response = await this.apiCaller.call(
478
+ "verifyEmailRegistrationLink",
479
+ params
480
+ );
465
481
  if (response.status) {
466
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationVerified, {
467
- target: 'email-registration-link',
468
- purpose: _types.VerificationPurpose.REGISTER
469
- });
482
+ await this.core.effects.emit(
483
+ import_types.RegisterAndLoginHooks.onEmailVerificationVerified,
484
+ {
485
+ target: "email-registration-link",
486
+ purpose: import_types.VerificationPurpose.REGISTER
487
+ }
488
+ );
470
489
  } else {
471
- this.store.error = response.message || '邮箱注册链接验证失败';
472
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
473
- target: 'email-registration-link',
474
- error: this.store.error
475
- });
490
+ this.store.error = response.message || "邮箱注册链接验证失败";
491
+ await this.core.effects.emit(
492
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
493
+ {
494
+ target: "email-registration-link",
495
+ error: this.store.error
496
+ }
497
+ );
476
498
  }
477
499
  return response;
478
500
  } catch (error) {
479
- this.store.error = '邮箱注册链接验证失败';
480
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
481
- target: 'email-registration-link',
482
- error: this.store.error
483
- });
501
+ this.store.error = "邮箱注册链接验证失败";
502
+ await this.core.effects.emit(
503
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
504
+ {
505
+ target: "email-registration-link",
506
+ error: this.store.error
507
+ }
508
+ );
484
509
  return error;
485
510
  } finally {
486
511
  this.store.isLoading = false;
487
512
  }
488
513
  }
489
-
490
514
  /**
491
515
  * 邮箱密码登录
492
516
  */
@@ -494,46 +518,45 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
494
518
  try {
495
519
  this.store.isLoading = true;
496
520
  this.store.error = null;
497
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginStarted, {
498
- type: 'email-password',
521
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginStarted, {
522
+ type: "email-password",
499
523
  email: params.email
500
524
  });
501
- const response = await this.apiCaller.call('emailPasswordLogin', params);
525
+ const response = await this.apiCaller.call(
526
+ "emailPasswordLogin",
527
+ params
528
+ );
502
529
  if (response.status && response.data) {
503
- // 保存用户信息和 token
504
530
  this.store.isLoggedIn = true;
505
531
  this.store.userInfo = response.data.user;
506
532
  this.store.token = response.data.token;
507
-
508
- // 如果有 refreshToken,也保存
509
533
  if (response.data.refreshToken) {
510
534
  this.store.refreshToken = response.data.refreshToken;
511
535
  }
512
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginSuccess, {
536
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginSuccess, {
513
537
  user: response.data.user,
514
538
  token: response.data.token,
515
- loginType: 'email-password'
539
+ loginType: "email-password"
516
540
  });
517
541
  } else {
518
- this.store.error = response.message || '邮箱密码登录失败';
519
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
542
+ this.store.error = response.message || "邮箱密码登录失败";
543
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
520
544
  error: this.store.error,
521
- loginType: 'email-password'
545
+ loginType: "email-password"
522
546
  });
523
547
  }
524
548
  return response;
525
549
  } catch (error) {
526
- this.store.error = '邮箱密码登录失败';
527
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
550
+ this.store.error = "邮箱密码登录失败";
551
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
528
552
  error: this.store.error,
529
- loginType: 'email-password'
553
+ loginType: "email-password"
530
554
  });
531
555
  return error;
532
556
  } finally {
533
557
  this.store.isLoading = false;
534
558
  }
535
559
  }
536
-
537
560
  /**
538
561
  * 验证验证码
539
562
  */
@@ -541,16 +564,19 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
541
564
  try {
542
565
  this.store.isLoading = true;
543
566
  this.store.error = null;
544
- const response = await this.apiCaller.call('verifyCode', params);
567
+ const response = await this.apiCaller.call(
568
+ "verifyCode",
569
+ params
570
+ );
545
571
  if (response.status) {
546
- const hookName = params.type === _types.VerificationCodeType.EMAIL ? _types.RegisterAndLoginHooks.onEmailVerificationVerified : _types.RegisterAndLoginHooks.onSmsVerificationVerified;
572
+ const hookName = params.type === import_types.VerificationCodeType.EMAIL ? import_types.RegisterAndLoginHooks.onEmailVerificationVerified : import_types.RegisterAndLoginHooks.onSmsVerificationVerified;
547
573
  await this.core.effects.emit(hookName, {
548
574
  target: params.target,
549
575
  purpose: params.purpose
550
576
  });
551
577
  } else {
552
- this.store.error = response.message || '验证码验证失败';
553
- const hookName = params.type === _types.VerificationCodeType.EMAIL ? _types.RegisterAndLoginHooks.onEmailVerificationFailed : _types.RegisterAndLoginHooks.onSmsVerificationFailed;
578
+ this.store.error = response.message || "验证码验证失败";
579
+ const hookName = params.type === import_types.VerificationCodeType.EMAIL ? import_types.RegisterAndLoginHooks.onEmailVerificationFailed : import_types.RegisterAndLoginHooks.onSmsVerificationFailed;
554
580
  await this.core.effects.emit(hookName, {
555
581
  target: params.target,
556
582
  error: this.store.error
@@ -558,13 +584,12 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
558
584
  }
559
585
  return response;
560
586
  } catch (error) {
561
- this.store.error = '验证码验证失败';
587
+ this.store.error = "验证码验证失败";
562
588
  return error;
563
589
  } finally {
564
590
  this.store.isLoading = false;
565
591
  }
566
592
  }
567
-
568
593
  /**
569
594
  * 用户注册
570
595
  */
@@ -572,40 +597,35 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
572
597
  try {
573
598
  this.store.isLoading = true;
574
599
  this.store.error = null;
575
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterStarted, params);
576
- const response = await this.apiCaller.call('register', params);
600
+ await this.core.effects.emit(
601
+ import_types.RegisterAndLoginHooks.onRegisterStarted,
602
+ params
603
+ );
604
+ const response = await this.apiCaller.call(
605
+ "register",
606
+ params
607
+ );
577
608
  if (response.status && response.data) {
578
- const {
579
- user,
580
- token,
581
- refreshToken,
582
- expiresAt
583
- } = response.data;
584
-
585
- // 如果注册成功并返回了 token,说明可以直接登录
609
+ const { user, token, refreshToken, expiresAt } = response.data;
586
610
  if (token) {
587
611
  this.store.currentUser = user;
588
612
  this.store.isLoggedIn = true;
589
-
590
- // 保存到本地存储
591
- // this.window.localStorage.setItem('auth_token', token);
592
- // this.window.localStorage.setItem('user_info', JSON.stringify(user));
593
- // if (refreshToken) {
594
- // this.window.localStorage.setItem('refresh_token', refreshToken);
595
- // }
596
613
  }
597
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterSuccess, response.data);
614
+ await this.core.effects.emit(
615
+ import_types.RegisterAndLoginHooks.onRegisterSuccess,
616
+ response.data
617
+ );
598
618
  } else {
599
- this.store.error = response.message || '注册失败';
600
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterFailed, {
619
+ this.store.error = response.message || "注册失败";
620
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onRegisterFailed, {
601
621
  error: this.store.error,
602
622
  params
603
623
  });
604
624
  }
605
625
  return response;
606
626
  } catch (error) {
607
- this.store.error = '注册失败';
608
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onRegisterFailed, {
627
+ this.store.error = "注册失败";
628
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onRegisterFailed, {
609
629
  error: this.store.error,
610
630
  params
611
631
  });
@@ -614,7 +634,6 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
614
634
  this.store.isLoading = false;
615
635
  }
616
636
  }
617
-
618
637
  /**
619
638
  * 用户登录
620
639
  */
@@ -622,36 +641,33 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
622
641
  try {
623
642
  this.store.isLoading = true;
624
643
  this.store.error = null;
625
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginStarted, params);
626
- const response = await this.apiCaller.call('login', params);
644
+ await this.core.effects.emit(
645
+ import_types.RegisterAndLoginHooks.onLoginStarted,
646
+ params
647
+ );
648
+ const response = await this.apiCaller.call(
649
+ "login",
650
+ params
651
+ );
627
652
  if (response.status && response.data) {
628
- const {
629
- user,
630
- token,
631
- refreshToken
632
- } = response.data;
653
+ const { user, token, refreshToken } = response.data;
633
654
  this.store.currentUser = user;
634
655
  this.store.isLoggedIn = true;
635
-
636
- // 保存到本地存储
637
- // this.window.localStorage.setItem('auth_token', token);
638
- // this.window.localStorage.setItem('user_info', JSON.stringify(user));
639
- // if (refreshToken) {
640
- // this.window.localStorage.setItem('refresh_token', refreshToken);
641
- // }
642
-
643
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginSuccess, response.data);
656
+ await this.core.effects.emit(
657
+ import_types.RegisterAndLoginHooks.onLoginSuccess,
658
+ response.data
659
+ );
644
660
  } else {
645
- this.store.error = response.message || '登录失败';
646
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
661
+ this.store.error = response.message || "登录失败";
662
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
647
663
  error: this.store.error,
648
664
  params
649
665
  });
650
666
  }
651
667
  return response;
652
668
  } catch (error) {
653
- this.store.error = '登录失败';
654
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
669
+ this.store.error = "登录失败";
670
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
655
671
  error: this.store.error,
656
672
  params
657
673
  });
@@ -660,7 +676,6 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
660
676
  this.store.isLoading = false;
661
677
  }
662
678
  }
663
-
664
679
  /**
665
680
  * OAuth 登录
666
681
  */
@@ -668,36 +683,30 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
668
683
  try {
669
684
  this.store.isLoading = true;
670
685
  this.store.error = null;
671
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onOAuthLoginStarted, params);
672
- const response = await this.apiCaller.call('oauthLogin', params);
686
+ await this.core.effects.emit(
687
+ import_types.RegisterAndLoginHooks.onOAuthLoginStarted,
688
+ params
689
+ );
690
+ const response = await this.apiCaller.call("oauthLogin", params);
673
691
  if (response.status && response.data) {
674
- const {
675
- user,
676
- token,
677
- refreshToken
678
- } = response.data;
692
+ const { user, token, refreshToken } = response.data;
679
693
  this.store.currentUser = user;
680
694
  this.store.isLoggedIn = true;
681
-
682
- // 保存到本地存储
683
- // this.window.localStorage.setItem('auth_token', token);
684
- // this.window.localStorage.setItem('user_info', JSON.stringify(user));
685
- // if (refreshToken) {
686
- // this.window.localStorage.setItem('refresh_token', refreshToken);
687
- // }
688
-
689
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onOAuthLoginSuccess, response.data);
695
+ await this.core.effects.emit(
696
+ import_types.RegisterAndLoginHooks.onOAuthLoginSuccess,
697
+ response.data
698
+ );
690
699
  } else {
691
- this.store.error = response.message || 'OAuth 登录失败';
692
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onOAuthLoginFailed, {
700
+ this.store.error = response.message || "OAuth 登录失败";
701
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onOAuthLoginFailed, {
693
702
  error: this.store.error,
694
703
  params
695
704
  });
696
705
  }
697
706
  return response;
698
707
  } catch (error) {
699
- this.store.error = 'OAuth 登录失败';
700
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onOAuthLoginFailed, {
708
+ this.store.error = "OAuth 登录失败";
709
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onOAuthLoginFailed, {
701
710
  error: this.store.error,
702
711
  params
703
712
  });
@@ -706,110 +715,116 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
706
715
  this.store.isLoading = false;
707
716
  }
708
717
  }
709
-
710
718
  /**
711
719
  * 用户登出
712
720
  */
713
721
  async logout() {
714
722
  try {
715
- // 调用后端登出接口
716
- await this.apiCaller.call('logout');
723
+ await this.apiCaller.call("logout");
717
724
  } catch (error) {
718
- console.warn('[RegisterAndLogin] 登出接口调用失败:', error);
725
+ console.warn("[RegisterAndLogin] 登出接口调用失败:", error);
719
726
  } finally {
720
- // 无论后端接口是否成功,都清除本地状态
721
727
  this.clearLoginState();
722
728
  }
723
729
  }
724
-
725
730
  /** 发送重置密码邮箱链接 */
726
731
  async sendResetPasswordLink(params) {
727
732
  try {
728
733
  this.store.isLoading = true;
729
734
  this.store.error = null;
730
- const response = await this.apiCaller.call('sendResetPasswordLink', params);
735
+ const response = await this.apiCaller.call(
736
+ "sendResetPasswordLink",
737
+ params
738
+ );
731
739
  if (response.status) {
732
740
  this.store.verificationCodeSent[params.email] = {
733
741
  sent: true,
734
742
  sentAt: Date.now(),
735
- expiresAt: Date.now() + 5 * 60 * 1000 // 5分钟后过期
743
+ expiresAt: Date.now() + 5 * 60 * 1e3
744
+ // 5分钟后过期
736
745
  };
737
- this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationSent, {
746
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onEmailVerificationSent, {
738
747
  email: params.email,
739
- purpose: 'reset-password-link'
748
+ purpose: "reset-password-link"
740
749
  });
741
750
  } else {
742
- this.store.error = response.message || '发送重置密码链接失败';
751
+ this.store.error = response.message || "发送重置密码链接失败";
743
752
  }
744
753
  return response;
745
754
  } catch (error) {
746
- this.store.error = '发送重置密码链接失败';
755
+ this.store.error = "发送重置密码链接失败";
747
756
  return error;
748
757
  } finally {
749
758
  this.store.isLoading = false;
750
759
  }
751
760
  }
752
-
753
761
  /** 检测重置密码链接code有效性 */
754
762
  async checkResetPasswordCode(params) {
755
763
  try {
756
764
  this.store.isLoading = true;
757
765
  this.store.error = null;
758
- const response = await this.apiCaller.call('checkResetPasswordCode', params);
766
+ const response = await this.apiCaller.call(
767
+ "checkResetPasswordCode",
768
+ params
769
+ );
759
770
  if (!response.status) {
760
- this.store.error = response.message || '验证码无效';
771
+ this.store.error = response.message || "验证码无效";
761
772
  }
762
773
  return response;
763
774
  } catch (error) {
764
- this.store.error = '验证码验证失败';
775
+ this.store.error = "验证码验证失败";
765
776
  return error;
766
777
  } finally {
767
778
  this.store.isLoading = false;
768
779
  }
769
780
  }
770
-
771
781
  /** 校验邮件链接 code 有效性 */
772
782
  async checkEmailLinkCode(params) {
773
783
  try {
774
784
  this.store.isLoading = true;
775
785
  this.store.error = null;
776
- const response = await this.apiCaller.call('checkEmailLinkCode', params);
786
+ const response = await this.apiCaller.call(
787
+ "checkEmailLinkCode",
788
+ params
789
+ );
777
790
  if (!response.status) {
778
- this.store.error = response.message || '邮件链接验证码无效';
791
+ this.store.error = response.message || "邮件链接验证码无效";
779
792
  }
780
793
  return response;
781
794
  } catch (error) {
782
- this.store.error = '邮件链接验证码验证失败';
795
+ this.store.error = "邮件链接验证码验证失败";
783
796
  return error;
784
797
  } finally {
785
798
  this.store.isLoading = false;
786
799
  }
787
800
  }
788
-
789
801
  /** 通过code重置密码 */
790
802
  async resetPasswordByCode(params) {
791
803
  try {
792
804
  this.store.isLoading = true;
793
805
  this.store.error = null;
794
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetStarted, {
806
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetStarted, {
795
807
  code: params.code
796
808
  });
797
- const response = await this.apiCaller.call('resetPasswordByCode', params);
809
+ const response = await this.apiCaller.call(
810
+ "resetPasswordByCode",
811
+ params
812
+ );
798
813
  if (response.status) {
799
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetSuccess, {
814
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetSuccess, {
800
815
  code: params.code
801
816
  });
802
817
  } else {
803
- this.store.error = response.message || '密码重置失败';
804
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetFailed, {
818
+ this.store.error = response.message || "密码重置失败";
819
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetFailed, {
805
820
  code: params.code,
806
821
  error: this.store.error
807
822
  });
808
823
  }
809
824
  return response;
810
825
  } catch (error) {
811
- this.store.error = '密码重置失败';
812
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetFailed, {
826
+ this.store.error = "密码重置失败";
827
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetFailed, {
813
828
  code: params.code,
814
829
  error: this.store.error
815
830
  });
@@ -818,7 +833,6 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
818
833
  this.store.isLoading = false;
819
834
  }
820
835
  }
821
-
822
836
  /**
823
837
  * 重置密码
824
838
  */
@@ -826,64 +840,65 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
826
840
  try {
827
841
  this.store.isLoading = true;
828
842
  this.store.error = null;
829
-
830
- // 根据类型触发不同的事件
831
- if (params.type === 'email') {
832
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetStarted, {
843
+ if (params.type === "email") {
844
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetStarted, {
833
845
  email: params.target.email
834
846
  });
835
847
  } else {
836
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetStarted, {
848
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetStarted, {
837
849
  phone: params.target.phone
838
850
  });
839
851
  }
840
852
  let response;
841
- if (params.type === 'email') {
842
- // 邮箱重置密码
853
+ if (params.type === "email") {
843
854
  if (!params.target.email) {
844
- throw new Error('邮箱地址不能为空');
855
+ throw new Error("邮箱地址不能为空");
845
856
  }
846
- response = await this.apiCaller.call('resetPasswordByEmail', {
847
- email: params.target.email,
848
- password: params.password,
849
- code: params.code
850
- });
857
+ response = await this.apiCaller.call(
858
+ "resetPasswordByEmail",
859
+ {
860
+ email: params.target.email,
861
+ password: params.password,
862
+ code: params.code
863
+ }
864
+ );
851
865
  } else {
852
- // 手机号重置密码
853
866
  if (!params.target.phone || !params.target.country_calling_code) {
854
- throw new Error('手机号和国家区号不能为空');
867
+ throw new Error("手机号和国家区号不能为空");
855
868
  }
856
- response = await this.apiCaller.call('resetPasswordByPhone', {
857
- phone: params.target.phone,
858
- password: params.password,
859
- code: params.code,
860
- country_calling_code: params.target.country_calling_code
861
- });
869
+ response = await this.apiCaller.call(
870
+ "resetPasswordByPhone",
871
+ {
872
+ phone: params.target.phone,
873
+ password: params.password,
874
+ code: params.code,
875
+ country_calling_code: params.target.country_calling_code
876
+ }
877
+ );
862
878
  }
863
879
  if (response.status) {
864
- // 清除验证码发送状态
865
- const key = params.type === 'email' ? params.target.email : params.target.phone;
880
+ const key = params.type === "email" ? params.target.email : params.target.phone;
866
881
  if (this.store.verificationCodeSent[key]) {
867
882
  delete this.store.verificationCodeSent[key];
868
883
  }
869
- if (params.type === 'email') {
870
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetSuccess, {
884
+ if (params.type === "email") {
885
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetSuccess, {
871
886
  email: params.target.email
872
887
  });
873
888
  } else {
874
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetSuccess, {
889
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetSuccess, {
875
890
  phone: params.target.phone
876
891
  });
877
892
  }
878
893
  } else {
879
- this.store.error = response.message || '密码重置失败';
880
- if (params.type === 'email') {
881
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetFailed, {
894
+ this.store.error = response.message || "密码重置失败";
895
+ if (params.type === "email") {
896
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetFailed, {
882
897
  email: params.target.email,
883
898
  error: this.store.error
884
899
  });
885
900
  } else {
886
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetFailed, {
901
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetFailed, {
887
902
  phone: params.target.phone,
888
903
  error: this.store.error
889
904
  });
@@ -891,14 +906,14 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
891
906
  }
892
907
  return response;
893
908
  } catch (error) {
894
- this.store.error = '密码重置失败';
895
- if (params.type === 'email') {
896
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetFailed, {
909
+ this.store.error = "密码重置失败";
910
+ if (params.type === "email") {
911
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetFailed, {
897
912
  email: params.target.email,
898
913
  error: this.store.error
899
914
  });
900
915
  } else {
901
- this.core.effects.emit(_types.RegisterAndLoginHooks.onPasswordResetFailed, {
916
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onPasswordResetFailed, {
902
917
  phone: params.target.phone,
903
918
  error: this.store.error
904
919
  });
@@ -908,83 +923,93 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
908
923
  this.store.isLoading = false;
909
924
  }
910
925
  }
911
-
912
926
  /** 发送手机登录验证码 */
913
927
  async sendSmsLoginCode(params) {
914
928
  try {
915
929
  this.store.isLoading = true;
916
930
  this.store.error = null;
917
- const response = await this.apiCaller.call('sendSmsLoginCode', params);
931
+ const response = await this.apiCaller.call(
932
+ "sendSmsLoginCode",
933
+ params
934
+ );
918
935
  if (response.status) {
919
- // 记录验证码发送状态
920
936
  const now = Date.now();
921
937
  this.store.verificationCodeSent[params.phone] = {
922
938
  sent: true,
923
939
  sentAt: now,
924
- expiresAt: now + 5 * 60 * 1000 // 5分钟过期
940
+ expiresAt: now + 5 * 60 * 1e3
941
+ // 5分钟过期
925
942
  };
926
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onSmsVerificationSent, {
927
- target: params.phone,
928
- purpose: _types.VerificationPurpose.LOGIN
929
- });
943
+ await this.core.effects.emit(
944
+ import_types.RegisterAndLoginHooks.onSmsVerificationSent,
945
+ {
946
+ target: params.phone,
947
+ purpose: import_types.VerificationPurpose.LOGIN
948
+ }
949
+ );
930
950
  } else {
931
- this.store.error = response.message || '发送登录验证码失败';
932
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onSmsVerificationFailed, {
933
- target: params.phone,
934
- error: this.store.error
935
- });
951
+ this.store.error = response.message || "发送登录验证码失败";
952
+ await this.core.effects.emit(
953
+ import_types.RegisterAndLoginHooks.onSmsVerificationFailed,
954
+ {
955
+ target: params.phone,
956
+ error: this.store.error
957
+ }
958
+ );
936
959
  }
937
960
  return response;
938
961
  } catch (error) {
939
- this.store.error = '发送登录验证码失败';
940
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onSmsVerificationFailed, {
941
- target: params.phone,
942
- error: this.store.error
943
- });
962
+ this.store.error = "发送登录验证码失败";
963
+ await this.core.effects.emit(
964
+ import_types.RegisterAndLoginHooks.onSmsVerificationFailed,
965
+ {
966
+ target: params.phone,
967
+ error: this.store.error
968
+ }
969
+ );
944
970
  return error;
945
971
  } finally {
946
972
  this.store.isLoading = false;
947
973
  }
948
974
  }
949
-
950
975
  /** 手机号+短信验证码登录 */
951
976
  async phoneCodeLogin(params) {
952
977
  try {
953
978
  this.store.isLoading = true;
954
979
  this.store.error = null;
955
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginStarted, {
956
- type: 'phone-code',
980
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginStarted, {
981
+ type: "phone-code",
957
982
  phone: params.phone
958
983
  });
959
- const response = await this.apiCaller.call('phoneCodeLogin', params);
984
+ const response = await this.apiCaller.call(
985
+ "phoneCodeLogin",
986
+ params
987
+ );
960
988
  if (response.status && response.data) {
961
- // 保存用户信息和 token
962
989
  this.store.isLoggedIn = true;
963
990
  this.store.userInfo = response.data.user;
964
991
  this.store.token = response.data.token;
965
-
966
- // 如果有 refreshToken,也保存
967
992
  if (response.data.refreshToken) {
968
993
  this.store.refreshToken = response.data.refreshToken;
969
994
  }
970
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginSuccess, {
995
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginSuccess, {
971
996
  user: response.data.user,
972
997
  token: response.data.token,
973
- loginType: 'phone-code'
998
+ loginType: "phone-code"
974
999
  });
975
1000
  } else {
976
- this.store.error = response.message || '手机号验证码登录失败';
977
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
1001
+ this.store.error = response.message || "手机号验证码登录失败";
1002
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
978
1003
  error: this.store.error,
979
- loginType: 'phone-code'
1004
+ loginType: "phone-code"
980
1005
  });
981
1006
  }
982
1007
  return response;
983
1008
  } catch (error) {
984
- this.store.error = '手机号验证码登录失败';
985
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
1009
+ this.store.error = "手机号验证码登录失败";
1010
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
986
1011
  error: this.store.error,
987
- loginType: 'phone-code'
1012
+ loginType: "phone-code"
988
1013
  });
989
1014
  return error;
990
1015
  } finally {
@@ -992,206 +1017,196 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
992
1017
  }
993
1018
  }
994
1019
  formatLoginParams(params) {
995
- // 获取当前浏览器窗口的 URL
996
1020
  const currentUrl = this.window.location.href;
997
- // 使用 URL 对象解析 URL
998
- let urlObj = new URL(currentUrl || '');
999
- // 获取 customer 参数的值
1000
- let source_customer_id = urlObj.searchParams.get('customer');
1021
+ let urlObj = new URL(currentUrl || "");
1022
+ let source_customer_id = urlObj.searchParams.get("customer");
1001
1023
  if (source_customer_id) {
1002
1024
  params.source_customer_id = parseInt(source_customer_id);
1003
1025
  }
1004
1026
  return params;
1005
1027
  }
1006
-
1007
1028
  /** Guest 登录 */
1008
1029
  async guestLogin() {
1030
+ var _a, _b;
1009
1031
  try {
1010
1032
  this.store.isLoading = true;
1011
1033
  this.store.error = null;
1012
- this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginStarted, {
1013
- type: 'guest'
1034
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginStarted, {
1035
+ type: "guest"
1014
1036
  });
1015
- // 匿名登录 code
1016
- let guestCode = this.window.localStorage.getItem('guest_code') || '';
1037
+ let guestCode = this.window.localStorage.getItem("guest_code") || "";
1017
1038
  let param = {
1018
1039
  login_channel: this.channel
1019
1040
  };
1020
1041
  if (guestCode) {
1021
1042
  param.guest_code = guestCode;
1022
1043
  }
1023
-
1024
- // 获取邀请id
1025
1044
  param = this.formatLoginParams(param);
1026
- const response = await this.apiCaller.call('guestLogin', param);
1045
+ const response = await this.apiCaller.call("guestLogin", param);
1027
1046
  if (response.status && response.data) {
1028
- // 保存用户信息和 token
1029
1047
  this.store.isLoggedIn = true;
1030
1048
  this.store.userInfo = response.data.user;
1031
1049
  this.store.token = response.data.token;
1032
-
1033
- // 如果有 refreshToken,也保存
1034
1050
  if (response.data.refreshToken) {
1035
1051
  this.store.refreshToken = response.data.refreshToken;
1036
1052
  }
1037
-
1038
- // 设置匿名登录code
1039
- if (response.data?.customer?.guest_code) {
1040
- this.window.localStorage.setItem('guest_code', response.data.customer.guest_code);
1053
+ if ((_b = (_a = response.data) == null ? void 0 : _a.customer) == null ? void 0 : _b.guest_code) {
1054
+ this.window.localStorage.setItem("guest_code", response.data.customer.guest_code);
1041
1055
  }
1042
- this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginSuccess, {
1056
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginSuccess, {
1043
1057
  user: response.data.user,
1044
1058
  token: response.data.token,
1045
- loginType: 'guest'
1059
+ loginType: "guest"
1046
1060
  });
1047
1061
  } else {
1048
- this.store.error = response.message || 'Guest 登录失败';
1049
- this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
1062
+ this.store.error = response.message || "Guest 登录失败";
1063
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
1050
1064
  error: this.store.error,
1051
- loginType: 'guest'
1065
+ loginType: "guest"
1052
1066
  });
1053
1067
  }
1054
1068
  return response;
1055
1069
  } catch (error) {
1056
- this.store.error = 'Guest 登录失败';
1057
- this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
1070
+ this.store.error = "Guest 登录失败";
1071
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
1058
1072
  error: this.store.error,
1059
- loginType: 'guest'
1073
+ loginType: "guest"
1060
1074
  });
1061
1075
  return error;
1062
1076
  } finally {
1063
1077
  this.store.isLoading = false;
1064
1078
  }
1065
1079
  }
1066
-
1067
1080
  /** 检查邮箱是否已注册 */
1068
1081
  async checkEmailExists(params) {
1069
1082
  try {
1070
1083
  this.store.isLoading = true;
1071
1084
  this.store.error = null;
1072
- const response = await this.apiCaller.call('checkEmailExists', params);
1085
+ const response = await this.apiCaller.call("checkEmailExists", params);
1073
1086
  if (!response.status) {
1074
- this.store.error = response.message || '检查邮箱失败';
1087
+ this.store.error = response.message || "检查邮箱失败";
1075
1088
  }
1076
1089
  return response;
1077
1090
  } catch (error) {
1078
- this.store.error = '检查邮箱失败';
1091
+ this.store.error = "检查邮箱失败";
1079
1092
  return error;
1080
1093
  } finally {
1081
1094
  this.store.isLoading = false;
1082
1095
  }
1083
1096
  }
1084
-
1085
1097
  /** 检查邮箱验证码是否有效 */
1086
1098
  async checkEmailCode(params) {
1087
1099
  try {
1088
1100
  this.store.isLoading = true;
1089
1101
  this.store.error = null;
1090
- const response = await this.apiCaller.call('checkEmailCode', params);
1102
+ const response = await this.apiCaller.call("checkEmailCode", params);
1091
1103
  if (!response.status) {
1092
- this.store.error = response.message || '检查邮箱验证码失败';
1104
+ this.store.error = response.message || "检查邮箱验证码失败";
1093
1105
  }
1094
1106
  return response;
1095
1107
  } catch (error) {
1096
- this.store.error = '检查邮箱验证码失败';
1108
+ this.store.error = "检查邮箱验证码失败";
1097
1109
  return error;
1098
1110
  } finally {
1099
1111
  this.store.isLoading = false;
1100
1112
  }
1101
1113
  }
1102
-
1103
1114
  /** 检查手机验证码是否有效 */
1104
1115
  async checkMobileCode(params) {
1105
1116
  try {
1106
1117
  this.store.isLoading = true;
1107
1118
  this.store.error = null;
1108
- const response = await this.apiCaller.call('checkMobileCode', params);
1119
+ const response = await this.apiCaller.call("checkMobileCode", params);
1109
1120
  if (!response.status) {
1110
- this.store.error = response.message || '检查手机验证码失败';
1121
+ this.store.error = response.message || "检查手机验证码失败";
1111
1122
  }
1112
1123
  return response;
1113
1124
  } catch (error) {
1114
- this.store.error = '检查手机验证码失败';
1125
+ this.store.error = "检查手机验证码失败";
1115
1126
  return error;
1116
1127
  } finally {
1117
1128
  this.store.isLoading = false;
1118
1129
  }
1119
1130
  }
1120
-
1121
1131
  /** 手机号密码登录 */
1122
1132
  async phonePasswordLogin(params) {
1123
1133
  try {
1124
1134
  this.store.isLoading = true;
1125
1135
  this.store.error = null;
1126
- this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginStarted, {
1127
- type: 'phone-password',
1136
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginStarted, {
1137
+ type: "phone-password",
1128
1138
  phone: params.phone
1129
1139
  });
1130
- const response = await this.apiCaller.call('phonePasswordLogin', params);
1140
+ const response = await this.apiCaller.call(
1141
+ "phonePasswordLogin",
1142
+ params
1143
+ );
1131
1144
  if (response.status && response.data) {
1132
- // 保存用户信息和 token
1133
1145
  this.store.isLoggedIn = true;
1134
1146
  this.store.userInfo = response.data.user;
1135
1147
  this.store.token = response.data.token;
1136
-
1137
- // 如果有 refreshToken,也保存
1138
1148
  if (response.data.refreshToken) {
1139
1149
  this.store.refreshToken = response.data.refreshToken;
1140
1150
  }
1141
- this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginSuccess, {
1151
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginSuccess, {
1142
1152
  user: response.data.user,
1143
1153
  token: response.data.token,
1144
- loginType: 'phone-password'
1154
+ loginType: "phone-password"
1145
1155
  });
1146
1156
  } else {
1147
- this.store.error = response.message || '手机号密码登录失败';
1148
- this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
1157
+ this.store.error = response.message || "手机号密码登录失败";
1158
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
1149
1159
  error: this.store.error,
1150
- loginType: 'phone-password'
1160
+ loginType: "phone-password"
1151
1161
  });
1152
1162
  }
1153
1163
  return response;
1154
1164
  } catch (error) {
1155
- this.store.error = '手机号密码登录失败';
1156
- this.core.effects.emit(_types.RegisterAndLoginHooks.onLoginFailed, {
1165
+ this.store.error = "手机号密码登录失败";
1166
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onLoginFailed, {
1157
1167
  error: this.store.error,
1158
- loginType: 'phone-password'
1168
+ loginType: "phone-password"
1159
1169
  });
1160
1170
  return error;
1161
1171
  } finally {
1162
1172
  this.store.isLoading = false;
1163
1173
  }
1164
1174
  }
1165
-
1166
1175
  /** 发送密码重置邮箱验证码 */
1167
1176
  async sendPasswordResetEmail(params) {
1168
1177
  try {
1169
1178
  this.store.isLoading = true;
1170
1179
  this.store.error = null;
1171
- const response = await this.apiCaller.call('sendPasswordResetEmail', params);
1180
+ const response = await this.apiCaller.call(
1181
+ "sendPasswordResetEmail",
1182
+ params
1183
+ );
1172
1184
  if (response.status) {
1173
- // 记录验证码发送状态
1174
1185
  const now = Date.now();
1175
1186
  this.store.verificationCodeSent[params.email] = {
1176
1187
  sent: true,
1177
1188
  sentAt: now,
1178
- expiresAt: now + 10 * 60 * 1000 // 10分钟过期
1189
+ expiresAt: now + 10 * 60 * 1e3
1190
+ // 10分钟过期
1179
1191
  };
1180
- this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationSent, {
1192
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onEmailVerificationSent, {
1181
1193
  target: params.email,
1182
- purpose: _types.VerificationPurpose.PASSWORD_RESET
1194
+ purpose: import_types.VerificationPurpose.PASSWORD_RESET
1183
1195
  });
1184
1196
  } else {
1185
- this.store.error = response.message || '发送密码重置验证码失败';
1186
- this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
1187
- target: params.email,
1188
- error: this.store.error
1189
- });
1197
+ this.store.error = response.message || "发送密码重置验证码失败";
1198
+ this.core.effects.emit(
1199
+ import_types.RegisterAndLoginHooks.onEmailVerificationFailed,
1200
+ {
1201
+ target: params.email,
1202
+ error: this.store.error
1203
+ }
1204
+ );
1190
1205
  }
1191
1206
  return response;
1192
1207
  } catch (error) {
1193
- this.store.error = '发送密码重置验证码失败';
1194
- this.core.effects.emit(_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
1208
+ this.store.error = "发送密码重置验证码失败";
1209
+ this.core.effects.emit(import_types.RegisterAndLoginHooks.onEmailVerificationFailed, {
1195
1210
  target: params.email,
1196
1211
  error: this.store.error
1197
1212
  });
@@ -1200,62 +1215,58 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
1200
1215
  this.store.isLoading = false;
1201
1216
  }
1202
1217
  }
1203
-
1204
1218
  /** 发送手机号验证码重置密码 */
1205
1219
  async sendPasswordResetSms(params) {
1206
1220
  try {
1207
1221
  this.store.isLoading = true;
1208
1222
  this.store.error = null;
1209
- const response = await this.apiCaller.call('sendPasswordResetSms', params);
1223
+ const response = await this.apiCaller.call(
1224
+ "sendPasswordResetSms",
1225
+ params
1226
+ );
1210
1227
  if (response.status) {
1211
1228
  return response;
1212
1229
  } else {
1213
- this.store.error = response.message || '发送手机号验证码重置密码失败';
1230
+ this.store.error = response.message || "发送手机号验证码重置密码失败";
1214
1231
  }
1215
1232
  return response;
1216
1233
  } catch (error) {
1217
- this.store.error = '发送手机号验证码重置密码失败';
1234
+ this.store.error = "发送手机号验证码重置密码失败";
1218
1235
  return error;
1219
1236
  } finally {
1220
1237
  this.store.isLoading = false;
1221
1238
  }
1222
1239
  }
1223
-
1224
1240
  /**
1225
1241
  * 获取当前用户信息
1226
1242
  */
1227
1243
  getCurrentUser() {
1228
1244
  return this.store.currentUser;
1229
1245
  }
1230
-
1231
1246
  /**
1232
1247
  * 检查是否已登录
1233
1248
  */
1234
1249
  isLoggedIn() {
1235
1250
  return this.store.isLoggedIn;
1236
1251
  }
1237
-
1238
1252
  /**
1239
1253
  * 获取加载状态
1240
1254
  */
1241
1255
  isLoading() {
1242
1256
  return this.store.isLoading;
1243
1257
  }
1244
-
1245
1258
  /**
1246
1259
  * 获取错误信息
1247
1260
  */
1248
1261
  getError() {
1249
1262
  return this.store.error;
1250
1263
  }
1251
-
1252
1264
  /**
1253
1265
  * 清除错误信息
1254
1266
  */
1255
1267
  clearError() {
1256
1268
  this.store.error = null;
1257
1269
  }
1258
-
1259
1270
  /**
1260
1271
  * 检查验证码是否已发送且未过期
1261
1272
  */
@@ -1266,7 +1277,6 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
1266
1277
  }
1267
1278
  return Date.now() < codeInfo.expiresAt;
1268
1279
  }
1269
-
1270
1280
  /**
1271
1281
  * 获取验证码剩余时间(秒)
1272
1282
  */
@@ -1276,203 +1286,207 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
1276
1286
  return 0;
1277
1287
  }
1278
1288
  const remaining = Math.max(0, codeInfo.expiresAt - Date.now());
1279
- return Math.ceil(remaining / 1000);
1289
+ return Math.ceil(remaining / 1e3);
1280
1290
  }
1281
-
1282
1291
  /**
1283
1292
  * 初始化 Facebook SDK
1284
1293
  */
1285
1294
  async initFacebookSDK(token) {
1286
- // const config = this.store.oauthConfig[OAuthProvider.FACEBOOK];
1287
- // if (!config) {
1288
- // throw new Error('Facebook OAuth 配置未找到');
1289
- // }
1290
-
1291
1295
  return new Promise((resolve, reject) => {
1292
- if (typeof window === 'undefined') {
1293
- reject(new Error('Facebook SDK 只能在浏览器环境中使用'));
1296
+ if (typeof window === "undefined") {
1297
+ reject(new Error("Facebook SDK 只能在浏览器环境中使用"));
1294
1298
  return;
1295
1299
  }
1296
-
1297
- // 检查是否已经加载
1298
1300
  if (window.FB) {
1299
1301
  resolve();
1300
1302
  return;
1301
1303
  }
1302
-
1303
- // 动态加载 Facebook SDK
1304
- const script = document.createElement('script');
1305
- script.src = 'https://connect.facebook.net/en_US/sdk.js';
1304
+ const script = document.createElement("script");
1305
+ script.src = "https://connect.facebook.net/en_US/sdk.js";
1306
1306
  script.async = true;
1307
1307
  script.defer = true;
1308
- script.crossOrigin = 'anonymous';
1308
+ script.crossOrigin = "anonymous";
1309
1309
  script.onload = () => {
1310
1310
  window.FB.init({
1311
1311
  appId: token,
1312
1312
  cookie: true,
1313
1313
  xfbml: true,
1314
- version: 'v18.0'
1314
+ version: "v18.0"
1315
1315
  });
1316
1316
  resolve();
1317
1317
  };
1318
1318
  script.onerror = () => {
1319
- reject(new Error('Facebook SDK 加载失败'));
1319
+ reject(new Error("Facebook SDK 加载失败"));
1320
1320
  };
1321
1321
  document.head.appendChild(script);
1322
1322
  });
1323
1323
  }
1324
-
1325
1324
  /**
1326
1325
  * 初始化 Apple SDK
1327
1326
  */
1328
1327
  async initAppleSDK() {
1329
1328
  return new Promise((resolve, reject) => {
1330
- if (typeof window === 'undefined') {
1331
- reject(new Error('Apple SDK 只能在浏览器环境中使用'));
1329
+ if (typeof window === "undefined") {
1330
+ reject(new Error("Apple SDK 只能在浏览器环境中使用"));
1332
1331
  return;
1333
1332
  }
1334
-
1335
- // 检查是否已经加载
1336
1333
  if (window.AppleID) {
1337
1334
  resolve();
1338
1335
  return;
1339
1336
  }
1340
-
1341
- // 动态加载 Apple SDK
1342
- const script = document.createElement('script');
1343
- script.src = 'https://file.mypisell-dev.com/static/apple.js';
1337
+ const script = document.createElement("script");
1338
+ script.src = "https://file.mypisell-dev.com/static/apple.js";
1344
1339
  script.async = true;
1345
1340
  script.defer = true;
1346
- script.crossOrigin = 'anonymous';
1341
+ script.crossOrigin = "anonymous";
1347
1342
  script.onload = () => {
1348
- // Apple SDK 加载完成后,需要等待一下确保 AppleID 对象可用
1349
1343
  setTimeout(() => {
1350
1344
  if (window.AppleID) {
1351
1345
  resolve();
1352
1346
  } else {
1353
- reject(new Error('Apple SDK 加载失败:AppleID 对象不可用'));
1347
+ reject(new Error("Apple SDK 加载失败:AppleID 对象不可用"));
1354
1348
  }
1355
1349
  }, 100);
1356
1350
  };
1357
1351
  script.onerror = () => {
1358
- reject(new Error('Apple SDK 加载失败'));
1352
+ reject(new Error("Apple SDK 加载失败"));
1359
1353
  };
1360
1354
  document.head.appendChild(script);
1361
1355
  });
1362
1356
  }
1363
-
1364
1357
  /**
1365
1358
  * Facebook 登录
1366
1359
  */
1367
1360
  async loginWithFacebook(token) {
1361
+ console.log("[RegisterAndLogin] Facebook 登录开始", {
1362
+ tokenLength: (token == null ? void 0 : token.length) || 0,
1363
+ timestamp: Date.now()
1364
+ });
1368
1365
  await this.initFacebookSDK(token);
1366
+ console.log("[RegisterAndLogin] Facebook SDK 初始化完成,准备调用 FB.login");
1369
1367
  return new Promise((resolve, reject) => {
1370
- window.FB.login(async response => {
1371
- if (response.authResponse) {
1372
- try {
1373
- // 直接调用 /auth/facebook/login 接口
1374
-
1375
- const result = await this.apiCaller.call('facebookLogin', {
1376
- token: response.authResponse.accessToken
1377
- });
1378
- resolve(result);
1379
- } catch (error) {
1380
- console.error('[RegisterAndLogin] facebookLogin 接口调用失败', error);
1381
- reject(error);
1382
- }
1383
- } else {
1384
- console.warn('[RegisterAndLogin] FB.login 用户取消授权或无 authResponse', response);
1385
- reject(new Error('facebook_login_cancel'));
1386
- }
1387
- }, {
1388
- scope: 'email,public_profile'
1368
+ console.log("[RegisterAndLogin] 调用 FB.login", {
1369
+ scope: "email,public_profile"
1389
1370
  });
1371
+ window.FB.login(
1372
+ async (response) => {
1373
+ console.log("[RegisterAndLogin] FB.login 回调触发", {
1374
+ hasAuthResponse: Boolean(response == null ? void 0 : response.authResponse),
1375
+ status: response == null ? void 0 : response.status
1376
+ });
1377
+ if (response.authResponse) {
1378
+ try {
1379
+ console.log("[RegisterAndLogin] 调用后端 facebookLogin 接口");
1380
+ const result = await this.apiCaller.call("facebookLogin", {
1381
+ token: response.authResponse.accessToken
1382
+ });
1383
+ console.log("[RegisterAndLogin] facebookLogin 接口返回成功", {
1384
+ hasResult: Boolean(result)
1385
+ });
1386
+ resolve(result);
1387
+ } catch (error) {
1388
+ console.error("[RegisterAndLogin] facebookLogin 接口调用失败", error);
1389
+ reject(error);
1390
+ }
1391
+ } else {
1392
+ console.warn("[RegisterAndLogin] FB.login 用户取消授权或无 authResponse", response);
1393
+ reject(new Error("facebook_login_cancel"));
1394
+ }
1395
+ },
1396
+ { scope: "email,public_profile" }
1397
+ );
1390
1398
  });
1391
1399
  }
1392
-
1393
1400
  /**
1394
1401
  * Apple 登录(需要在支持的环境中使用)
1395
1402
  */
1396
1403
  async loginWithApple(token) {
1397
- // 先加载 Apple SDK
1398
-
1404
+ console.log("[RegisterAndLogin] Apple 登录开始", {
1405
+ tokenLength: (token == null ? void 0 : token.length) || 0,
1406
+ timestamp: Date.now()
1407
+ });
1399
1408
  await this.initAppleSDK();
1409
+ console.log("[RegisterAndLogin] Apple SDK 初始化完成");
1400
1410
  return new Promise((resolve, reject) => {
1411
+ var _a, _b, _c, _d;
1401
1412
  try {
1402
- // 动态创建 Apple 登录按钮元素
1403
-
1404
- const appleSignInDiv = document.createElement('div');
1405
- appleSignInDiv.id = 'appleid-signin-temp';
1406
- appleSignInDiv.setAttribute('data-color', 'black');
1407
- appleSignInDiv.setAttribute('data-border', 'false');
1408
- appleSignInDiv.setAttribute('data-type', 'sign-in');
1409
- appleSignInDiv.setAttribute('data-mode', 'logo-only');
1410
- appleSignInDiv.setAttribute('data-logo-size', 'small');
1411
- appleSignInDiv.style.opacity = '0';
1412
- appleSignInDiv.style.position = 'absolute';
1413
- appleSignInDiv.style.left = '-9999px';
1414
- appleSignInDiv.style.top = '-9999px';
1415
- appleSignInDiv.style.width = '1px';
1416
- appleSignInDiv.style.height = '1px';
1417
-
1418
- // 将元素添加到 body 中
1413
+ console.log("[RegisterAndLogin] 创建临时 Apple SignIn 按钮节点");
1414
+ const appleSignInDiv = document.createElement("div");
1415
+ appleSignInDiv.id = "appleid-signin-temp";
1416
+ appleSignInDiv.setAttribute("data-color", "black");
1417
+ appleSignInDiv.setAttribute("data-border", "false");
1418
+ appleSignInDiv.setAttribute("data-type", "sign-in");
1419
+ appleSignInDiv.setAttribute("data-mode", "logo-only");
1420
+ appleSignInDiv.setAttribute("data-logo-size", "small");
1421
+ appleSignInDiv.style.opacity = "0";
1422
+ appleSignInDiv.style.position = "absolute";
1423
+ appleSignInDiv.style.left = "-9999px";
1424
+ appleSignInDiv.style.top = "-9999px";
1425
+ appleSignInDiv.style.width = "1px";
1426
+ appleSignInDiv.style.height = "1px";
1419
1427
  document.body.appendChild(appleSignInDiv);
1420
- // 初始化 Apple ID 按钮
1421
- if (window.AppleID?.auth?.init) {
1428
+ console.log("[RegisterAndLogin] Apple SignIn 按钮已添加到文档");
1429
+ if ((_b = (_a = window.AppleID) == null ? void 0 : _a.auth) == null ? void 0 : _b.init) {
1430
+ console.log("[RegisterAndLogin] 调用 AppleID.auth.init");
1422
1431
  window.AppleID.auth.init({
1423
1432
  clientId: token,
1424
1433
  // 使用传入的 token 作为 clientId
1425
- scope: 'name email',
1434
+ scope: "name email",
1426
1435
  redirectURI: window.location.origin,
1427
- state: 'signin',
1436
+ state: "signin",
1428
1437
  usePopup: true
1429
1438
  });
1430
1439
  } else {
1431
- console.warn('[RegisterAndLogin] AppleID.auth.init 方法不可用');
1440
+ console.warn("[RegisterAndLogin] AppleID.auth.init 方法不可用");
1432
1441
  }
1433
-
1434
- // 直接调用 Apple ID 登录,并处理 Promise
1435
- if (window.AppleID?.auth?.signIn) {
1436
- window.AppleID.auth.signIn().then(async authResult => {
1442
+ if ((_d = (_c = window.AppleID) == null ? void 0 : _c.auth) == null ? void 0 : _d.signIn) {
1443
+ console.log("[RegisterAndLogin] 调用 AppleID.auth.signIn");
1444
+ window.AppleID.auth.signIn().then(async (authResult) => {
1445
+ var _a2, _b2;
1437
1446
  try {
1438
- // 清理临时元素
1439
1447
  if (document.body.contains(appleSignInDiv)) {
1440
1448
  document.body.removeChild(appleSignInDiv);
1441
1449
  }
1442
- // 获取授权码或令牌
1443
- const authorizationCode = authResult.authorization?.code;
1444
- const identityToken = authResult.authorization?.id_token;
1445
-
1446
- // 使用授权码或身份令牌调用后端接口
1447
-
1448
- const result = await this.apiCaller.call('appleLogin', {
1450
+ console.log("[RegisterAndLogin] Apple SignIn 成功,临时节点已移除", {
1451
+ hasAuthorization: Boolean(authResult == null ? void 0 : authResult.authorization),
1452
+ hasUser: Boolean(authResult == null ? void 0 : authResult.user)
1453
+ });
1454
+ const authorizationCode = (_a2 = authResult.authorization) == null ? void 0 : _a2.code;
1455
+ const identityToken = (_b2 = authResult.authorization) == null ? void 0 : _b2.id_token;
1456
+ console.log("[RegisterAndLogin] Apple 授权结果解析", {
1457
+ hasAuthorizationCode: Boolean(authorizationCode),
1458
+ hasIdentityToken: Boolean(identityToken)
1459
+ });
1460
+ console.log("[RegisterAndLogin] 调用后端 appleLogin 接口");
1461
+ const result = await this.apiCaller.call("appleLogin", {
1449
1462
  code: identityToken || authorizationCode,
1450
1463
  login_channel: this.channel
1451
1464
  });
1465
+ console.log("[RegisterAndLogin] appleLogin 接口返回成功", {
1466
+ hasResult: Boolean(result)
1467
+ });
1452
1468
  resolve(result);
1453
1469
  } catch (error) {
1454
- console.error('[RegisterAndLogin] 处理 Apple 登录结果失败', error);
1470
+ console.error("[RegisterAndLogin] 处理 Apple 登录结果失败", error);
1455
1471
  reject(error);
1456
1472
  }
1457
- }).catch(error => {
1458
- // 清理临时元素
1473
+ }).catch((error) => {
1459
1474
  if (document.body.contains(appleSignInDiv)) {
1460
1475
  document.body.removeChild(appleSignInDiv);
1461
1476
  }
1462
- console.error('[RegisterAndLogin] Apple SignIn Promise 拒绝', error);
1463
- reject(new Error('Apple 登录失败: ' + (error?.error || error?.message || '未知错误')));
1477
+ console.error("[RegisterAndLogin] Apple SignIn Promise 拒绝", error);
1478
+ reject(new Error("Apple 登录失败: " + ((error == null ? void 0 : error.error) || (error == null ? void 0 : error.message) || "未知错误")));
1464
1479
  });
1465
1480
  } else {
1466
- console.error('[RegisterAndLogin] AppleID.auth.signIn 方法不可用');
1467
- reject(new Error('Apple SDK 未正确加载'));
1481
+ console.error("[RegisterAndLogin] AppleID.auth.signIn 方法不可用");
1482
+ reject(new Error("Apple SDK 未正确加载"));
1468
1483
  }
1469
1484
  } catch (error) {
1470
- console.error('[RegisterAndLogin] Apple 登录流程异常', error);
1485
+ console.error("[RegisterAndLogin] Apple 登录流程异常", error);
1471
1486
  reject(error);
1472
1487
  }
1473
1488
  });
1474
1489
  }
1475
-
1476
1490
  /**
1477
1491
  * 更新 OAuth 配置
1478
1492
  */
@@ -1482,37 +1496,30 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
1482
1496
  ...config
1483
1497
  };
1484
1498
  }
1485
-
1486
1499
  /**
1487
1500
  * 获取当前渠道
1488
1501
  */
1489
1502
  getCurrentChannel() {
1490
1503
  return this.channel;
1491
1504
  }
1492
-
1493
1505
  /**
1494
1506
  * 获取 API 调用器(用于高级用法)
1495
1507
  */
1496
1508
  getApiCaller() {
1497
1509
  return this.apiCaller;
1498
1510
  }
1499
-
1500
1511
  /**
1501
1512
  * 获取国家区号列表
1502
1513
  */
1503
1514
  async getCountries() {
1504
- const CACHE_KEY = 'pisell_countries_cache';
1515
+ const CACHE_KEY = "pisell_countries_cache";
1505
1516
  try {
1506
1517
  this.store.isLoading = true;
1507
1518
  this.store.error = null;
1508
-
1509
- // 1. 检查内存缓存
1510
1519
  if (this.countriesCache) {
1511
1520
  this.store.isLoading = false;
1512
1521
  return this.countriesCache;
1513
1522
  }
1514
-
1515
- // 2. 检查 localStorage 缓存
1516
1523
  let cachedData = null;
1517
1524
  try {
1518
1525
  const cached = this.window.localStorage.getItem(CACHE_KEY);
@@ -1520,77 +1527,67 @@ class RegisterAndLoginImpl extends _BaseModule.BaseModule {
1520
1527
  cachedData = JSON.parse(cached);
1521
1528
  }
1522
1529
  } catch (error) {
1523
- console.warn('[RegisterAndLogin] localStorage 缓存解析失败:', error);
1530
+ console.warn("[RegisterAndLogin] localStorage 缓存解析失败:", error);
1524
1531
  }
1525
-
1526
- // 3. 如果有 localStorage 缓存,先返回缓存数据
1527
1532
  if (cachedData && Array.isArray(cachedData) && cachedData.length > 0) {
1528
- // 设置内存缓存
1529
1533
  this.countriesCache = cachedData;
1530
-
1531
- // 异步请求后端数据进行对比和更新
1532
1534
  this.updateCountriesCache(CACHE_KEY, cachedData);
1533
1535
  this.store.isLoading = false;
1534
1536
  return cachedData;
1535
1537
  }
1536
-
1537
- // 4. 没有缓存,直接请求后端
1538
- const response = await this.apiCaller.call('getCountries');
1538
+ const response = await this.apiCaller.call("getCountries");
1539
1539
  if (response.status && response.data) {
1540
1540
  const countries = response.data;
1541
-
1542
- // 更新内存缓存
1543
1541
  this.countriesCache = countries;
1544
-
1545
- // 更新 localStorage 缓存
1546
1542
  try {
1547
1543
  localStorage.setItem(CACHE_KEY, JSON.stringify(countries));
1548
1544
  } catch (error) {
1549
- console.warn('[RegisterAndLogin] localStorage 存储失败:', error);
1545
+ console.warn("[RegisterAndLogin] localStorage 存储失败:", error);
1550
1546
  }
1551
1547
  return countries;
1552
1548
  } else {
1553
- this.store.error = response.message || '获取国家区号失败';
1549
+ this.store.error = response.message || "获取国家区号失败";
1554
1550
  throw new Error(this.store.error);
1555
1551
  }
1556
1552
  } catch (error) {
1557
- this.store.error = '获取国家区号失败';
1558
- console.error('[RegisterAndLogin] 获取国家区号失败:', error);
1553
+ this.store.error = "获取国家区号失败";
1554
+ console.error("[RegisterAndLogin] 获取国家区号失败:", error);
1559
1555
  throw error;
1560
1556
  } finally {
1561
1557
  this.store.isLoading = false;
1562
1558
  }
1563
1559
  }
1564
-
1565
1560
  /**
1566
1561
  * 异步更新国家缓存数据
1567
1562
  */
1568
1563
  async updateCountriesCache(cacheKey, cachedData) {
1569
1564
  try {
1570
- const response = await this.apiCaller.call('getCountries');
1565
+ const response = await this.apiCaller.call("getCountries");
1571
1566
  if (response.status && response.data) {
1572
1567
  const newData = response.data;
1573
-
1574
- // 比较数据是否有变化(简单的长度和内容对比)
1575
1568
  const hasChanged = newData.length !== cachedData.length || JSON.stringify(newData) !== JSON.stringify(cachedData);
1576
1569
  if (hasChanged) {
1577
- // 更新内存缓存
1578
1570
  this.countriesCache = newData;
1579
-
1580
- // 更新 localStorage 缓存
1581
1571
  try {
1582
1572
  localStorage.setItem(cacheKey, JSON.stringify(newData));
1583
1573
  } catch (error) {
1584
- console.warn('[RegisterAndLogin] localStorage 更新失败:', error);
1574
+ console.warn("[RegisterAndLogin] localStorage 更新失败:", error);
1585
1575
  }
1576
+ console.log("[RegisterAndLogin] 国家数据已更新");
1586
1577
  }
1587
1578
  }
1588
1579
  } catch (error) {
1589
- console.warn('[RegisterAndLogin] 后台更新国家数据失败:', error);
1580
+ console.warn("[RegisterAndLogin] 后台更新国家数据失败:", error);
1590
1581
  }
1591
1582
  }
1592
1583
  async destroy() {
1593
- await this.core.effects.emit(_types.RegisterAndLoginHooks.onDestroy, {});
1584
+ await this.core.effects.emit(import_types.RegisterAndLoginHooks.onDestroy, {});
1585
+ console.log("[RegisterAndLogin] 已销毁");
1594
1586
  }
1595
- }
1596
- exports.RegisterAndLoginImpl = RegisterAndLoginImpl;
1587
+ };
1588
+ // Annotate the CommonJS export names for ESM import in node:
1589
+ 0 && (module.exports = {
1590
+ RegisterAndLoginImpl,
1591
+ ...require("./types"),
1592
+ ...require("./config")
1593
+ });