fix: abort機制

This commit is contained in:
skytek_xinliang
2026-06-01 14:50:47 +08:00
parent f61432ad8a
commit 915f3b7f2f
9 changed files with 70 additions and 16 deletions
+6
View File
@@ -84,3 +84,9 @@ token 由 `tokenService` 作為單一來源:
## 請求取消
需要取消請求時,由 store 或 composable 建立 `AbortController`service module 只接收 `signal`。不要讓 service module 持有 controller 或 UI 狀態。
建議做法:
- 在 store/composable 以 key 管理同類請求(例如 `auth/login``menu/get-menu`)。
- 發新請求前先取消同 key 舊請求,避免競態與多餘流量。
- 請求結束後於 `finally` 清理該 key;離開流程(如 `clear``logout`)時清理全部 key。