fix: abort機制
This commit is contained in:
@@ -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。
|
||||
|
||||
Reference in New Issue
Block a user