Constants
Functions
- useSm2()
国密 sm2
- useSm3(msg, [options]) ⇒
* 国密 sm3 加密
- useSm4Encrypt(msg, key, [options]) ⇒
Uint8Array 国密 sm4 加密
- useSm4Decrypt(encryptData, key, [options]) ⇒
Uint8Array 国密 sm4 解密
- useDayjs(date, [format]) ⇒
dayjs.Dayjs 根据格式创建 Dayjs 对象
- useDateFormat(date, format) ⇒
string 格式化日期
- useDateUnix(date) ⇒
number|string 获取日期的 Unix 时间戳
- useTimestampFormat(timestamp, [format]) ⇒
string 根据时间戳格式化日期
- useHiddenForm(options) ⇒
HTMLFormElement 创建一个隐藏的表单
- useProcessStatus(res, ops)
处理请求结果
- useProcessStatusSuccess(res, success)
处理正确请求结果
- useFormFail(e)
处理表单提交失败
- useFormFormat(form, [format]) ⇒
Object 处理表单数据
- useFetch([fetcher]) ⇒
Object 通用 AJAX 请求
- get(url, [config]) ⇒
Promise.<unknown> get请求
- post(url, data, [config]) ⇒
Promise.<unknown> post请求
- useTextFromOptionsValue(value, options) ⇒
*|string|string 从 options 中根据 value 获取 text
- useFindTextsInValues(options, values, [adapter]) ⇒
从嵌套的 options 中根据 value 获取 text, 如 [1, 3] => ["东", "南"]
- useFindLabelsFromPath(options, path, [adapter]) ⇒
从嵌套的 options 中根据 value 获取 label
- useFindTextsFromPath(options, path, [adapter]) ⇒
[移动端适配] 从嵌套的 options 中根据 value 获取 text
- useFindParentValues(options, value, adapter) ⇒
从嵌套的 options 中根据 value 获取整个 values 路径, 如地区路径: 440113 => [440000, 440100, 440113]
STATUS : Object
请求返回状态码
usePage
分页请求
Kind: global constant
| Param | Type | Description |
|---|---|---|
| pagination | object | 分页对象 |
| pagination.uri | string | 请求地址 |
| [pagination.params] | object | 请求参数 |
| [pagination.page] | number | 当前页码 |
| [pagination.finishedText] | string | 加载完毕文本 |
| [pagination.loading] | boolean | 加载状态 |
| [pagination.finished] | boolean | 加载完毕 |
| [pagination.error] | boolean | 是否错误 |
| [pagination.errorText] | string | 错误文本 |
| [pagination.empty] | boolean | 是否无内容 |
| [pagination.items] | array | 分页数据 |
| refresh | boolean | 是否刷新 |
| [process] | function | 数据处理函数 |
useSm2()
国密 sm2
useSm3(msg, [options]) ⇒ *
国密 sm3 加密
Kind: global function
| Param | Type |
|---|---|
| msg | |
| [options] | Object |
useSm4Encrypt(msg, key, [options]) ⇒ Uint8Array
国密 sm4 加密
Kind: global function
| Param | Type |
|---|---|
| msg | |
| key | |
| [options] | Object |
useSm4Decrypt(encryptData, key, [options]) ⇒ Uint8Array
国密 sm4 解密
Kind: global function
| Param | Type |
|---|---|
| encryptData | |
| key | |
| [options] | Object |
useDayjs(date, [format]) ⇒ dayjs.Dayjs
根据格式创建 Dayjs 对象
Kind: global function
| Param | Type | Description |
|---|---|---|
| date | string | number | |
| [format] | string | 日期格式 |
useDateFormat(date, format) ⇒ string
格式化日期
Kind: global function
| Param | Type |
|---|---|
| date | dayjs.Dayjs | Date |
| format | string |
useDateUnix(date) ⇒ number | string
获取日期的 Unix 时间戳
Kind: global function
| Param | Type |
|---|---|
| date | dayjs.Dayjs | Date |
useTimestampFormat(timestamp, [format]) ⇒ string
根据时间戳格式化日期
Kind: global function
| Param | Description |
|---|---|
| timestamp | 时间戳 |
| [format] | 日期格式 |
useHiddenForm(options) ⇒ HTMLFormElement
创建一个隐藏的表单
Kind: global function
| Param | Type |
|---|---|
| options | Object |
| options.url | string |
| options.data | Object |
| [options.method] | string |
| options.csrfToken | string |
useProcessStatus(res, ops)
处理请求结果
Kind: global function
| Param | Type | Description |
|---|---|---|
| res | object | 请求结果 |
| res.status | string | 请求结果状态 |
| res.result | * | 请求结果信息 |
| ops | Object.<string, (string|function())> | 状态的处理对象 |
useProcessStatusSuccess(res, success)
处理正确请求结果
Kind: global function
| Param | Type | Description |
|---|---|---|
| res | object | 请求结果 |
| res.status | string | 请求结果状态 |
| res.result | * | 请求结果信息 |
| success | string | function | 状态的处理对象 |
useFormFail(e)
处理表单提交失败
Kind: global function
| Param | Type |
|---|---|
| e | * |
useFormFormat(form, [format]) ⇒ Object
处理表单数据
Kind: global function
| Param | Type | Description |
|---|---|---|
| form | Object | |
| [format] | Object | 需要处理的类型 |
| [format.date] | boolean | string | function | true: 转成时间戳,string: 为 Format 格式, 如 "YYYY-MM-DD", function: 自定义处理函数, 参数为 dayjs 对象 |
| [format.boolean] | boolean | 布尔值处理, 如果开启则 true 转成 1, false 转成 0 |
| [format.attachment] | string | function | string: 附件字段名, function: 自定义处理函数, 参数为附件对象 |
useFetch([fetcher]) ⇒ Object
通用 AJAX 请求
Kind: global function
| Param | Type | Description |
|---|---|---|
| [fetcher] | Object | 用于存储请求状态的对象 |
get(url, [config]) ⇒ Promise.<unknown>
get请求
Kind: global function
| Param | Type | Description |
|---|---|---|
| url | ||
| [config] | Object | axios config |
post(url, data, [config]) ⇒ Promise.<unknown>
post请求
Kind: global function
| Param | Type | Description |
|---|---|---|
| url | string | |
| data | Object | |
| [config] | Object | axios config |
useTextFromOptionsValue(value, options) ⇒ * | string | string
从 options 中根据 value 获取 text
Kind: global function
| Param |
|---|
| value |
| options |
useFindTextsInValues(options, values, [adapter]) ⇒
从嵌套的 options 中根据 value 获取 text, 如 [1, 3] => ["东", "南"]
Kind: global function
Returns: Array
| Param | Type | Default | Description |
|---|---|---|---|
| options | Array | 嵌套的选项 | |
| values | Array | 需要查找的值 | |
| [adapter] | Object | {value: "value",label: "label",children: "children"} | 选项适配器 |
useFindLabelsFromPath(options, path, [adapter]) ⇒
从嵌套的 options 中根据 value 获取 label
Kind: global function
Returns: Array
| Param | Type |
|---|---|
| options | Array |
| path | Array |
| [adapter] | Object |
useFindTextsFromPath(options, path, [adapter]) ⇒
[移动端适配] 从嵌套的 options 中根据 value 获取 text
Kind: global function
Returns: Array
| Param | Type |
|---|---|
| options | Array |
| path | Array |
| [adapter] | Object |
useFindParentValues(options, value, adapter) ⇒
从嵌套的 options 中根据 value 获取整个 values 路径, 如地区路径: 440113 => [440000, 440100, 440113]
Kind: global function
Returns: Array
| Param |
|---|
| options |
| value |
| adapter |