sa2kit 2.0.4 → 3.0.0

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 (347) hide show
  1. package/dist/{UniversalFileService-GsP6D3Rc.d.ts → UniversalFileService-CC4d3wkc.d.ts} +2 -2
  2. package/dist/{UniversalFileService-BpvbZitV.d.mts → UniversalFileService-CzAE_G4V.d.mts} +2 -2
  3. package/dist/auth/client/index.d.mts +8 -27
  4. package/dist/auth/client/index.d.ts +8 -27
  5. package/dist/auth/client/index.js +9 -4
  6. package/dist/auth/client/index.mjs +2 -1
  7. package/dist/auth/components/index.d.mts +8 -225
  8. package/dist/auth/components/index.d.ts +8 -225
  9. package/dist/auth/components/index.js +62 -319
  10. package/dist/auth/components/index.js.map +1 -1
  11. package/dist/auth/components/index.mjs +6 -316
  12. package/dist/auth/components/index.mjs.map +1 -1
  13. package/dist/auth/hooks/index.d.mts +11 -29
  14. package/dist/auth/hooks/index.d.ts +11 -29
  15. package/dist/auth/hooks/index.js +14 -3
  16. package/dist/auth/hooks/index.mjs +4 -1
  17. package/dist/auth/index.d.mts +17 -14
  18. package/dist/auth/index.d.ts +17 -14
  19. package/dist/auth/index.js +51 -90
  20. package/dist/auth/index.mjs +8 -7
  21. package/dist/auth/rn/index.d.mts +3087 -18
  22. package/dist/auth/rn/index.d.ts +3087 -18
  23. package/dist/auth/rn/index.js +396 -477
  24. package/dist/auth/rn/index.js.map +1 -1
  25. package/dist/auth/rn/index.mjs +384 -475
  26. package/dist/auth/rn/index.mjs.map +1 -1
  27. package/dist/auth/schema/index.d.mts +3 -788
  28. package/dist/auth/schema/index.d.ts +3 -788
  29. package/dist/auth/schema/index.js +17 -9
  30. package/dist/auth/schema/index.mjs +1 -1
  31. package/dist/auth/services/index.d.mts +1 -48
  32. package/dist/auth/services/index.d.ts +1 -48
  33. package/dist/auth/services/index.js +3 -20
  34. package/dist/auth/services/index.mjs +1 -2
  35. package/dist/{base-api-client-B3wZZoaH.d.ts → base-api-client-BpmcQt4Q.d.ts} +1 -1
  36. package/dist/{base-api-client-ACKKt13v.d.mts → base-api-client-CFIhZK4C.d.mts} +1 -1
  37. package/dist/{base-api-client-ACKKt13v.d.ts → base-api-client-CFIhZK4C.d.ts} +1 -1
  38. package/dist/{base-api-client-DrL35Ea2.d.mts → base-api-client-DXLsq2yz.d.mts} +1 -1
  39. package/dist/business/index.d.mts +1 -5
  40. package/dist/business/index.d.ts +1 -5
  41. package/dist/business/index.js +34 -1135
  42. package/dist/business/index.js.map +1 -1
  43. package/dist/business/index.mjs +5 -1105
  44. package/dist/business/index.mjs.map +1 -1
  45. package/dist/calendar/routes/index.d.mts +74 -1
  46. package/dist/calendar/routes/index.d.ts +74 -1
  47. package/dist/calendar/routes/index.js +186 -97
  48. package/dist/calendar/routes/index.js.map +1 -1
  49. package/dist/calendar/routes/index.mjs +178 -99
  50. package/dist/calendar/routes/index.mjs.map +1 -1
  51. package/dist/{chunk-IIVNHQEI.mjs → chunk-5GBDDXYL.mjs} +4 -3
  52. package/dist/chunk-5GBDDXYL.mjs.map +1 -0
  53. package/dist/chunk-7E3J7VAD.mjs +3 -0
  54. package/dist/chunk-7E3J7VAD.mjs.map +1 -0
  55. package/dist/chunk-B3CZ3HXJ.mjs +126 -0
  56. package/dist/chunk-B3CZ3HXJ.mjs.map +1 -0
  57. package/dist/chunk-CAYOQDBR.js +78 -0
  58. package/dist/chunk-CAYOQDBR.js.map +1 -0
  59. package/dist/{chunk-PTMSDNGO.mjs → chunk-CX2GHCAI.mjs} +4 -75
  60. package/dist/chunk-CX2GHCAI.mjs.map +1 -0
  61. package/dist/chunk-EBHPTFG6.mjs +82 -0
  62. package/dist/chunk-EBHPTFG6.mjs.map +1 -0
  63. package/dist/chunk-FOQEQWX5.js +4 -0
  64. package/dist/chunk-FOQEQWX5.js.map +1 -0
  65. package/dist/{chunk-YGI7UU2D.mjs → chunk-G4NFB2QA.mjs} +2 -2
  66. package/dist/chunk-G4NFB2QA.mjs.map +1 -0
  67. package/dist/chunk-G5HJGXGC.mjs +39 -0
  68. package/dist/chunk-G5HJGXGC.mjs.map +1 -0
  69. package/dist/{chunk-GSNGCENJ.js → chunk-GQZHGSRR.js} +2 -39
  70. package/dist/chunk-GQZHGSRR.js.map +1 -0
  71. package/dist/chunk-GS7XLKET.js +41 -0
  72. package/dist/chunk-GS7XLKET.js.map +1 -0
  73. package/dist/{chunk-7B5SI4OF.mjs → chunk-IBWDBBX5.mjs} +4 -3
  74. package/dist/chunk-IBWDBBX5.mjs.map +1 -0
  75. package/dist/chunk-IS7O4LPI.js +146 -0
  76. package/dist/chunk-IS7O4LPI.js.map +1 -0
  77. package/dist/chunk-LGHUCQIU.js +93 -0
  78. package/dist/chunk-LGHUCQIU.js.map +1 -0
  79. package/dist/chunk-LHJKLUM7.mjs +18 -0
  80. package/dist/chunk-LHJKLUM7.mjs.map +1 -0
  81. package/dist/chunk-LKBIVQBT.mjs +34 -0
  82. package/dist/chunk-LKBIVQBT.mjs.map +1 -0
  83. package/dist/chunk-MIDXG6LS.js +32 -0
  84. package/dist/chunk-MIDXG6LS.js.map +1 -0
  85. package/dist/chunk-MWSAH7ZG.mjs +42 -0
  86. package/dist/chunk-MWSAH7ZG.mjs.map +1 -0
  87. package/dist/{chunk-HCI6JQOU.mjs → chunk-MZOGYD4N.mjs} +7 -4
  88. package/dist/chunk-MZOGYD4N.mjs.map +1 -0
  89. package/dist/chunk-NDGHXVGS.js +25 -0
  90. package/dist/chunk-NDGHXVGS.js.map +1 -0
  91. package/dist/chunk-Q5VFBPMG.mjs +76 -0
  92. package/dist/chunk-Q5VFBPMG.mjs.map +1 -0
  93. package/dist/chunk-QDUBO567.js +1148 -0
  94. package/dist/chunk-QDUBO567.js.map +1 -0
  95. package/dist/{chunk-3CSCIRQY.js → chunk-QP5N3ER6.js} +6 -5
  96. package/dist/chunk-QP5N3ER6.js.map +1 -0
  97. package/dist/chunk-RWCD2CAD.mjs +1132 -0
  98. package/dist/chunk-RWCD2CAD.mjs.map +1 -0
  99. package/dist/{chunk-VQ54PUQV.js → chunk-S37OK2QG.js} +2 -2
  100. package/dist/chunk-S37OK2QG.js.map +1 -0
  101. package/dist/chunk-S3PUP7N4.js +20 -0
  102. package/dist/chunk-S3PUP7N4.js.map +1 -0
  103. package/dist/{chunk-QQ2WFYOD.js → chunk-S6YSGVWD.js} +4 -76
  104. package/dist/chunk-S6YSGVWD.js.map +1 -0
  105. package/dist/chunk-SFDJNKWC.js +22 -0
  106. package/dist/chunk-SFDJNKWC.js.map +1 -0
  107. package/dist/chunk-TTYCVBIQ.mjs +144 -0
  108. package/dist/chunk-TTYCVBIQ.mjs.map +1 -0
  109. package/dist/{chunk-HBF4HPRK.js → chunk-TXMX6PZR.js} +7 -3
  110. package/dist/chunk-TXMX6PZR.js.map +1 -0
  111. package/dist/chunk-VHN7PF5I.js +20 -0
  112. package/dist/chunk-VHN7PF5I.js.map +1 -0
  113. package/dist/chunk-VJNDOYEC.js +41 -0
  114. package/dist/chunk-VJNDOYEC.js.map +1 -0
  115. package/dist/chunk-XBZIS3MV.mjs +13 -0
  116. package/dist/chunk-XBZIS3MV.mjs.map +1 -0
  117. package/dist/chunk-XFOZ56FB.mjs +20 -0
  118. package/dist/chunk-XFOZ56FB.mjs.map +1 -0
  119. package/dist/chunk-Z23HAXHL.js +136 -0
  120. package/dist/chunk-Z23HAXHL.js.map +1 -0
  121. package/dist/chunk-ZF7DKR5A.mjs +26 -0
  122. package/dist/chunk-ZF7DKR5A.mjs.map +1 -0
  123. package/dist/common/auth/client/index.d.mts +3239 -0
  124. package/dist/common/auth/client/index.d.ts +3239 -0
  125. package/dist/common/auth/client/index.js +26 -0
  126. package/dist/common/auth/client/index.mjs +5 -0
  127. package/dist/common/auth/components/index.d.mts +374 -0
  128. package/dist/common/auth/components/index.d.ts +374 -0
  129. package/dist/common/auth/components/index.js +70 -0
  130. package/dist/common/auth/components/index.mjs +9 -0
  131. package/dist/common/auth/hooks/index.d.mts +75 -0
  132. package/dist/common/auth/hooks/index.d.ts +75 -0
  133. package/dist/common/auth/hooks/index.js +28 -0
  134. package/dist/common/auth/hooks/index.js.map +1 -0
  135. package/dist/common/auth/hooks/index.mjs +7 -0
  136. package/dist/common/auth/hooks/index.mjs.map +1 -0
  137. package/dist/common/auth/index.d.mts +14 -6
  138. package/dist/common/auth/index.d.ts +14 -6
  139. package/dist/common/auth/index.js +17 -8
  140. package/dist/common/auth/index.mjs +4 -3
  141. package/dist/common/auth/react/index.d.mts +3056 -0
  142. package/dist/common/auth/react/index.d.ts +3056 -0
  143. package/dist/common/auth/react/index.js +31 -0
  144. package/dist/common/auth/react/index.js.map +1 -0
  145. package/dist/common/auth/react/index.mjs +21 -0
  146. package/dist/common/auth/react/index.mjs.map +1 -0
  147. package/dist/common/auth/rn/index.d.mts +3138 -0
  148. package/dist/common/auth/rn/index.d.ts +3138 -0
  149. package/dist/common/auth/rn/index.js +348 -0
  150. package/dist/common/auth/rn/index.js.map +1 -0
  151. package/dist/common/auth/rn/index.mjs +327 -0
  152. package/dist/common/auth/rn/index.mjs.map +1 -0
  153. package/dist/common/auth/schema/index.d.mts +1479 -0
  154. package/dist/common/auth/schema/index.d.ts +1479 -0
  155. package/dist/common/auth/schema/index.js +49 -0
  156. package/dist/common/auth/schema/index.js.map +1 -0
  157. package/dist/common/auth/schema/index.mjs +4 -0
  158. package/dist/common/auth/schema/index.mjs.map +1 -0
  159. package/dist/common/auth/server/index.d.mts +7 -30
  160. package/dist/common/auth/server/index.d.ts +7 -30
  161. package/dist/common/auth/server/index.js +36 -79
  162. package/dist/common/auth/server/index.mjs +2 -5
  163. package/dist/common/auth/services/index.d.mts +14 -0
  164. package/dist/common/auth/services/index.d.ts +14 -0
  165. package/dist/common/auth/services/index.js +17 -0
  166. package/dist/common/auth/services/index.js.map +1 -0
  167. package/dist/common/auth/services/index.mjs +4 -0
  168. package/dist/common/auth/services/index.mjs.map +1 -0
  169. package/dist/common/index.d.mts +13 -5
  170. package/dist/common/index.d.ts +13 -5
  171. package/dist/common/index.js +19 -16
  172. package/dist/common/index.mjs +11 -8
  173. package/dist/common/request/index.js +5 -4
  174. package/dist/common/request/index.mjs +3 -2
  175. package/dist/common/storage/index.js +13 -12
  176. package/dist/common/storage/index.mjs +3 -2
  177. package/dist/festivalCard/index.d.mts +3 -3
  178. package/dist/festivalCard/index.d.ts +3 -3
  179. package/dist/festivalCard/routes/index.d.mts +1 -1
  180. package/dist/festivalCard/routes/index.d.ts +1 -1
  181. package/dist/festivalCard/server/index.d.mts +2 -2
  182. package/dist/festivalCard/server/index.d.ts +2 -2
  183. package/dist/{festivalCardService-BFCRhJrq.d.ts → festivalCardService-B3GsnNpV.d.ts} +1 -1
  184. package/dist/{festivalCardService-GriR2VMc.d.mts → festivalCardService-CWhrLNE9.d.mts} +1 -1
  185. package/dist/{index-DPYkrKZf.d.mts → index-BcjDRcKp.d.mts} +11 -6
  186. package/dist/{index-Bnh6VqFv.d.ts → index-BlpXrrTy.d.ts} +11 -6
  187. package/dist/{index-1Ag7IBXN.d.ts → index-DZ5iJtNO.d.mts} +2 -44
  188. package/dist/{index-DdeZSeTJ.d.mts → index-DZ5iJtNO.d.ts} +2 -44
  189. package/dist/index.d.mts +6296 -40
  190. package/dist/index.d.ts +6296 -40
  191. package/dist/index.js +1378 -2508
  192. package/dist/index.js.map +1 -1
  193. package/dist/index.mjs +1073 -2203
  194. package/dist/index.mjs.map +1 -1
  195. package/dist/mmd/admin/index.d.mts +1 -1
  196. package/dist/mmd/admin/index.d.ts +1 -1
  197. package/dist/mmd/index.d.mts +1 -1
  198. package/dist/mmd/index.d.ts +1 -1
  199. package/dist/mmd/server/index.d.mts +3 -3
  200. package/dist/mmd/server/index.d.ts +3 -3
  201. package/dist/request/index.js +4 -3
  202. package/dist/request/index.mjs +2 -1
  203. package/dist/session-BCXvGCnm.d.mts +81 -0
  204. package/dist/session-BCXvGCnm.d.ts +81 -0
  205. package/dist/storage/index.js +12 -11
  206. package/dist/storage/index.mjs +2 -1
  207. package/dist/{types-DyG3ZV9V.d.mts → types-B6B210gX.d.mts} +1 -1
  208. package/dist/{types-DyG3ZV9V.d.ts → types-B6B210gX.d.ts} +1 -1
  209. package/dist/{types-BTiaMsBz.d.mts → types-Bdnte5EN.d.mts} +1 -1
  210. package/dist/{types-tQfupO6d.d.mts → types-Cs0CLvrH.d.mts} +1 -1
  211. package/dist/{types-tQfupO6d.d.ts → types-Cs0CLvrH.d.ts} +1 -1
  212. package/dist/{types-ERmJyjx8.d.ts → types-_rFX1atk.d.ts} +1 -1
  213. package/dist/types.legacy-J-j-_ig_.d.mts +25 -0
  214. package/dist/types.legacy-J-j-_ig_.d.ts +25 -0
  215. package/dist/useAuthActions-7S5dL7Oh.d.mts +77 -0
  216. package/dist/useAuthActions-7S5dL7Oh.d.ts +77 -0
  217. package/dist/vocaloidBooth/server/index.d.mts +3 -3
  218. package/dist/vocaloidBooth/server/index.d.ts +3 -3
  219. package/package.json +44 -76
  220. package/dist/auth/legacy/core/index.d.mts +0 -42
  221. package/dist/auth/legacy/core/index.d.ts +0 -42
  222. package/dist/auth/legacy/core/index.js +0 -242
  223. package/dist/auth/legacy/core/index.js.map +0 -1
  224. package/dist/auth/legacy/core/index.mjs +0 -226
  225. package/dist/auth/legacy/core/index.mjs.map +0 -1
  226. package/dist/auth/legacy/db/index.d.mts +0 -5
  227. package/dist/auth/legacy/db/index.d.ts +0 -5
  228. package/dist/auth/legacy/db/index.js +0 -261
  229. package/dist/auth/legacy/db/index.js.map +0 -1
  230. package/dist/auth/legacy/db/index.mjs +0 -250
  231. package/dist/auth/legacy/db/index.mjs.map +0 -1
  232. package/dist/auth/legacy/index.d.mts +0 -5
  233. package/dist/auth/legacy/index.d.ts +0 -5
  234. package/dist/auth/legacy/index.js +0 -1107
  235. package/dist/auth/legacy/index.js.map +0 -1
  236. package/dist/auth/legacy/index.mjs +0 -1086
  237. package/dist/auth/legacy/index.mjs.map +0 -1
  238. package/dist/auth/legacy/logic/index.d.mts +0 -9
  239. package/dist/auth/legacy/logic/index.d.ts +0 -9
  240. package/dist/auth/legacy/logic/index.js +0 -194
  241. package/dist/auth/legacy/logic/index.js.map +0 -1
  242. package/dist/auth/legacy/logic/index.mjs +0 -187
  243. package/dist/auth/legacy/logic/index.mjs.map +0 -1
  244. package/dist/auth/legacy/miniapp/index.d.mts +0 -5
  245. package/dist/auth/legacy/miniapp/index.d.ts +0 -5
  246. package/dist/auth/legacy/miniapp/index.js +0 -506
  247. package/dist/auth/legacy/miniapp/index.js.map +0 -1
  248. package/dist/auth/legacy/miniapp/index.mjs +0 -487
  249. package/dist/auth/legacy/miniapp/index.mjs.map +0 -1
  250. package/dist/auth/legacy/routes/index.d.mts +0 -53
  251. package/dist/auth/legacy/routes/index.d.ts +0 -53
  252. package/dist/auth/legacy/routes/index.js +0 -278
  253. package/dist/auth/legacy/routes/index.js.map +0 -1
  254. package/dist/auth/legacy/routes/index.mjs +0 -271
  255. package/dist/auth/legacy/routes/index.mjs.map +0 -1
  256. package/dist/auth/legacy/schema/index.d.mts +0 -401
  257. package/dist/auth/legacy/schema/index.d.ts +0 -401
  258. package/dist/auth/legacy/schema/index.js +0 -50
  259. package/dist/auth/legacy/schema/index.js.map +0 -1
  260. package/dist/auth/legacy/schema/index.mjs +0 -44
  261. package/dist/auth/legacy/schema/index.mjs.map +0 -1
  262. package/dist/auth/legacy/server/index.d.mts +0 -13
  263. package/dist/auth/legacy/server/index.d.ts +0 -13
  264. package/dist/auth/legacy/server/index.js +0 -21
  265. package/dist/auth/legacy/server/index.js.map +0 -1
  266. package/dist/auth/legacy/server/index.mjs +0 -19
  267. package/dist/auth/legacy/server/index.mjs.map +0 -1
  268. package/dist/auth/legacy/services/index.d.mts +0 -40
  269. package/dist/auth/legacy/services/index.d.ts +0 -40
  270. package/dist/auth/legacy/services/index.js +0 -258
  271. package/dist/auth/legacy/services/index.js.map +0 -1
  272. package/dist/auth/legacy/services/index.mjs +0 -252
  273. package/dist/auth/legacy/services/index.mjs.map +0 -1
  274. package/dist/auth/legacy/ui/miniapp/index.d.mts +0 -10
  275. package/dist/auth/legacy/ui/miniapp/index.d.ts +0 -10
  276. package/dist/auth/legacy/ui/miniapp/index.js +0 -298
  277. package/dist/auth/legacy/ui/miniapp/index.js.map +0 -1
  278. package/dist/auth/legacy/ui/miniapp/index.mjs +0 -290
  279. package/dist/auth/legacy/ui/miniapp/index.mjs.map +0 -1
  280. package/dist/auth/legacy/ui/web/index.d.mts +0 -22
  281. package/dist/auth/legacy/ui/web/index.d.ts +0 -22
  282. package/dist/auth/legacy/ui/web/index.js +0 -899
  283. package/dist/auth/legacy/ui/web/index.js.map +0 -1
  284. package/dist/auth/legacy/ui/web/index.mjs +0 -889
  285. package/dist/auth/legacy/ui/web/index.mjs.map +0 -1
  286. package/dist/auth/legacy/web/index.d.mts +0 -5
  287. package/dist/auth/legacy/web/index.d.ts +0 -5
  288. package/dist/auth/legacy/web/index.js +0 -1107
  289. package/dist/auth/legacy/web/index.js.map +0 -1
  290. package/dist/auth/legacy/web/index.mjs +0 -1086
  291. package/dist/auth/legacy/web/index.mjs.map +0 -1
  292. package/dist/auth/middleware/index.d.mts +0 -75
  293. package/dist/auth/middleware/index.d.ts +0 -75
  294. package/dist/auth/middleware/index.js +0 -15
  295. package/dist/auth/middleware/index.mjs +0 -6
  296. package/dist/auth/routes/index.d.mts +0 -261
  297. package/dist/auth/routes/index.d.ts +0 -261
  298. package/dist/auth/routes/index.js +0 -59
  299. package/dist/auth/routes/index.mjs +0 -6
  300. package/dist/chunk-37HYTHEC.mjs +0 -90
  301. package/dist/chunk-37HYTHEC.mjs.map +0 -1
  302. package/dist/chunk-3CSCIRQY.js.map +0 -1
  303. package/dist/chunk-5WV35FPV.js +0 -131
  304. package/dist/chunk-5WV35FPV.js.map +0 -1
  305. package/dist/chunk-7B5SI4OF.mjs.map +0 -1
  306. package/dist/chunk-DCRD5CZB.js +0 -573
  307. package/dist/chunk-DCRD5CZB.js.map +0 -1
  308. package/dist/chunk-DDX4JKFS.js +0 -19
  309. package/dist/chunk-DDX4JKFS.js.map +0 -1
  310. package/dist/chunk-DV6M7MFP.js +0 -283
  311. package/dist/chunk-DV6M7MFP.js.map +0 -1
  312. package/dist/chunk-EQXPL7TN.mjs +0 -78
  313. package/dist/chunk-EQXPL7TN.mjs.map +0 -1
  314. package/dist/chunk-GSNGCENJ.js.map +0 -1
  315. package/dist/chunk-HBF4HPRK.js.map +0 -1
  316. package/dist/chunk-HCI6JQOU.mjs.map +0 -1
  317. package/dist/chunk-I44HXJ3X.mjs +0 -17
  318. package/dist/chunk-I44HXJ3X.mjs.map +0 -1
  319. package/dist/chunk-IIVNHQEI.mjs.map +0 -1
  320. package/dist/chunk-IJ4YYWE3.mjs +0 -122
  321. package/dist/chunk-IJ4YYWE3.mjs.map +0 -1
  322. package/dist/chunk-J4BEIZUC.js +0 -92
  323. package/dist/chunk-J4BEIZUC.js.map +0 -1
  324. package/dist/chunk-OKPWFVXC.js +0 -24
  325. package/dist/chunk-OKPWFVXC.js.map +0 -1
  326. package/dist/chunk-PNOTQAYK.mjs +0 -560
  327. package/dist/chunk-PNOTQAYK.mjs.map +0 -1
  328. package/dist/chunk-PTMSDNGO.mjs.map +0 -1
  329. package/dist/chunk-Q2IAL7YV.js +0 -36
  330. package/dist/chunk-Q2IAL7YV.js.map +0 -1
  331. package/dist/chunk-QQ2WFYOD.js.map +0 -1
  332. package/dist/chunk-VQ54PUQV.js.map +0 -1
  333. package/dist/chunk-W5JEGA76.mjs +0 -33
  334. package/dist/chunk-W5JEGA76.mjs.map +0 -1
  335. package/dist/chunk-YGI7UU2D.mjs.map +0 -1
  336. package/dist/chunk-ZCLQSI5F.mjs +0 -271
  337. package/dist/chunk-ZCLQSI5F.mjs.map +0 -1
  338. package/dist/drizzle-auth-service-D-pljzCD.d.mts +0 -145
  339. package/dist/drizzle-auth-service-D3qryE_I.d.ts +0 -145
  340. package/dist/index-DNKZ7-R_.d.mts +0 -184
  341. package/dist/index-DNKZ7-R_.d.ts +0 -184
  342. package/dist/types-C5vUWf9u.d.ts +0 -70
  343. package/dist/types-IYCqCk2g.d.mts +0 -70
  344. /package/dist/{auth/middleware → common/auth/client}/index.js.map +0 -0
  345. /package/dist/{auth/middleware → common/auth/client}/index.mjs.map +0 -0
  346. /package/dist/{auth/routes → common/auth/components}/index.js.map +0 -0
  347. /package/dist/{auth/routes → common/auth/components}/index.mjs.map +0 -0
@@ -1,1086 +0,0 @@
1
- import React5, { createContext, useState, useRef, useCallback, useEffect, useContext } from 'react';
2
- import { createPortal } from 'react-dom';
3
- import { X, Phone, Lock, EyeOff, Eye, User, LogOut, LogIn } from 'lucide-react';
4
-
5
- // src/business/auth-legacy/components/AuthGuard.tsx
6
- var AuthContext = createContext(void 0);
7
- function extractUser(data) {
8
- return data?.user ?? data?.data?.user ?? null;
9
- }
10
- function extractValid(data) {
11
- if (typeof data?.valid === "boolean") return data.valid;
12
- if (typeof data?.data?.valid === "boolean") return data.data.valid;
13
- return false;
14
- }
15
- function AuthProvider({ children }) {
16
- const [user, setUser] = useState(null);
17
- const [loading, setLoading] = useState(true);
18
- const [isAuthenticated, setIsAuthenticated] = useState(false);
19
- const isMountedRef = useRef(true);
20
- const safeSetState = useCallback((updater) => {
21
- if (isMountedRef.current) {
22
- updater();
23
- }
24
- }, []);
25
- const validateSession = useCallback(async () => {
26
- console.log("\u{1F50D} [AuthContext] \u5F00\u59CB\u9A8C\u8BC1\u4F1A\u8BDD...");
27
- try {
28
- const response = await fetch("/api/auth/validate");
29
- console.log("\u{1F4E1} [AuthContext] \u4F1A\u8BDD\u9A8C\u8BC1\u54CD\u5E94\u72B6\u6001:", response.status);
30
- const data = await response.json();
31
- console.log("\u{1F4C4} [AuthContext] \u4F1A\u8BDD\u9A8C\u8BC1\u54CD\u5E94\u6570\u636E:", data);
32
- const resolvedUser = extractUser(data);
33
- const resolvedValid = extractValid(data);
34
- safeSetState(() => {
35
- if (resolvedValid && resolvedUser) {
36
- console.log("\u2705 [AuthContext] \u4F1A\u8BDD\u9A8C\u8BC1\u6210\u529F, \u7528\u6237:", resolvedUser);
37
- setUser(resolvedUser);
38
- setIsAuthenticated(true);
39
- } else {
40
- console.log("\u274C [AuthContext] \u4F1A\u8BDD\u9A8C\u8BC1\u5931\u8D25:", data.message);
41
- setUser(null);
42
- setIsAuthenticated(false);
43
- }
44
- setLoading(false);
45
- });
46
- } catch (error) {
47
- console.error("\u{1F4A5} [AuthContext] \u4F1A\u8BDD\u9A8C\u8BC1\u5F02\u5E38:", error);
48
- safeSetState(() => {
49
- setUser(null);
50
- setIsAuthenticated(false);
51
- setLoading(false);
52
- });
53
- }
54
- }, [safeSetState]);
55
- const login = useCallback(async (credentials) => {
56
- console.log("\u{1F511} [AuthContext] \u5F00\u59CB\u767B\u5F55...");
57
- console.log("\u{1F4DD} [AuthContext] \u767B\u5F55\u51ED\u636E:", { phone: credentials.phone, password: "***" });
58
- try {
59
- console.log("\u{1F4E4} [AuthContext] \u53D1\u9001\u767B\u5F55\u8BF7\u6C42\u5230 /api/auth/login");
60
- const response = await fetch("/api/auth/login", {
61
- method: "POST",
62
- headers: { "Content-Type": "application/json" },
63
- body: JSON.stringify(credentials)
64
- });
65
- console.log("\u{1F4E1} [AuthContext] \u6536\u5230\u54CD\u5E94\uFF0C\u72B6\u6001\u7801:", response.status);
66
- const data = await response.json();
67
- console.log("\u{1F4C4} [AuthContext] \u54CD\u5E94\u6570\u636E:", data);
68
- const resolvedUser = extractUser(data);
69
- if (data.success && resolvedUser) {
70
- console.log("\u2705 [AuthContext] \u767B\u5F55\u6210\u529F, \u5F00\u59CB\u66F4\u65B0\u5168\u5C40\u72B6\u6001");
71
- console.log("\u{1F464} [AuthContext] \u7528\u6237\u6570\u636E:", resolvedUser);
72
- console.log("\u{1F4CA} [AuthContext] \u66F4\u65B0\u524D\u72B6\u6001:", {
73
- currentUser: user ? `${user.name || "\u672A\u8BBE\u7F6E"} (${user.phone})` : null,
74
- currentIsAuthenticated: isAuthenticated,
75
- currentLoading: loading
76
- });
77
- console.log("\u{1F504} [AuthContext] \u6267\u884C\u5168\u5C40\u72B6\u6001\u66F4\u65B0...");
78
- safeSetState(() => {
79
- console.log("\u{1F504} [AuthContext] \u6B63\u5728\u8BBE\u7F6E\u7528\u6237:", resolvedUser);
80
- setUser(resolvedUser);
81
- console.log("\u{1F504} [AuthContext] \u6B63\u5728\u8BBE\u7F6E\u8BA4\u8BC1\u72B6\u6001: true");
82
- setIsAuthenticated(true);
83
- console.log("\u{1F504} [AuthContext] \u6B63\u5728\u8BBE\u7F6E\u52A0\u8F7D\u72B6\u6001: false");
84
- setLoading(false);
85
- console.log("\u2705 [AuthContext] \u5168\u5C40\u72B6\u6001\u66F4\u65B0\u5B8C\u6210");
86
- });
87
- setTimeout(() => {
88
- console.log("\u{1F389} [AuthContext] \u5EF6\u8FDF\u786E\u8BA4 - \u5168\u5C40\u767B\u5F55\u72B6\u6001\u5E94\u8BE5\u5DF2\u66F4\u65B0:", {
89
- user: resolvedUser,
90
- isAuthenticated: true
91
- });
92
- }, 0);
93
- console.log("\u{1F680} [AuthContext] \u8FD4\u56DE\u6210\u529F\u7ED3\u679C");
94
- return { success: true, user: resolvedUser };
95
- } else {
96
- console.log("\u274C [AuthContext] \u767B\u5F55\u5931\u8D25:", data.message);
97
- return { success: false, message: data.message };
98
- }
99
- } catch (error) {
100
- console.error("\u{1F4A5} [AuthContext] \u767B\u5F55\u5F02\u5E38:", error);
101
- return { success: false, message: "\u767B\u5F55\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5" };
102
- }
103
- }, [safeSetState, user, isAuthenticated, loading]);
104
- const register = useCallback(async (userData) => {
105
- console.log("\u{1F4DD} [AuthContext] \u5F00\u59CB\u6CE8\u518C...");
106
- try {
107
- const response = await fetch("/api/auth/register", {
108
- method: "POST",
109
- headers: { "Content-Type": "application/json" },
110
- body: JSON.stringify(userData)
111
- });
112
- const data = await response.json();
113
- console.log("\u{1F4E1} [AuthContext] \u6CE8\u518C\u54CD\u5E94:", data);
114
- const resolvedUser = extractUser(data);
115
- if (data.success && resolvedUser) {
116
- console.log("\u2705 [AuthContext] \u6CE8\u518C\u6210\u529F, \u7ACB\u5373\u66F4\u65B0\u5168\u5C40\u72B6\u6001");
117
- safeSetState(() => {
118
- setUser(resolvedUser);
119
- setIsAuthenticated(true);
120
- setLoading(false);
121
- });
122
- console.log("\u{1F680} [AuthContext] \u8FD4\u56DE\u6CE8\u518C\u6210\u529F\u7ED3\u679C");
123
- return { success: true, user: resolvedUser };
124
- } else {
125
- console.log("\u274C [AuthContext] \u6CE8\u518C\u5931\u8D25:", data.message);
126
- return { success: false, message: data.message };
127
- }
128
- } catch (error) {
129
- console.error("\u{1F4A5} [AuthContext] \u6CE8\u518C\u5F02\u5E38:", error);
130
- return { success: false, message: "\u6CE8\u518C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5" };
131
- }
132
- }, [safeSetState]);
133
- const logout = useCallback(async () => {
134
- console.log("\u{1F6AA} [AuthContext] \u5F00\u59CB\u767B\u51FA...");
135
- try {
136
- await fetch("/api/auth/logout", { method: "POST" });
137
- safeSetState(() => {
138
- setUser(null);
139
- setIsAuthenticated(false);
140
- });
141
- console.log("\u2705 [AuthContext] \u767B\u51FA\u6210\u529F, \u5168\u5C40\u72B6\u6001\u5DF2\u6E05\u9664");
142
- } catch (error) {
143
- console.error("\u{1F4A5} [AuthContext] \u767B\u51FA\u5931\u8D25:", error);
144
- }
145
- }, [safeSetState]);
146
- const refreshUser = useCallback(() => {
147
- console.log("\u{1F504} [AuthContext] \u5237\u65B0\u7528\u6237\u4FE1\u606F...");
148
- setLoading(true);
149
- validateSession();
150
- }, [validateSession]);
151
- useEffect(() => {
152
- isMountedRef.current = true;
153
- return () => {
154
- isMountedRef.current = false;
155
- };
156
- }, []);
157
- useEffect(() => {
158
- console.log("\u{1F680} [AuthContext] \u521D\u59CB\u5316, \u5F00\u59CB\u9A8C\u8BC1\u4F1A\u8BDD");
159
- validateSession();
160
- }, [validateSession]);
161
- useEffect(() => {
162
- console.log("\u{1F4CA} [AuthContext] \u5168\u5C40\u72B6\u6001\u53D8\u5316:", {
163
- isAuthenticated,
164
- user: user ? `${user.name || "\u672A\u8BBE\u7F6E"} (${user.phone})` : null,
165
- loading
166
- });
167
- }, [isAuthenticated, user, loading]);
168
- const value = {
169
- user,
170
- loading,
171
- isAuthenticated,
172
- login,
173
- register,
174
- logout,
175
- refreshUser
176
- };
177
- return /* @__PURE__ */ React5.createElement(AuthContext.Provider, { value }, children);
178
- }
179
- function useAuth() {
180
- const context = useContext(AuthContext);
181
- if (context === void 0) {
182
- throw new Error("useAuth must be used within an AuthProvider");
183
- }
184
- return context;
185
- }
186
-
187
- // src/business/auth-legacy/utils/authUtils.ts
188
- function validatePhoneNumber(phone) {
189
- return /^1[3-9]\d{9}$/.test(phone);
190
- }
191
- function validatePassword(password) {
192
- if (!password) {
193
- return { valid: false, message: "\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A" };
194
- }
195
- if (password.length < 6) {
196
- return { valid: false, message: "\u5BC6\u7801\u957F\u5EA6\u81F3\u5C116\u4F4D" };
197
- }
198
- return { valid: true };
199
- }
200
- function generateSessionToken() {
201
- return Math.random().toString(36).substring(2) + Date.now().toString(36) + Math.random().toString(36).substring(2);
202
- }
203
- function isAdmin(user) {
204
- return user?.role === "admin";
205
- }
206
- function isActiveUser(user) {
207
- return user?.isActive === true;
208
- }
209
- function getUserDisplayName(user) {
210
- return user.name || user.phone || "\u672A\u77E5\u7528\u6237";
211
- }
212
- function calculateSessionExpiry(days = 30) {
213
- return new Date(Date.now() + days * 24 * 60 * 60 * 1e3);
214
- }
215
- function isSessionExpired(expiresAt) {
216
- return /* @__PURE__ */ new Date() > new Date(expiresAt);
217
- }
218
- function ForgotPasswordModal({ isOpen, onClose, onSuccess }) {
219
- const [formData, setFormData] = useState({
220
- phone: "",
221
- newPassword: "",
222
- confirmPassword: "",
223
- verificationCode: ""
224
- });
225
- const [showPassword, setShowPassword] = useState(false);
226
- const [showConfirmPassword, setShowConfirmPassword] = useState(false);
227
- const [error, setError] = useState("");
228
- const [loading, setLoading] = useState(false);
229
- const [countdown, setCountdown] = useState(0);
230
- const [mounted, setMounted] = useState(false);
231
- useEffect(() => {
232
- setMounted(true);
233
- }, []);
234
- const handleInputChange = (e) => {
235
- const { name, value } = e.target;
236
- setFormData((prev) => ({ ...prev, [name]: value }));
237
- if (error) setError("");
238
- };
239
- const validateForm = () => {
240
- if (!formData.phone || !formData.newPassword || !formData.confirmPassword || !formData.verificationCode) {
241
- setError("\u8BF7\u586B\u5199\u5B8C\u6574\u4FE1\u606F");
242
- return false;
243
- }
244
- if (!validatePhoneNumber(formData.phone)) {
245
- setError("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u683C\u5F0F");
246
- return false;
247
- }
248
- const passwordValidation = validatePassword(formData.newPassword);
249
- if (!passwordValidation.valid) {
250
- setError(passwordValidation.message || "\u5BC6\u7801\u683C\u5F0F\u9519\u8BEF");
251
- return false;
252
- }
253
- if (formData.newPassword !== formData.confirmPassword) {
254
- setError("\u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u81F4");
255
- return false;
256
- }
257
- if (!/^\d{6}$/.test(formData.verificationCode)) {
258
- setError("\u8BF7\u8F93\u51656\u4F4D\u6570\u5B57\u9A8C\u8BC1\u7801");
259
- return false;
260
- }
261
- return true;
262
- };
263
- const handleSendCode = async () => {
264
- if (!formData.phone) {
265
- setError("\u8BF7\u8F93\u5165\u624B\u673A\u53F7");
266
- return;
267
- }
268
- if (!validatePhoneNumber(formData.phone)) {
269
- setError("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u683C\u5F0F");
270
- return;
271
- }
272
- try {
273
- setLoading(true);
274
- setError("");
275
- const response = await fetch("/api/auth/send-verification-code", {
276
- method: "POST",
277
- headers: { "Content-Type": "application/json" },
278
- body: JSON.stringify({ phone: formData.phone })
279
- });
280
- const data = await response.json();
281
- if (data.success) {
282
- setCountdown(60);
283
- const timer = setInterval(() => {
284
- setCountdown((prev) => {
285
- if (prev <= 1) {
286
- clearInterval(timer);
287
- return 0;
288
- }
289
- return prev - 1;
290
- });
291
- }, 1e3);
292
- console.log("\u2705 \u9A8C\u8BC1\u7801\u53D1\u9001\u6210\u529F");
293
- } else {
294
- setError(data.message || "\u53D1\u9001\u9A8C\u8BC1\u7801\u5931\u8D25");
295
- }
296
- } catch (error2) {
297
- console.error("\u53D1\u9001\u9A8C\u8BC1\u7801\u5F02\u5E38:", error2);
298
- setError("\u53D1\u9001\u9A8C\u8BC1\u7801\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
299
- } finally {
300
- setLoading(false);
301
- }
302
- };
303
- const handleSubmit = async (e) => {
304
- e.preventDefault();
305
- setError("");
306
- setLoading(true);
307
- try {
308
- if (!validateForm()) {
309
- return;
310
- }
311
- const response = await fetch("/api/auth/reset-password", {
312
- method: "POST",
313
- headers: { "Content-Type": "application/json" },
314
- body: JSON.stringify({
315
- phone: formData.phone,
316
- newPassword: formData.newPassword,
317
- verificationCode: formData.verificationCode
318
- })
319
- });
320
- const data = await response.json();
321
- if (data.success) {
322
- onSuccess();
323
- } else {
324
- setError(data.message || "\u91CD\u7F6E\u5BC6\u7801\u5931\u8D25");
325
- }
326
- } catch (error2) {
327
- setError("\u91CD\u7F6E\u5BC6\u7801\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
328
- } finally {
329
- setLoading(false);
330
- }
331
- };
332
- const handleOverlayClick = (e) => {
333
- if (e.target === e.currentTarget) {
334
- onClose();
335
- }
336
- };
337
- if (!isOpen || !mounted) return null;
338
- const modalContent = /* @__PURE__ */ React5.createElement(
339
- "div",
340
- {
341
- className: "fixed top-0 left-0 right-0 bottom-0 w-screen h-screen bg-black/50 backdrop-blur-sm flex items-center justify-center z-[9999] p-4",
342
- style: { margin: 0 },
343
- onClick: handleOverlayClick
344
- },
345
- /* @__PURE__ */ React5.createElement(
346
- "div",
347
- {
348
- className: "bg-white rounded-2xl shadow-xl w-full max-w-[420px] max-h-[90vh] overflow-y-auto relative",
349
- onClick: (e) => e.stopPropagation()
350
- },
351
- /* @__PURE__ */ React5.createElement(
352
- "button",
353
- {
354
- className: "absolute top-5 right-5 bg-transparent border-none text-gray-500 cursor-pointer p-2 rounded-lg transition-all hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 min-w-9 min-h-9 flex items-center justify-center",
355
- onClick: onClose
356
- },
357
- /* @__PURE__ */ React5.createElement(X, { size: 20 })
358
- ),
359
- /* @__PURE__ */ React5.createElement("div", { className: "px-6 pt-6 pb-4 text-center border-b border-gray-100" }, /* @__PURE__ */ React5.createElement("h2", { className: "text-2xl font-semibold text-gray-800 mb-2" }, "\u91CD\u7F6E\u5BC6\u7801"), /* @__PURE__ */ React5.createElement("p", { className: "text-gray-500 text-sm" }, "\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u548C\u9A8C\u8BC1\u7801\u91CD\u7F6E\u5BC6\u7801")),
360
- /* @__PURE__ */ React5.createElement("form", { onSubmit: handleSubmit, className: "p-6" }, /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "phone", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u624B\u673A\u53F7"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(Phone, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5.createElement(
361
- "input",
362
- {
363
- id: "phone",
364
- name: "phone",
365
- type: "tel",
366
- value: formData.phone,
367
- onChange: handleInputChange,
368
- placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7",
369
- className: "w-full py-3 px-4 pl-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
370
- disabled: loading
371
- }
372
- ))), /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "verificationCode", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u9A8C\u8BC1\u7801"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(
373
- "input",
374
- {
375
- id: "verificationCode",
376
- name: "verificationCode",
377
- type: "text",
378
- value: formData.verificationCode,
379
- onChange: handleInputChange,
380
- placeholder: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801",
381
- className: "w-full py-3 px-4 pr-28 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
382
- disabled: loading,
383
- maxLength: 6
384
- }
385
- ), /* @__PURE__ */ React5.createElement(
386
- "button",
387
- {
388
- type: "button",
389
- className: "absolute right-2 top-1/2 -translate-y-1/2 bg-transparent border-none text-blue-500 text-sm font-medium cursor-pointer px-2 py-1 rounded transition-all whitespace-nowrap hover:bg-blue-50 disabled:text-gray-400 disabled:cursor-not-allowed",
390
- onClick: handleSendCode,
391
- disabled: loading || countdown > 0
392
- },
393
- countdown > 0 ? `${countdown}\u79D2\u540E\u91CD\u8BD5` : "\u53D1\u9001\u9A8C\u8BC1\u7801"
394
- ))), /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "newPassword", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u65B0\u5BC6\u7801"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5.createElement(
395
- "input",
396
- {
397
- id: "newPassword",
398
- name: "newPassword",
399
- type: showPassword ? "text" : "password",
400
- value: formData.newPassword,
401
- onChange: handleInputChange,
402
- placeholder: "\u8BF7\u8F93\u5165\u65B0\u5BC6\u7801",
403
- className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
404
- disabled: loading
405
- }
406
- ), /* @__PURE__ */ React5.createElement(
407
- "button",
408
- {
409
- type: "button",
410
- className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
411
- onClick: () => setShowPassword(!showPassword),
412
- disabled: loading
413
- },
414
- showPassword ? /* @__PURE__ */ React5.createElement(EyeOff, { size: 18 }) : /* @__PURE__ */ React5.createElement(Eye, { size: 18 })
415
- ))), /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "confirmPassword", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u786E\u8BA4\u5BC6\u7801"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5.createElement(
416
- "input",
417
- {
418
- id: "confirmPassword",
419
- name: "confirmPassword",
420
- type: showConfirmPassword ? "text" : "password",
421
- value: formData.confirmPassword,
422
- onChange: handleInputChange,
423
- placeholder: "\u8BF7\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801",
424
- className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
425
- disabled: loading
426
- }
427
- ), /* @__PURE__ */ React5.createElement(
428
- "button",
429
- {
430
- type: "button",
431
- className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
432
- onClick: () => setShowConfirmPassword(!showConfirmPassword),
433
- disabled: loading
434
- },
435
- showConfirmPassword ? /* @__PURE__ */ React5.createElement(EyeOff, { size: 18 }) : /* @__PURE__ */ React5.createElement(Eye, { size: 18 })
436
- ))), error && /* @__PURE__ */ React5.createElement("div", { className: "text-red-500 text-sm my-4 p-3 bg-red-50 border border-red-200 rounded-lg leading-relaxed" }, error), /* @__PURE__ */ React5.createElement(
437
- "button",
438
- {
439
- type: "submit",
440
- className: "w-full bg-blue-500 text-white border-none py-3.5 px-6 rounded-lg text-base font-medium cursor-pointer transition-all mt-2 min-h-[52px] hover:bg-blue-600 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30 active:translate-y-0 disabled:bg-gray-400 disabled:cursor-not-allowed disabled:transform-none disabled:shadow-none focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2",
441
- disabled: loading
442
- },
443
- loading ? "\u63D0\u4EA4\u4E2D..." : "\u91CD\u7F6E\u5BC6\u7801"
444
- ))
445
- )
446
- );
447
- return createPortal(modalContent, document.body);
448
- }
449
-
450
- // src/business/auth-legacy/components/LoginModal.tsx
451
- function LoginModal({ isOpen, onClose, onSuccess, onSwitchToRegister }) {
452
- const { login } = useAuth();
453
- const [formData, setFormData] = useState({
454
- phone: "",
455
- password: ""
456
- });
457
- const [showPassword, setShowPassword] = useState(false);
458
- const [error, setError] = useState("");
459
- const [loading, setLoading] = useState(false);
460
- const [showForgotPassword, setShowForgotPassword] = useState(false);
461
- const [mounted, setMounted] = useState(false);
462
- useEffect(() => {
463
- setMounted(true);
464
- }, []);
465
- const fillDemoAccount = (type) => {
466
- if (process.env.NODE_ENV === "development") {
467
- const accounts = {
468
- admin: { phone: "13800138000", password: "admin123456" },
469
- user: { phone: "13900139000", password: "test123456" }
470
- };
471
- setFormData(accounts[type]);
472
- setError("");
473
- }
474
- };
475
- const handleInputChange = (e) => {
476
- const { name, value } = e.target;
477
- setFormData((prev) => ({ ...prev, [name]: value }));
478
- if (error) setError("");
479
- };
480
- const handleSubmit = async (e) => {
481
- e.preventDefault();
482
- setError("");
483
- setLoading(true);
484
- console.log("\u{1F504} [LoginModal] handleSubmit \u5F00\u59CB");
485
- try {
486
- if (!formData.phone || !formData.password) {
487
- console.log("\u274C [LoginModal] \u524D\u7AEF\u9A8C\u8BC1\u5931\u8D25: \u4FE1\u606F\u4E0D\u5B8C\u6574");
488
- setError("\u8BF7\u586B\u5199\u5B8C\u6574\u4FE1\u606F");
489
- return;
490
- }
491
- if (!validatePhoneNumber(formData.phone)) {
492
- console.log("\u274C [LoginModal] \u524D\u7AEF\u9A8C\u8BC1\u5931\u8D25: \u624B\u673A\u53F7\u683C\u5F0F\u9519\u8BEF");
493
- setError("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7");
494
- return;
495
- }
496
- console.log("\u2705 [LoginModal] \u524D\u7AEF\u9A8C\u8BC1\u901A\u8FC7");
497
- console.log("\u{1F511} [LoginModal] \u63D0\u4EA4\u767B\u5F55\u8868\u5355:", {
498
- phone: formData.phone,
499
- password: "***"
500
- });
501
- console.log("\u{1F4DE} [LoginModal] \u51C6\u5907\u8C03\u7528 useAuth.login()...");
502
- const result = await login(formData);
503
- console.log("\u{1F4E1} [LoginModal] useAuth.login() \u8FD4\u56DE\u7ED3\u679C:", result);
504
- if (result.success) {
505
- console.log("\u2705 [LoginModal] \u767B\u5F55\u6210\u529F\uFF0C\u51C6\u5907\u8C03\u7528 onSuccess()");
506
- console.log("\u{1F464} [LoginModal] \u767B\u5F55\u6210\u529F\u7684\u7528\u6237\u4FE1\u606F:", result.user);
507
- setTimeout(() => {
508
- console.log("\u{1F3AF} [LoginModal] \u8C03\u7528 onSuccess \u56DE\u8C03");
509
- onSuccess();
510
- console.log("\u{1F3C1} [LoginModal] onSuccess \u8C03\u7528\u5B8C\u6210");
511
- }, 100);
512
- } else {
513
- console.log("\u274C [LoginModal] \u767B\u5F55\u5931\u8D25:", result.message);
514
- setError(result.message || "\u767B\u5F55\u5931\u8D25");
515
- }
516
- } catch (error2) {
517
- console.error("\u{1F4A5} [LoginModal] \u767B\u5F55\u5F02\u5E38:", error2);
518
- setError("\u767B\u5F55\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
519
- } finally {
520
- console.log("\u{1F51A} [LoginModal] handleSubmit \u7ED3\u675F\uFF0C\u8BBE\u7F6E loading = false");
521
- setLoading(false);
522
- }
523
- };
524
- const handleOverlayClick = (e) => {
525
- if (e.target === e.currentTarget) {
526
- onClose();
527
- }
528
- };
529
- if (!isOpen || !mounted) return null;
530
- const modalContent = /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
531
- "div",
532
- {
533
- className: "fixed top-0 left-0 right-0 bottom-0 w-screen h-screen bg-black/50 backdrop-blur-sm flex items-center justify-center z-[9999] p-4",
534
- style: { margin: 0 },
535
- onClick: handleOverlayClick
536
- },
537
- /* @__PURE__ */ React5.createElement(
538
- "div",
539
- {
540
- className: "bg-white rounded-2xl shadow-xl w-full max-w-[420px] max-h-[90vh] overflow-y-auto relative",
541
- onClick: (e) => e.stopPropagation()
542
- },
543
- /* @__PURE__ */ React5.createElement(
544
- "button",
545
- {
546
- className: "absolute top-5 right-5 bg-transparent border-none text-gray-500 cursor-pointer p-2 rounded-lg transition-all hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 min-w-9 min-h-9 flex items-center justify-center",
547
- onClick: onClose
548
- },
549
- /* @__PURE__ */ React5.createElement(X, { size: 20 })
550
- ),
551
- /* @__PURE__ */ React5.createElement("div", { className: "px-6 pt-6 pb-4 text-center border-b border-gray-100" }, /* @__PURE__ */ React5.createElement("h2", { className: "text-2xl font-semibold text-gray-800 mb-2" }, "\u7528\u6237\u767B\u5F55"), /* @__PURE__ */ React5.createElement("p", { className: "text-gray-500 text-sm" }, "\u8BF7\u8F93\u5165\u60A8\u7684\u624B\u673A\u53F7\u548C\u5BC6\u7801")),
552
- process.env.NODE_ENV === "development" && /* @__PURE__ */ React5.createElement("div", { className: "px-6 py-4 bg-amber-50 border-b border-gray-100" }, /* @__PURE__ */ React5.createElement("p", { className: "text-xs text-amber-800 font-medium mb-2" }, "\u5F00\u53D1\u73AF\u5883\u5FEB\u6377\u767B\u5F55\uFF1A"), /* @__PURE__ */ React5.createElement("div", { className: "flex gap-2" }, /* @__PURE__ */ React5.createElement(
553
- "button",
554
- {
555
- type: "button",
556
- onClick: () => fillDemoAccount("admin"),
557
- className: "px-3 py-1.5 text-xs bg-amber-400 text-amber-900 border-none rounded-md cursor-pointer transition-all font-medium hover:bg-amber-500"
558
- },
559
- "\u7BA1\u7406\u5458\u8D26\u53F7"
560
- ), /* @__PURE__ */ React5.createElement(
561
- "button",
562
- {
563
- type: "button",
564
- onClick: () => fillDemoAccount("user"),
565
- className: "px-3 py-1.5 text-xs bg-amber-400 text-amber-900 border-none rounded-md cursor-pointer transition-all font-medium hover:bg-amber-500"
566
- },
567
- "\u7528\u6237\u8D26\u53F7"
568
- ))),
569
- /* @__PURE__ */ React5.createElement("form", { onSubmit: handleSubmit, className: "p-6" }, /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "phone", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u624B\u673A\u53F7"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(User, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5.createElement(
570
- "input",
571
- {
572
- id: "phone",
573
- name: "phone",
574
- type: "tel",
575
- autoComplete: "tel",
576
- value: formData.phone,
577
- onChange: handleInputChange,
578
- placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7",
579
- className: "w-full py-3 px-4 pl-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
580
- disabled: loading
581
- }
582
- ))), /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "password", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u5BC6\u7801"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5.createElement(
583
- "input",
584
- {
585
- id: "password",
586
- name: "password",
587
- type: showPassword ? "text" : "password",
588
- autoComplete: "current-password",
589
- value: formData.password,
590
- onChange: handleInputChange,
591
- placeholder: "\u8BF7\u8F93\u5165\u5BC6\u7801",
592
- className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
593
- disabled: loading
594
- }
595
- ), /* @__PURE__ */ React5.createElement(
596
- "button",
597
- {
598
- type: "button",
599
- className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
600
- onClick: () => setShowPassword(!showPassword),
601
- disabled: loading
602
- },
603
- showPassword ? /* @__PURE__ */ React5.createElement(EyeOff, { size: 18 }) : /* @__PURE__ */ React5.createElement(Eye, { size: 18 })
604
- ))), /* @__PURE__ */ React5.createElement("div", { className: "text-right -mt-2 mb-4" }, /* @__PURE__ */ React5.createElement(
605
- "button",
606
- {
607
- type: "button",
608
- onClick: () => setShowForgotPassword(true),
609
- className: "bg-transparent border-none text-blue-500 cursor-pointer text-sm font-medium underline px-1 py-0.5 rounded transition-all hover:text-blue-600 hover:bg-blue-50 hover:no-underline focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
610
- },
611
- "\u5FD8\u8BB0\u5BC6\u7801\uFF1F"
612
- )), error && /* @__PURE__ */ React5.createElement("div", { className: "text-red-500 text-sm my-4 p-3 bg-red-50 border border-red-200 rounded-lg leading-relaxed" }, error), /* @__PURE__ */ React5.createElement(
613
- "button",
614
- {
615
- type: "submit",
616
- className: "w-full bg-blue-500 text-white border-none py-3.5 px-6 rounded-lg text-base font-medium cursor-pointer transition-all mt-2 min-h-[52px] hover:bg-blue-600 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30 active:translate-y-0 disabled:bg-gray-400 disabled:cursor-not-allowed disabled:transform-none disabled:shadow-none focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2",
617
- disabled: loading
618
- },
619
- loading ? "\u767B\u5F55\u4E2D..." : "\u767B\u5F55"
620
- ), onSwitchToRegister && /* @__PURE__ */ React5.createElement("div", { className: "text-center mt-5 pt-4 border-t border-gray-100" }, /* @__PURE__ */ React5.createElement("span", { className: "text-gray-500 text-sm mr-1" }, "\u8FD8\u6CA1\u6709\u8D26\u53F7\uFF1F"), /* @__PURE__ */ React5.createElement(
621
- "button",
622
- {
623
- type: "button",
624
- onClick: onSwitchToRegister,
625
- className: "bg-transparent border-none text-blue-500 cursor-pointer text-sm font-medium underline px-1 py-0.5 rounded transition-all hover:text-blue-600 hover:bg-blue-50 hover:no-underline focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
626
- },
627
- "\u7ACB\u5373\u6CE8\u518C"
628
- )))
629
- )
630
- ), /* @__PURE__ */ React5.createElement(
631
- ForgotPasswordModal,
632
- {
633
- isOpen: showForgotPassword,
634
- onClose: () => setShowForgotPassword(false),
635
- onSuccess: () => {
636
- setShowForgotPassword(false);
637
- onSuccess();
638
- }
639
- }
640
- ));
641
- return createPortal(modalContent, document.body);
642
- }
643
-
644
- // src/business/auth-legacy/components/AuthGuard.tsx
645
- function AuthGuard({
646
- children,
647
- fallback,
648
- requireAuth = true
649
- }) {
650
- const { isAuthenticated, loading, refreshUser } = useAuth();
651
- const [showLoginModal, setShowLoginModal] = useState(false);
652
- useEffect(() => {
653
- if (!loading && requireAuth && !isAuthenticated) {
654
- setShowLoginModal(true);
655
- }
656
- }, [loading, requireAuth, isAuthenticated]);
657
- const handleLoginSuccess = () => {
658
- refreshUser();
659
- setShowLoginModal(false);
660
- };
661
- if (loading) {
662
- return /* @__PURE__ */ React5.createElement("div", { style: {
663
- display: "flex",
664
- alignItems: "center",
665
- justifyContent: "center",
666
- minHeight: "200px",
667
- color: "#6b7280",
668
- flexDirection: "column",
669
- gap: "12px"
670
- } }, /* @__PURE__ */ React5.createElement("div", { style: {
671
- width: "32px",
672
- height: "32px",
673
- border: "3px solid #e5e7eb",
674
- borderTop: "3px solid #3b82f6",
675
- borderRadius: "50%",
676
- animation: "spin 1s linear infinite"
677
- } }), /* @__PURE__ */ React5.createElement("div", null, "\u9A8C\u8BC1\u767B\u5F55\u72B6\u6001..."));
678
- }
679
- if (requireAuth && !isAuthenticated) {
680
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, fallback || /* @__PURE__ */ React5.createElement("div", { style: {
681
- display: "flex",
682
- alignItems: "center",
683
- justifyContent: "center",
684
- minHeight: "200px",
685
- color: "#6b7280",
686
- flexDirection: "column",
687
- gap: "16px",
688
- padding: "24px",
689
- textAlign: "center"
690
- } }, /* @__PURE__ */ React5.createElement("div", { style: {
691
- fontSize: "48px",
692
- opacity: 0.5
693
- } }, "\u{1F512}"), /* @__PURE__ */ React5.createElement("div", { style: {
694
- fontSize: "18px",
695
- fontWeight: "500"
696
- } }, "\u8BF7\u5148\u767B\u5F55\u4EE5\u8BBF\u95EE\u6B64\u9875\u9762"), /* @__PURE__ */ React5.createElement("div", { style: {
697
- fontSize: "14px",
698
- opacity: 0.7
699
- } }, "\u767B\u5F55\u540E\u5373\u53EF\u67E5\u770B\u76F8\u5173\u5185\u5BB9")), /* @__PURE__ */ React5.createElement(
700
- LoginModal,
701
- {
702
- isOpen: showLoginModal,
703
- onClose: () => setShowLoginModal(false),
704
- onSuccess: handleLoginSuccess
705
- }
706
- ));
707
- }
708
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, children);
709
- }
710
- function RegisterModal({ isOpen, onClose, onSuccess, onSwitchToLogin }) {
711
- const { register } = useAuth();
712
- const [formData, setFormData] = useState({
713
- phone: "",
714
- password: "",
715
- confirmPassword: "",
716
- name: ""
717
- });
718
- const [showPassword, setShowPassword] = useState(false);
719
- const [showConfirmPassword, setShowConfirmPassword] = useState(false);
720
- const [error, setError] = useState("");
721
- const [loading, setLoading] = useState(false);
722
- const [mounted, setMounted] = useState(false);
723
- useEffect(() => {
724
- setMounted(true);
725
- }, []);
726
- const handleInputChange = (e) => {
727
- const { name, value } = e.target;
728
- setFormData((prev) => ({ ...prev, [name]: value }));
729
- if (error) setError("");
730
- };
731
- const validateForm = () => {
732
- if (!formData.phone || !formData.password || !formData.confirmPassword) {
733
- setError("\u8BF7\u586B\u5199\u5FC5\u8981\u4FE1\u606F");
734
- return false;
735
- }
736
- if (!validatePhoneNumber(formData.phone)) {
737
- setError("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u683C\u5F0F");
738
- return false;
739
- }
740
- const passwordValidation = validatePassword(formData.password);
741
- if (!passwordValidation.valid) {
742
- setError(passwordValidation.message || "\u5BC6\u7801\u683C\u5F0F\u9519\u8BEF");
743
- return false;
744
- }
745
- if (formData.password !== formData.confirmPassword) {
746
- setError("\u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u81F4");
747
- return false;
748
- }
749
- return true;
750
- };
751
- const handleSubmit = async (e) => {
752
- e.preventDefault();
753
- setError("");
754
- setLoading(true);
755
- try {
756
- if (!validateForm()) {
757
- return;
758
- }
759
- console.log("\u{1F4DD} [RegisterModal] \u63D0\u4EA4\u6CE8\u518C\u8868\u5355:", {
760
- phone: formData.phone,
761
- name: formData.name || "\u672A\u8BBE\u7F6E",
762
- password: "***"
763
- });
764
- const result = await register({
765
- phone: formData.phone,
766
- password: formData.password,
767
- name: formData.name || void 0
768
- });
769
- if (result.success) {
770
- console.log("\u2705 [RegisterModal] \u6CE8\u518C\u6210\u529F");
771
- onSuccess();
772
- } else {
773
- console.log("\u274C [RegisterModal] \u6CE8\u518C\u5931\u8D25:", result.message);
774
- setError(result.message || "\u6CE8\u518C\u5931\u8D25");
775
- }
776
- } catch (error2) {
777
- console.error("\u{1F4A5} [RegisterModal] \u6CE8\u518C\u5F02\u5E38:", error2);
778
- setError("\u6CE8\u518C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
779
- } finally {
780
- setLoading(false);
781
- }
782
- };
783
- const handleOverlayClick = (e) => {
784
- if (e.target === e.currentTarget) {
785
- onClose();
786
- }
787
- };
788
- if (!isOpen || !mounted) return null;
789
- const modalContent = /* @__PURE__ */ React5.createElement(
790
- "div",
791
- {
792
- className: "fixed top-0 left-0 right-0 bottom-0 w-screen h-screen bg-black/50 backdrop-blur-sm flex items-center justify-center z-[9999] p-4",
793
- style: { margin: 0 },
794
- onClick: handleOverlayClick
795
- },
796
- /* @__PURE__ */ React5.createElement(
797
- "div",
798
- {
799
- className: "bg-white rounded-2xl shadow-xl w-full max-w-[420px] max-h-[90vh] overflow-y-auto relative",
800
- onClick: (e) => e.stopPropagation()
801
- },
802
- /* @__PURE__ */ React5.createElement(
803
- "button",
804
- {
805
- className: "absolute top-5 right-5 bg-transparent border-none text-gray-500 cursor-pointer p-2 rounded-lg transition-all hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 min-w-9 min-h-9 flex items-center justify-center",
806
- onClick: onClose
807
- },
808
- /* @__PURE__ */ React5.createElement(X, { size: 20 })
809
- ),
810
- /* @__PURE__ */ React5.createElement("div", { className: "px-6 pt-6 pb-4 text-center border-b border-gray-100" }, /* @__PURE__ */ React5.createElement("h2", { className: "text-2xl font-semibold text-gray-800 mb-2" }, "\u7528\u6237\u6CE8\u518C"), /* @__PURE__ */ React5.createElement("p", { className: "text-gray-500 text-sm" }, "\u8BF7\u586B\u5199\u4EE5\u4E0B\u4FE1\u606F\u521B\u5EFA\u8D26\u6237")),
811
- /* @__PURE__ */ React5.createElement("form", { onSubmit: handleSubmit, className: "p-6" }, /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "phone", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u624B\u673A\u53F7 *"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(Phone, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5.createElement(
812
- "input",
813
- {
814
- id: "phone",
815
- name: "phone",
816
- type: "tel",
817
- autoComplete: "tel",
818
- value: formData.phone,
819
- onChange: handleInputChange,
820
- placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7",
821
- className: "w-full py-3 px-4 pl-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
822
- disabled: loading
823
- }
824
- ))), /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "name", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u59D3\u540D"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(User, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5.createElement(
825
- "input",
826
- {
827
- id: "name",
828
- name: "name",
829
- type: "text",
830
- autoComplete: "name",
831
- value: formData.name,
832
- onChange: handleInputChange,
833
- placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D\uFF08\u53EF\u9009\uFF09",
834
- className: "w-full py-3 px-4 pl-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
835
- disabled: loading
836
- }
837
- ))), /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "password", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u5BC6\u7801 *"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5.createElement(
838
- "input",
839
- {
840
- id: "password",
841
- name: "password",
842
- type: showPassword ? "text" : "password",
843
- autoComplete: "new-password",
844
- value: formData.password,
845
- onChange: handleInputChange,
846
- placeholder: "\u8BF7\u8F93\u5165\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09",
847
- className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
848
- disabled: loading
849
- }
850
- ), /* @__PURE__ */ React5.createElement(
851
- "button",
852
- {
853
- type: "button",
854
- className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
855
- onClick: () => setShowPassword(!showPassword),
856
- disabled: loading
857
- },
858
- showPassword ? /* @__PURE__ */ React5.createElement(EyeOff, { size: 18 }) : /* @__PURE__ */ React5.createElement(Eye, { size: 18 })
859
- ))), /* @__PURE__ */ React5.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: "confirmPassword", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u786E\u8BA4\u5BC6\u7801 *"), /* @__PURE__ */ React5.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5.createElement(Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5.createElement(
860
- "input",
861
- {
862
- id: "confirmPassword",
863
- name: "confirmPassword",
864
- type: showConfirmPassword ? "text" : "password",
865
- autoComplete: "new-password",
866
- value: formData.confirmPassword,
867
- onChange: handleInputChange,
868
- placeholder: "\u8BF7\u518D\u6B21\u8F93\u5165\u5BC6\u7801",
869
- className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
870
- disabled: loading
871
- }
872
- ), /* @__PURE__ */ React5.createElement(
873
- "button",
874
- {
875
- type: "button",
876
- className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
877
- onClick: () => setShowConfirmPassword(!showConfirmPassword),
878
- disabled: loading
879
- },
880
- showConfirmPassword ? /* @__PURE__ */ React5.createElement(EyeOff, { size: 18 }) : /* @__PURE__ */ React5.createElement(Eye, { size: 18 })
881
- ))), error && /* @__PURE__ */ React5.createElement("div", { className: "text-red-500 text-sm my-4 p-3 bg-red-50 border border-red-200 rounded-lg leading-relaxed" }, error), /* @__PURE__ */ React5.createElement(
882
- "button",
883
- {
884
- type: "submit",
885
- className: "w-full bg-blue-500 text-white border-none py-3.5 px-6 rounded-lg text-base font-medium cursor-pointer transition-all mt-2 min-h-[52px] hover:bg-blue-600 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30 active:translate-y-0 disabled:bg-gray-400 disabled:cursor-not-allowed disabled:transform-none disabled:shadow-none focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2",
886
- disabled: loading
887
- },
888
- loading ? "\u6CE8\u518C\u4E2D..." : "\u6CE8\u518C"
889
- ), onSwitchToLogin && /* @__PURE__ */ React5.createElement("div", { className: "text-center mt-5 pt-4 border-t border-gray-100" }, /* @__PURE__ */ React5.createElement("span", { className: "text-gray-500 text-sm mr-1" }, "\u5DF2\u6709\u8D26\u53F7\uFF1F"), /* @__PURE__ */ React5.createElement(
890
- "button",
891
- {
892
- type: "button",
893
- onClick: onSwitchToLogin,
894
- className: "bg-transparent border-none text-blue-500 cursor-pointer text-sm font-medium underline px-1 py-0.5 rounded transition-all hover:text-blue-600 hover:bg-blue-50 hover:no-underline focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
895
- },
896
- "\u7ACB\u5373\u767B\u5F55"
897
- )))
898
- )
899
- );
900
- return createPortal(modalContent, document.body);
901
- }
902
-
903
- // src/business/auth-legacy/components/UserMenu.tsx
904
- function UserMenu({ customMenuItems = [], className }) {
905
- const { user, isAuthenticated, logout } = useAuth();
906
- const [isOpen, setIsOpen] = useState(false);
907
- const [showLoginModal, setShowLoginModal] = useState(false);
908
- const [showRegisterModal, setShowRegisterModal] = useState(false);
909
- const toggleMenu = () => {
910
- setIsOpen(!isOpen);
911
- };
912
- const handleMenuClick = (e) => {
913
- e.stopPropagation();
914
- };
915
- const handleCustomMenuClick = (item) => {
916
- console.log(`\u{1F527} [UserMenu] \u81EA\u5B9A\u4E49\u83DC\u5355\u9879\u88AB\u70B9\u51FB: ${item.label}`);
917
- item.onClick();
918
- setIsOpen(false);
919
- };
920
- const handleLogin = () => {
921
- console.log("\u{1F511} [UserMenu] \u767B\u5F55\u6309\u94AE\u88AB\u70B9\u51FB");
922
- setShowLoginModal(true);
923
- setIsOpen(false);
924
- };
925
- const handleRegister = () => {
926
- console.log("\u{1F4DD} [UserMenu] \u6CE8\u518C\u6309\u94AE\u88AB\u70B9\u51FB");
927
- setShowRegisterModal(true);
928
- setIsOpen(false);
929
- };
930
- const handleLogout = async () => {
931
- console.log("\u{1F6AA} [UserMenu] \u9000\u51FA\u767B\u5F55\u6309\u94AE\u88AB\u70B9\u51FB");
932
- try {
933
- await logout();
934
- console.log("\u2705 [UserMenu] \u9000\u51FA\u767B\u5F55\u6210\u529F");
935
- } catch (error) {
936
- console.error("\u9000\u51FA\u767B\u5F55\u5931\u8D25:", error);
937
- }
938
- setIsOpen(false);
939
- };
940
- const handleAuthSuccess = () => {
941
- console.log("\u{1F389} [UserMenu] \u8BA4\u8BC1\u6210\u529F\u56DE\u8C03\u88AB\u8C03\u7528");
942
- console.log("\u{1F464} [UserMenu] \u5F53\u524DuseAuth\u72B6\u6001:", {
943
- user: user ? `${user.name || "\u672A\u8BBE\u7F6E"} (${user.phone})` : null,
944
- isAuthenticated
945
- });
946
- setShowLoginModal(false);
947
- setShowRegisterModal(false);
948
- console.log("\u2705 [UserMenu] \u8BA4\u8BC1\u6210\u529F\u5904\u7406\u5B8C\u6210 - \u6A21\u6001\u6846\u5DF2\u5173\u95ED");
949
- setTimeout(() => {
950
- console.log("\u{1F50D} [UserMenu] \u5EF6\u8FDF\u72B6\u6001\u68C0\u67E5:", {
951
- user: user ? `${user.name || "\u672A\u8BBE\u7F6E"} (${user.phone})` : null,
952
- isAuthenticated
953
- });
954
- }, 500);
955
- };
956
- const handleSwitchToRegister = () => {
957
- console.log("\u{1F504} [UserMenu] \u4ECE\u767B\u5F55\u5207\u6362\u5230\u6CE8\u518C");
958
- setShowLoginModal(false);
959
- setShowRegisterModal(true);
960
- };
961
- const handleSwitchToLogin = () => {
962
- console.log("\u{1F504} [UserMenu] \u4ECE\u6CE8\u518C\u5207\u6362\u5230\u767B\u5F55");
963
- setShowRegisterModal(false);
964
- setShowLoginModal(true);
965
- };
966
- const getVisibleCustomMenuItems = () => {
967
- return customMenuItems.filter((item) => {
968
- if (item.requireAuth === true) {
969
- return isAuthenticated;
970
- }
971
- if (item.requireAuth === false) {
972
- return !isAuthenticated;
973
- }
974
- return true;
975
- });
976
- };
977
- React5.useEffect(() => {
978
- const handleGlobalClick = () => {
979
- setIsOpen(false);
980
- };
981
- if (isOpen) {
982
- document.addEventListener("click", handleGlobalClick);
983
- }
984
- return () => {
985
- document.removeEventListener("click", handleGlobalClick);
986
- };
987
- }, [isOpen]);
988
- const visibleCustomMenuItems = getVisibleCustomMenuItems();
989
- return /* @__PURE__ */ React5.createElement("div", { className: `relative inline-block ${className || ""}` }, /* @__PURE__ */ React5.createElement(
990
- "button",
991
- {
992
- className: "flex items-center gap-2 px-3 py-2 bg-slate-50 text-slate-500 border border-slate-200 rounded-lg cursor-pointer transition-all min-w-11 min-h-11 text-sm font-medium hover:bg-slate-200 hover:text-slate-800 focus:outline-none focus:ring-2 focus:ring-blue-500/10",
993
- onClick: toggleMenu
994
- },
995
- /* @__PURE__ */ React5.createElement(User, { size: 24 }),
996
- isAuthenticated && user && /* @__PURE__ */ React5.createElement("span", { className: "max-w-[120px] overflow-hidden text-ellipsis whitespace-nowrap" }, user.name || user.phone)
997
- ), isOpen && /* @__PURE__ */ React5.createElement(
998
- "div",
999
- {
1000
- className: "absolute top-[calc(100%+0.5rem)] right-0 z-[1000] min-w-[200px] bg-white border border-slate-200 rounded-xl shadow-lg max-h-[90vh] overflow-y-auto p-2 animate-in slide-in-from-top-2 fade-in duration-200",
1001
- onClick: handleMenuClick
1002
- },
1003
- isAuthenticated && user ? (
1004
- // 已登录状态的菜单
1005
- /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: "p-3 mb-2 bg-slate-50 rounded-lg" }, /* @__PURE__ */ React5.createElement("div", { className: "text-sm font-semibold text-slate-800 mb-1 overflow-hidden text-ellipsis whitespace-nowrap" }, user.name || "\u672A\u8BBE\u7F6E\u540D\u79F0"), /* @__PURE__ */ React5.createElement("div", { className: "text-xs text-slate-500 mb-1 overflow-hidden text-ellipsis whitespace-nowrap" }, user.phone), /* @__PURE__ */ React5.createElement("div", { className: "text-xs text-blue-500 font-medium" }, user.role === "admin" ? "\u7BA1\u7406\u5458" : "\u666E\u901A\u7528\u6237")), visibleCustomMenuItems.length > 0 && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: "h-px bg-slate-200 my-2" }), visibleCustomMenuItems.map((item) => {
1006
- const IconComponent = item.icon;
1007
- return /* @__PURE__ */ React5.createElement(
1008
- "button",
1009
- {
1010
- key: item.id,
1011
- className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-slate-100 hover:text-slate-800 focus:outline-none focus:bg-slate-100 focus:ring-2 focus:ring-blue-500/10",
1012
- onClick: () => handleCustomMenuClick(item)
1013
- },
1014
- IconComponent && /* @__PURE__ */ React5.createElement(IconComponent, { size: 16 }),
1015
- /* @__PURE__ */ React5.createElement("span", null, item.label)
1016
- );
1017
- })), /* @__PURE__ */ React5.createElement("div", { className: "h-px bg-slate-200 my-2" }), /* @__PURE__ */ React5.createElement(
1018
- "button",
1019
- {
1020
- className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-red-50 hover:text-red-600 focus:outline-none focus:bg-red-50 focus:text-red-600 focus:ring-2 focus:ring-red-500/10",
1021
- onClick: handleLogout
1022
- },
1023
- /* @__PURE__ */ React5.createElement(LogOut, { size: 16 }),
1024
- /* @__PURE__ */ React5.createElement("span", null, "\u9000\u51FA\u767B\u5F55")
1025
- ))
1026
- ) : (
1027
- // 未登录状态的菜单
1028
- /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
1029
- "button",
1030
- {
1031
- className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-slate-100 hover:text-slate-800 focus:outline-none focus:bg-slate-100 focus:ring-2 focus:ring-blue-500/10",
1032
- onClick: handleLogin
1033
- },
1034
- /* @__PURE__ */ React5.createElement(LogIn, { size: 16 }),
1035
- /* @__PURE__ */ React5.createElement("span", null, "\u767B\u5F55")
1036
- ), /* @__PURE__ */ React5.createElement(
1037
- "button",
1038
- {
1039
- className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-slate-100 hover:text-slate-800 focus:outline-none focus:bg-slate-100 focus:ring-2 focus:ring-blue-500/10",
1040
- onClick: handleRegister
1041
- },
1042
- /* @__PURE__ */ React5.createElement(User, { size: 16 }),
1043
- /* @__PURE__ */ React5.createElement("span", null, "\u6CE8\u518C")
1044
- ), visibleCustomMenuItems.length > 0 && /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { className: "h-px bg-slate-200 my-2" }), visibleCustomMenuItems.map((item) => {
1045
- const IconComponent = item.icon;
1046
- return /* @__PURE__ */ React5.createElement(
1047
- "button",
1048
- {
1049
- key: item.id,
1050
- className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-slate-100 hover:text-slate-800 focus:outline-none focus:bg-slate-100 focus:ring-2 focus:ring-blue-500/10",
1051
- onClick: () => handleCustomMenuClick(item)
1052
- },
1053
- IconComponent && /* @__PURE__ */ React5.createElement(IconComponent, { size: 16 }),
1054
- /* @__PURE__ */ React5.createElement("span", null, item.label)
1055
- );
1056
- })))
1057
- )
1058
- ), /* @__PURE__ */ React5.createElement(
1059
- LoginModal,
1060
- {
1061
- isOpen: showLoginModal,
1062
- onClose: () => setShowLoginModal(false),
1063
- onSuccess: handleAuthSuccess,
1064
- onSwitchToRegister: handleSwitchToRegister
1065
- }
1066
- ), /* @__PURE__ */ React5.createElement(
1067
- RegisterModal,
1068
- {
1069
- isOpen: showRegisterModal,
1070
- onClose: () => setShowRegisterModal(false),
1071
- onSuccess: handleAuthSuccess,
1072
- onSwitchToLogin: handleSwitchToLogin
1073
- }
1074
- ));
1075
- }
1076
-
1077
- // src/business/auth-legacy/types/index.ts
1078
- var UserRole = /* @__PURE__ */ ((UserRole2) => {
1079
- UserRole2["USER"] = "user";
1080
- UserRole2["ADMIN"] = "admin";
1081
- return UserRole2;
1082
- })(UserRole || {});
1083
-
1084
- export { AuthGuard, AuthProvider, ForgotPasswordModal, LoginModal, RegisterModal, UserMenu, UserRole, calculateSessionExpiry, generateSessionToken, getUserDisplayName, isActiveUser, isAdmin, isSessionExpired, useAuth, validatePassword, validatePhoneNumber };
1085
- //# sourceMappingURL=index.mjs.map
1086
- //# sourceMappingURL=index.mjs.map