mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-09-12 16:40:40 +08:00
refactor: 架构升级
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
# HTTP Request
|
||||
|
||||
**官方文档**: https://uviewpro.cn
|
||||
|
||||
|
||||
## Instructions
|
||||
|
||||
This example demonstrates HTTP request utilities in uView Pro.
|
||||
|
||||
### Key Concepts
|
||||
|
||||
- Request methods
|
||||
- Request interceptors
|
||||
- Response interceptors
|
||||
- Error handling
|
||||
|
||||
### Example: Basic Request
|
||||
|
||||
```javascript
|
||||
import { request } from 'uview-pro'
|
||||
|
||||
request({
|
||||
url: '/api/user',
|
||||
method: 'GET'
|
||||
}).then(res => {
|
||||
console.log('Response:', res)
|
||||
}).catch(err => {
|
||||
console.error('Error:', err)
|
||||
})
|
||||
```
|
||||
|
||||
### Example: POST Request
|
||||
|
||||
```javascript
|
||||
import { request } from 'uview-pro'
|
||||
|
||||
request({
|
||||
url: '/api/user',
|
||||
method: 'POST',
|
||||
data: {
|
||||
name: 'John',
|
||||
email: 'john@example.com'
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('Response:', res)
|
||||
})
|
||||
```
|
||||
|
||||
### Example: Request Interceptor
|
||||
|
||||
```javascript
|
||||
import { request } from 'uview-pro'
|
||||
|
||||
request.interceptors.request.use(config => {
|
||||
// Add token
|
||||
config.header = {
|
||||
...config.header,
|
||||
'Authorization': 'Bearer token'
|
||||
}
|
||||
return config
|
||||
})
|
||||
```
|
||||
|
||||
### Example: Response Interceptor
|
||||
|
||||
```javascript
|
||||
import { request } from 'uview-pro'
|
||||
|
||||
request.interceptors.response.use(
|
||||
response => {
|
||||
return response.data
|
||||
},
|
||||
error => {
|
||||
console.error('Request error:', error)
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
### Example: Request Config
|
||||
|
||||
```javascript
|
||||
import { request } from 'uview-pro'
|
||||
|
||||
request({
|
||||
url: '/api/user',
|
||||
method: 'GET',
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
timeout: 10000
|
||||
})
|
||||
```
|
||||
|
||||
### Key Points
|
||||
|
||||
- Support GET, POST, PUT, DELETE methods
|
||||
- Request and response interceptors
|
||||
- Error handling
|
||||
- Configurable timeout
|
||||
- Support custom headers
|
||||
@@ -0,0 +1,73 @@
|
||||
# Tools Introduction
|
||||
|
||||
**官方文档**: https://uviewpro.cn
|
||||
|
||||
|
||||
## Instructions
|
||||
|
||||
This example provides an introduction to uView Pro tools and utilities.
|
||||
|
||||
### Key Concepts
|
||||
|
||||
- Tool categories
|
||||
- Tool usage
|
||||
- Tool methods
|
||||
|
||||
### Example: Tool Categories
|
||||
|
||||
**HTTP Request (HTTP 请求)**:
|
||||
- Request methods
|
||||
- Request interceptors
|
||||
- Response interceptors
|
||||
|
||||
**Storage (存储)**:
|
||||
- setStorage, getStorage
|
||||
- removeStorage, clearStorage
|
||||
|
||||
**Router (路由)**:
|
||||
- navigateTo, redirectTo
|
||||
- navigateBack, switchTab
|
||||
|
||||
**Validator (验证)**:
|
||||
- Validation methods
|
||||
- Form validation
|
||||
|
||||
**Format (格式化)**:
|
||||
- Date format
|
||||
- Number format
|
||||
- Text format
|
||||
|
||||
**Color (颜色)**:
|
||||
- Color conversion
|
||||
- Color utilities
|
||||
|
||||
### Example: Using Tools
|
||||
|
||||
```javascript
|
||||
// HTTP Request
|
||||
import { request } from 'uview-pro'
|
||||
|
||||
request({
|
||||
url: '/api/user',
|
||||
method: 'GET'
|
||||
})
|
||||
|
||||
// Storage
|
||||
import { setStorage, getStorage } from 'uview-pro'
|
||||
|
||||
setStorage('key', 'value')
|
||||
const value = getStorage('key')
|
||||
|
||||
// Router
|
||||
import { navigateTo } from 'uview-pro'
|
||||
|
||||
navigateTo('/pages/index/index')
|
||||
```
|
||||
|
||||
### Key Points
|
||||
|
||||
- Rich utility methods
|
||||
- Easy to use
|
||||
- Well documented
|
||||
- TypeScript support
|
||||
- Optimized for uni-app
|
||||
Reference in New Issue
Block a user