pit-docs-mcp 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +180 -0
- package/dist/codegen.d.ts +5 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/codegen.js +112 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +115 -0
- package/dist/resources.d.ts +3 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +80 -0
- package/dist/tools.d.ts +3 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +258 -0
- package/dist/utils.d.ts +26 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +198 -0
- package/docs/codegen/pit-simplify-web.md +686 -0
- package/docs/pitBusinessUi/README.md +102 -0
- package/docs/pitBusinessUi/add-date-picker.md +57 -0
- package/docs/pitBusinessUi/add-operation.md +64 -0
- package/docs/pitBusinessUi/batch-download.md +44 -0
- package/docs/pitBusinessUi/bill-tree-dialog.md +82 -0
- package/docs/pitBusinessUi/collapse.md +88 -0
- package/docs/pitBusinessUi/date-time-picker.md +74 -0
- package/docs/pitBusinessUi/design-report-explain.md +47 -0
- package/docs/pitBusinessUi/dialog.md +89 -0
- package/docs/pitBusinessUi/dic-radio.md +67 -0
- package/docs/pitBusinessUi/dic.md +78 -0
- package/docs/pitBusinessUi/document-preview.md +54 -0
- package/docs/pitBusinessUi/drawer.md +67 -0
- package/docs/pitBusinessUi/editor.md +63 -0
- package/docs/pitBusinessUi/expand-search-form.md +65 -0
- package/docs/pitBusinessUi/file-preview.md +56 -0
- package/docs/pitBusinessUi/flow-table-status.md +47 -0
- package/docs/pitBusinessUi/icon-box.md +74 -0
- package/docs/pitBusinessUi/image-preview.md +55 -0
- package/docs/pitBusinessUi/image.md +53 -0
- package/docs/pitBusinessUi/input-formatter.md +100 -0
- package/docs/pitBusinessUi/input-number.md +47 -0
- package/docs/pitBusinessUi/input-select.md +68 -0
- package/docs/pitBusinessUi/input.md +56 -0
- package/docs/pitBusinessUi/jm-preview.md +47 -0
- package/docs/pitBusinessUi/json-editor.md +71 -0
- package/docs/pitBusinessUi/loading-btn.md +64 -0
- package/docs/pitBusinessUi/monaco.md +82 -0
- package/docs/pitBusinessUi/money-input.md +59 -0
- package/docs/pitBusinessUi/pagination.md +70 -0
- package/docs/pitBusinessUi/password-strength.md +59 -0
- package/docs/pitBusinessUi/positive-number.md +63 -0
- package/docs/pitBusinessUi/preview-image.md +62 -0
- package/docs/pitBusinessUi/preview-office.md +50 -0
- package/docs/pitBusinessUi/preview.md +57 -0
- package/docs/pitBusinessUi/quill.md +52 -0
- package/docs/pitBusinessUi/runflow-btn.md +52 -0
- package/docs/pitBusinessUi/search-date-picker.md +60 -0
- package/docs/pitBusinessUi/select-bid-list.md +66 -0
- package/docs/pitBusinessUi/select-color.md +38 -0
- package/docs/pitBusinessUi/select-contract-tree.md +41 -0
- package/docs/pitBusinessUi/select-dept.md +38 -0
- package/docs/pitBusinessUi/select-project-unit.md +48 -0
- package/docs/pitBusinessUi/select-section-tree.md +45 -0
- package/docs/pitBusinessUi/select-section.md +66 -0
- package/docs/pitBusinessUi/select-string.md +60 -0
- package/docs/pitBusinessUi/select-system-unit.md +41 -0
- package/docs/pitBusinessUi/select-user-by-role.md +51 -0
- package/docs/pitBusinessUi/switch.md +43 -0
- package/docs/pitBusinessUi/table-contract.md +66 -0
- package/docs/pitBusinessUi/table-operation.md +81 -0
- package/docs/pitBusinessUi/table.md +75 -0
- package/docs/pitBusinessUi/tag.md +86 -0
- package/docs/pitBusinessUi/textarea.md +65 -0
- package/docs/pitBusinessUi/transfer-direct.md +57 -0
- package/docs/pitBusinessUi/transfer-user-project.md +78 -0
- package/docs/pitBusinessUi/transfer.md +68 -0
- package/docs/pitBusinessUi/tree-lazy.md +72 -0
- package/docs/pitBusinessUi/tree-select-name.md +59 -0
- package/docs/pitBusinessUi/tree-select-plus.md +106 -0
- package/docs/pitBusinessUi/tree-select.md +86 -0
- package/docs/pitBusinessUi/upload-avatar.md +60 -0
- package/docs/pitBusinessUi/upload-file-dialog.md +86 -0
- package/docs/pitBusinessUi/upload-file.md +77 -0
- package/docs/pitBusinessUi/upload-list-card.md +62 -0
- package/docs/pitBusinessUi/upload-table.md +77 -0
- package/docs/pitBusinessUi/user-transform.md +72 -0
- package/docs/pitBusinessUi/utils.md +272 -0
- package/docs/pitBusinessUtils/README.md +144 -0
- package/docs/pitBusinessUtils/auth.md +170 -0
- package/docs/pitBusinessUtils/clipboard.md +72 -0
- package/docs/pitBusinessUtils/filePreview.md +60 -0
- package/docs/pitBusinessUtils/formValidate.md +75 -0
- package/docs/pitBusinessUtils/generateTitle.md +49 -0
- package/docs/pitBusinessUtils/get-page-title.md +65 -0
- package/docs/pitBusinessUtils/i18n.md +130 -0
- package/docs/pitBusinessUtils/jwks.md +82 -0
- package/docs/pitBusinessUtils/oss.md +391 -0
- package/docs/pitBusinessUtils/passwordValidate.md +120 -0
- package/docs/pitBusinessUtils/pit.md +496 -0
- package/docs/pitBusinessUtils/print.md +126 -0
- package/docs/pitBusinessUtils/request.md +137 -0
- package/docs/pitBusinessUtils/scroll-to.md +68 -0
- package/docs/pitBusinessUtils/utils.md +762 -0
- package/docs/pitBusinessUtils/validate.md +224 -0
- package/docs/pitElementUi/alert.md +238 -0
- package/docs/pitElementUi/avatar.md +147 -0
- package/docs/pitElementUi/backtop.md +60 -0
- package/docs/pitElementUi/badge.md +120 -0
- package/docs/pitElementUi/base-tabs.md +73 -0
- package/docs/pitElementUi/border.md +135 -0
- package/docs/pitElementUi/breadcrumb.md +44 -0
- package/docs/pitElementUi/button.md +301 -0
- package/docs/pitElementUi/calendar.md +66 -0
- package/docs/pitElementUi/card.md +170 -0
- package/docs/pitElementUi/carousel.md +212 -0
- package/docs/pitElementUi/cascader.md +1966 -0
- package/docs/pitElementUi/checkbox.md +283 -0
- package/docs/pitElementUi/collapse.md +131 -0
- package/docs/pitElementUi/color-picker.md +123 -0
- package/docs/pitElementUi/color.md +244 -0
- package/docs/pitElementUi/container.md +240 -0
- package/docs/pitElementUi/custom-theme.md +131 -0
- package/docs/pitElementUi/date-picker.md +448 -0
- package/docs/pitElementUi/datetime-picker.md +254 -0
- package/docs/pitElementUi/descriptions.md +191 -0
- package/docs/pitElementUi/dialog-header.md +53 -0
- package/docs/pitElementUi/dialog.md +239 -0
- package/docs/pitElementUi/divider.md +61 -0
- package/docs/pitElementUi/drawer.md +307 -0
- package/docs/pitElementUi/dropdown.md +308 -0
- package/docs/pitElementUi/empty.md +61 -0
- package/docs/pitElementUi/font-family.md +90 -0
- package/docs/pitElementUi/form-base.md +1239 -0
- package/docs/pitElementUi/form-item-checkbox-group.md +48 -0
- package/docs/pitElementUi/form-item-date.md +60 -0
- package/docs/pitElementUi/form-item-dic.md +18 -0
- package/docs/pitElementUi/form-item-editor.md +16 -0
- package/docs/pitElementUi/form-item-input-money.md +19 -0
- package/docs/pitElementUi/form-item-input-number.md +20 -0
- package/docs/pitElementUi/form-item-input.md +18 -0
- package/docs/pitElementUi/form-item-radio-group.md +21 -0
- package/docs/pitElementUi/form-item-select.md +21 -0
- package/docs/pitElementUi/form-item-switch.md +15 -0
- package/docs/pitElementUi/form-item-textarea.md +20 -0
- package/docs/pitElementUi/form-item-tree-select.md +27 -0
- package/docs/pitElementUi/form-item-upload-card.md +18 -0
- package/docs/pitElementUi/form-item-upload.md +1 -0
- package/docs/pitElementUi/form-two.md +102 -0
- package/docs/pitElementUi/form.md +952 -0
- package/docs/pitElementUi/i18n.md +228 -0
- package/docs/pitElementUi/icon-custom.md +99 -0
- package/docs/pitElementUi/icon-line-custom.md +12 -0
- package/docs/pitElementUi/icon.md +28 -0
- package/docs/pitElementUi/image.md +178 -0
- package/docs/pitElementUi/infiniteScroll.md +87 -0
- package/docs/pitElementUi/input-number.md +197 -0
- package/docs/pitElementUi/input-select.md +1 -0
- package/docs/pitElementUi/input.md +800 -0
- package/docs/pitElementUi/installation.md +9 -0
- package/docs/pitElementUi/layout-column.md +376 -0
- package/docs/pitElementUi/layout-tree.md +715 -0
- package/docs/pitElementUi/layout.md +354 -0
- package/docs/pitElementUi/link.md +66 -0
- package/docs/pitElementUi/loading.md +208 -0
- package/docs/pitElementUi/menu.md +403 -0
- package/docs/pitElementUi/message-box.md +326 -0
- package/docs/pitElementUi/message.md +219 -0
- package/docs/pitElementUi/notification.md +311 -0
- package/docs/pitElementUi/page-header.md +40 -0
- package/docs/pitElementUi/pagination.md +200 -0
- package/docs/pitElementUi/popconfirm.md +60 -0
- package/docs/pitElementUi/popover.md +167 -0
- package/docs/pitElementUi/progress.md +178 -0
- package/docs/pitElementUi/quickstart.md +290 -0
- package/docs/pitElementUi/radio.md +211 -0
- package/docs/pitElementUi/rate.md +135 -0
- package/docs/pitElementUi/result.md +76 -0
- package/docs/pitElementUi/select-tree.md +661 -0
- package/docs/pitElementUi/select.md +586 -0
- package/docs/pitElementUi/skeleton.md +316 -0
- package/docs/pitElementUi/slider.md +237 -0
- package/docs/pitElementUi/steps.md +154 -0
- package/docs/pitElementUi/switch.md +142 -0
- package/docs/pitElementUi/table.md +4023 -0
- package/docs/pitElementUi/tabs.md +303 -0
- package/docs/pitElementUi/tag.md +203 -0
- package/docs/pitElementUi/time-picker.md +199 -0
- package/docs/pitElementUi/timeline.md +154 -0
- package/docs/pitElementUi/tooltip.md +177 -0
- package/docs/pitElementUi/transfer.md +249 -0
- package/docs/pitElementUi/transition.md +155 -0
- package/docs/pitElementUi/tree.md +1157 -0
- package/docs/pitElementUi/typography.md +151 -0
- package/docs/pitElementUi/upload-table.md +39 -0
- package/docs/pitElementUi/upload.md +392 -0
- package/docs/pitElementUi/virtual-list.md +154 -0
- package/docs/pitElementUi/virtual-select-tree.md +243 -0
- package/docs/pitElementUi/virtual-select.md +451 -0
- package/docs/pitElementUi/virtual-table-column.md +1 -0
- package/docs/pitElementUi/virtual-table.md +490 -0
- package/docs/pitElementUi/virtual-tree.md +119 -0
- package/package.json +33 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# request — HTTP 请求封装
|
|
2
|
+
|
|
3
|
+
基于 `axios` 封装的 HTTP 请求实例,采用**高度解耦设计**:所有业务逻辑(token 注入、错误提示、响应数据解构等)均通过三个 `window` 全局回调函数由宿主项目注入,本库不内置任何业务逻辑。
|
|
4
|
+
|
|
5
|
+
## 引用方式
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import request from 'pit-business-utils'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 实例配置
|
|
14
|
+
|
|
15
|
+
| 配置项 | 值 | 说明 |
|
|
16
|
+
|--------|-----|------|
|
|
17
|
+
| `baseURL` | `""` | 空字符串,实际 baseURL 在 `setConfigCallback` 中注入 |
|
|
18
|
+
| `withCredentials` | `false` | 跨域不携带 Cookie |
|
|
19
|
+
| `timeout` | `20000` | 超时时间 20 秒 |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 全局回调注入(必须在应用初始化时配置)
|
|
24
|
+
|
|
25
|
+
> ⚠️ **以下三个 `window` 函数必须在宿主项目初始化时注入**,否则请求拦截器将报错或无法正常工作。
|
|
26
|
+
|
|
27
|
+
### `window.setConfigCallback(config)`
|
|
28
|
+
|
|
29
|
+
**请求拦截回调**,在每次发送请求前调用,用于注入 token、设置 baseURL 等。
|
|
30
|
+
|
|
31
|
+
| 参数 | 类型 | 说明 |
|
|
32
|
+
|------|------|------|
|
|
33
|
+
| `config` | `AxiosRequestConfig` | axios 请求配置对象 |
|
|
34
|
+
|
|
35
|
+
| — | — |
|
|
36
|
+
|---|---|
|
|
37
|
+
| **必须返回** | 修改后的 `config` 对象 |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
### `window.requestThen(response)`
|
|
42
|
+
|
|
43
|
+
**响应成功回调**,在 HTTP 状态码 2xx 时调用,用于统一处理响应数据、业务错误码判断等。
|
|
44
|
+
|
|
45
|
+
| 参数 | 类型 | 说明 |
|
|
46
|
+
|------|------|------|
|
|
47
|
+
| `response` | `AxiosResponse` | axios 完整响应对象 |
|
|
48
|
+
|
|
49
|
+
| — | — |
|
|
50
|
+
|---|---|
|
|
51
|
+
| **必须返回** | 处理后的数据(通常为 `response.data` 或解构后的业务数据) |
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### `window.requestCatch(error)`
|
|
56
|
+
|
|
57
|
+
**响应失败回调**,在 HTTP 状态码非 2xx 或网络错误时调用,用于统一弹出错误提示、处理 401 跳转等。
|
|
58
|
+
|
|
59
|
+
| 参数 | 类型 | 说明 |
|
|
60
|
+
|------|------|------|
|
|
61
|
+
| `error` | `AxiosError` | axios 错误对象 |
|
|
62
|
+
|
|
63
|
+
| — | — |
|
|
64
|
+
|---|---|
|
|
65
|
+
| **必须返回** | `Promise.reject(error)` 或处理后的值 |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 宿主项目初始化示例
|
|
70
|
+
|
|
71
|
+
在项目的 `main.js` 或请求初始化文件中添加以下配置:
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
import { getToken } from 'pit-business-utils'
|
|
75
|
+
|
|
76
|
+
// 请求拦截:注入 token 和 baseURL
|
|
77
|
+
window.setConfigCallback = (config) => {
|
|
78
|
+
config.baseURL = process.env.VUE_APP_BASE_API
|
|
79
|
+
const token = getToken()
|
|
80
|
+
if (token) {
|
|
81
|
+
config.headers['Authorization'] = `Bearer ${token}`
|
|
82
|
+
}
|
|
83
|
+
return config
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 响应成功:解构业务数据,处理业务错误码
|
|
87
|
+
window.requestThen = (response) => {
|
|
88
|
+
const res = response.data
|
|
89
|
+
if (res.code !== 200) {
|
|
90
|
+
Vue.prototype.$message.error(res.message || '请求失败')
|
|
91
|
+
return Promise.reject(new Error(res.message))
|
|
92
|
+
}
|
|
93
|
+
return res
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 响应失败:统一错误提示
|
|
97
|
+
window.requestCatch = (error) => {
|
|
98
|
+
const status = error.response?.status
|
|
99
|
+
if (status === 401) {
|
|
100
|
+
// token 失效,跳转登录
|
|
101
|
+
removeAll()
|
|
102
|
+
router.push('/login')
|
|
103
|
+
} else {
|
|
104
|
+
Vue.prototype.$message.error(error.message || '网络错误,请稍后重试')
|
|
105
|
+
}
|
|
106
|
+
return Promise.reject(error)
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 在业务模块中使用
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
import request from 'pit-business-utils'
|
|
116
|
+
|
|
117
|
+
// GET 请求
|
|
118
|
+
export const getUserList = (params) =>
|
|
119
|
+
request.get('/api/user/list', { params })
|
|
120
|
+
|
|
121
|
+
// POST 请求
|
|
122
|
+
export const createUser = (data) =>
|
|
123
|
+
request.post('/api/user/create', data)
|
|
124
|
+
|
|
125
|
+
// 文件下载(responseType: 'blob')
|
|
126
|
+
export const exportExcel = (params) =>
|
|
127
|
+
request.get('/api/user/export', { params, responseType: 'blob' })
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 注意事项
|
|
133
|
+
|
|
134
|
+
- 三个 `window` 全局回调 **缺少任何一个都会导致请求出错**,务必在应用入口文件中全部配置。
|
|
135
|
+
- `baseURL` 不在库内配置,必须在 `setConfigCallback` 中通过 `config.baseURL = ...` 设置。
|
|
136
|
+
- 上传进度监听请在调用方传入 `onUploadProgress` 配置,axios 实例本身支持该特性。
|
|
137
|
+
- 超时时间为 20 秒,如需针对单个请求修改,可在调用时传入 `{ timeout: 60000 }`。
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# scroll-to — 平滑滚动
|
|
2
|
+
|
|
3
|
+
提供平滑滚动页面到指定位置的工具函数,使用 ease-in-out 缓动动画,自动兼容各主流浏览器。
|
|
4
|
+
|
|
5
|
+
## 引用方式
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import { scrollTo } from 'pit-business-utils'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 函数
|
|
14
|
+
|
|
15
|
+
### `scrollTo(to, duration, callback)`
|
|
16
|
+
|
|
17
|
+
将页面平滑滚动到指定的纵向位置,动画完成后可触发回调。
|
|
18
|
+
|
|
19
|
+
| 参数 | 类型 | 必填 | 说明 |
|
|
20
|
+
|------|------|------|------|
|
|
21
|
+
| `to` | `number` | ✅ | 目标滚动位置(距页面顶部的像素值),传 `0` 即回到顶部 |
|
|
22
|
+
| `duration` | `number` | — | 动画持续时间(毫秒),默认 `500` |
|
|
23
|
+
| `callback` | `Function` | — | 动画完成后的回调函数 |
|
|
24
|
+
|
|
25
|
+
| — | — |
|
|
26
|
+
|---|---|
|
|
27
|
+
| **返回值** | `void` |
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 使用示例
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { scrollTo } from 'pit-business-utils'
|
|
35
|
+
|
|
36
|
+
// 回到顶部(500ms 动画)
|
|
37
|
+
scrollTo(0)
|
|
38
|
+
|
|
39
|
+
// 滚动到 500px 位置,动画持续 800ms
|
|
40
|
+
scrollTo(500, 800)
|
|
41
|
+
|
|
42
|
+
// 滚动完成后执行回调
|
|
43
|
+
scrollTo(0, 500, () => {
|
|
44
|
+
console.log('已回到顶部')
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// 配合 el-backtop 的 click 事件使用
|
|
50
|
+
methods: {
|
|
51
|
+
backToTop() {
|
|
52
|
+
scrollTo(0, 400)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 动画说明
|
|
60
|
+
|
|
61
|
+
使用 **ease-in-out 二次缓动函数**:动画开始和结束时速度慢,中间速度快,视觉上更自然流畅。内部每帧增量约 20ms,优先使用 `requestAnimationFrame`,在不支持的浏览器中回退为 `setTimeout`。
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 注意事项
|
|
66
|
+
|
|
67
|
+
- `scrollTo` 操作的是 `document.documentElement.scrollTop` / `document.body.scrollTop`,适用于**页面级滚动**,不适用于局部容器内部滚动。
|
|
68
|
+
- 若需要滚动局部容器元素(如 `el-scrollbar`),请直接操作容器元素的 `scrollTop` 属性,或使用对应组件提供的方法。
|