This commit is contained in:
SunCheng
2026-02-15 10:10:28 +08:00
parent e51a3edd50
commit a88556c784
92 changed files with 6751 additions and 776 deletions

View File

@@ -4,9 +4,11 @@
**Parent:** EmailBill/AGENTS.md
## OVERVIEW
Axios-based HTTP client modules for backend API integration with request/response interceptors.
## STRUCTURE
```
Web/src/api/
├── request.js # Base HTTP client setup
@@ -26,17 +28,19 @@ Web/src/api/
```
## WHERE TO LOOK
| Task | Location | Notes |
|------|----------|-------|
| Base HTTP setup | request.js | Axios interceptors, error handling |
| Authentication | auth.js | Login, token management |
| Budget data | budget.js | Budget CRUD, statistics |
| Transactions | transactionRecord.js | Transaction operations |
| Categories | transactionCategory.js | Category management |
| Statistics | statistics.js | Analytics, reports |
| Notifications | notification.js | Push subscription handling |
| Task | Location | Notes |
| --------------- | ---------------------- | ---------------------------------- |
| Base HTTP setup | request.js | Axios interceptors, error handling |
| Authentication | auth.js | Login, token management |
| Budget data | budget.js | Budget CRUD, statistics |
| Transactions | transactionRecord.js | Transaction operations |
| Categories | transactionCategory.js | Category management |
| Statistics | statistics.js | Analytics, reports |
| Notifications | notification.js | Push subscription handling |
## CONVENTIONS
- All functions return Promises with async/await
- Error handling via try/catch with user messages
- HTTP methods: get, post, put, delete mapping to REST
@@ -45,6 +49,7 @@ Web/src/api/
- Consistent error message format
## ANTI-PATTERNS (THIS LAYER)
- Never fetch directly without going through these modules
- Don't hardcode API endpoints (use environment variables)
- Avoid synchronous operations
@@ -52,8 +57,9 @@ Web/src/api/
- No business logic in API clients
## UNIQUE STYLES
- Chinese error messages for user feedback
- Automatic token refresh handling
- Request/response logging for debugging
- Paged query patterns for list endpoints
- File upload handling for imports
- File upload handling for imports

View File

@@ -15,8 +15,8 @@ const request = axios.create({
// 生成请求ID
const generateRequestId = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 | 0
const v = c === 'x' ? r : (r & 0x3 | 0x8)
const r = (Math.random() * 16) | 0
const v = c === 'x' ? r : (r & 0x3) | 0x8
return v.toString(16)
})
}

View File

@@ -1,4 +1,4 @@
import request from './request'
import request from './request'
/**
* 获取分类列表(支持按类型筛选)
@@ -103,3 +103,15 @@ export const updateSelectedIcon = (categoryId, selectedIndex) => {
data: { categoryId, selectedIndex }
})
}
/**
* 删除分类图标
* @param {number} id - 分类ID
* @returns {Promise<{success: boolean}>}
*/
export const deleteCategoryIcon = (id) => {
return request({
url: `/TransactionCategory/DeleteIcon/${id}`,
method: 'delete'
})
}