refactor: ky

This commit is contained in:
skytek_xinliang
2026-05-07 11:17:30 +08:00
parent 87fbc1dda8
commit 71683482e1
15 changed files with 146 additions and 360 deletions
+3 -1
View File
@@ -99,7 +99,9 @@ export interface ReportSummary {
}
export const reportsApi = {
list: () => httpClient.get<ReportSummary[]>('/Reports'),
list: async () => ({
data: await httpClient.get('Reports').json<ReportSummary[]>(),
}),
}
```
+2 -2
View File
@@ -241,7 +241,7 @@ route 集中放在 `src/router/routes.ts`。不要在 view 或 component 裡臨
store 檔案直接放在 `src/stores/*.ts`。不要建立 `src/stores/stores/*` 或其他重複巢狀 store 目錄。
service 放在 `src/services`,負責外部 API 與 HTTP 細節。component 不應直接處理底層 HTTP client、token、interceptor 或錯誤正規化。
service 放在 `src/services`,負責外部 API 與 HTTP 細節。component 不應直接處理底層 HTTP client、token、hooks 或錯誤正規化。
資料流優先順序:
@@ -251,7 +251,7 @@ service 放在 `src/services`,負責外部 API 與 HTTP 細節。component 不
4. store 或 composable 呼叫 service。
5. service 回傳資料,不持有 UI 狀態。
不要讓 service import component、view 或 store。不要讓 component 直接繞過既有 store/composable 去操作 token、session 或 HTTP interceptor
不要讓 service import component、view 或 store。不要讓 component 直接繞過既有 store/composable 去操作 token、session 或 HTTP hooks
## 環境變數規則