alan-framework
v1.0.0
Published
基于vue/cli的前端应用框架
Maintainers
Readme
manniu核心库
基于vue/cli的蛮牛前端框架
工具函数
setVo
设置双向绑定值,只会设置vo有的属性
Kind: global constant
| Param | Description | | --- | --- | | vo | 目标 | | data | 源 |
validateIdCard ⇒
身份证号码验证
Kind: global constant
Returns: Boolean
| Param | Type | Description | | --- | --- | --- | | code | Number | String | 身份证号码 |
forceDecimal
强制小数位 例4.5 => 4.50; 1 => 1.00; 1.123 => 1.12
Kind: global constant
| Param | Type | Description | | --- | --- | --- | | num | Number | String | 源数字 | | count | Number | 小数位数 | | fill | Boolean | 是否填充 |
resetVo
重置VO
Kind: global constant
| Param | | --- | | vo |
colorGradient ⇒ Array.<number>
线性颜色渐变
Kind: global constant
| Param | Description | | --- | --- | | min | 最小参考值 | | max | 最大参考值 | | startRgb | 开始颜色 | | endRgb | 结束颜色 | | num | 当前参考值 |
minuteToHours ⇒ string
分钟数转小时,125分钟 => 2
Kind: global constant
| Param | Description | | --- | --- | | minute | 分钟数 |
minuteToMinute ⇒ string
分钟数转分钟,125分钟 => 5
Kind: global constant
| Param | | --- | | minute |
getOffsetTop ⇒ *
获取元素距离顶部的距离
Kind: global constant
| Param | Description | | --- | --- | | e | 元素 |
isPhone ⇒ boolean
判断是否为手机
Kind: global constant
base64toBlob ⇒ Blob
base64转Blob
Kind: global constant
| Param | | --- | | base64 |
getObjectURL ⇒ string | null
blob转URL
Kind: global constant
| Param | | --- | | file |
base64ToUrl ⇒ string | null
base64转URL
Kind: global constant
| Param | | --- | | base64 |
downloadOfUrl
下载文件
Kind: global constant
| Param | | --- | | url | | name |
getFileSizeFormat ⇒ Object | Object | Object | Object
获取文件大小格式
Kind: global constant
| Param | | --- | | size |
getFileSizeText ⇒ string
获取文件大小描述,1200KB,1M,0.1GB,0.01TB
Kind: global constant
| Param | | --- | | size |
$super ⇒ *
代理调用父级函数 this.$super(A).some()
Kind: global constant
| Param | Description | | --- | --- | | target | 父级对象 |
makeTree
把数组转换为树形结构
Kind: global constant
| Param | Type | Description | | --- | --- | --- | | array | Array | 源数据 | | pid | String | Number | 根ID 默认:0 | | parentProp | String | 父级属性名称 默认:pid | | idProp | String | ID属性名称 默认:id | | childProp | String | 下级属性名称 默认:children | | renderer | function | 渲染函数 |
parseDateRange ⇒ Object
转换日期范围 [date1, date2] => {[start]: '2020-01-01 00:00:00', [end]: '2020-01-01 23:59:59'}
Kind: global constant
| Param | Description | | --- | --- | | dateRange | 日期范围值 | | start | 开始key | | end | 结束key | | format | 格式化 |
parseMonthRange ⇒ Object
转换月份范围 [date1, date2] => {[start]: '2020-01-01 00:00:00', [end]: '2020-01-31 23:59:59'}
Kind: global constant
| Param | Description | | --- | --- | | dateRange | 日期范围值 | | start | 开始key | | end | 结束key | | format | 格式化 |
getBirthdayDateFromIdCard ⇒ number
根据身份证号获取出生日期
Kind: global constant
Returns: number - 时间戳
| Param | Description | | --- | --- | | idCard | 身份证号 |
animateScrollToTop
动画滑动滚动条
Kind: global constant
| Param | Description | | --- | --- | | element | 元素 | | speed | 速度 |
Http
axios请求封装类
Kind: global class
- Http
- new Http(options)
- .setDefaults(defaults) ⇒ Http
- .setOptions(options) ⇒ Http
- .addBeforeHook(fn, index) ⇒ Http
- .addAfterHook(fn, index) ⇒ Http
- .request(url, req, options) ⇒ AxiosPromise
- .get(url, params, options) ⇒ AxiosPromise
- .post(url, data, options) ⇒ AxiosPromise
new Http(options)
构造函数
| Param | Description | | --- | --- | | options | 配置参数 | | options.loading | 请求加载函数 (config, msg) | | options.error | 请求失败函数 (response) | | options.clear | 清除加载或者请求失败的函数 (config) | | options.mockUserHeader | 模拟用户信息头属性名,默认为 userInfo | | options.gateway | 访问线上接口服务网关名,默认为 /app-gateway | | options.encrypt | 是否加密,在请求中也可单独配置 |
http.setDefaults(defaults) ⇒ Http
设置默认值
Kind: instance method of Http
| Param | | --- | | defaults |
http.setOptions(options) ⇒ Http
配置参数
Kind: instance method of Http
| Param | | --- | | options |
http.addBeforeHook(fn, index) ⇒ Http
新增前置钩子 (config)
Kind: instance method of Http
| Param | Default | | --- | --- | | fn | | | index | false |
http.addAfterHook(fn, index) ⇒ Http
新增后置钩子(response)
Kind: instance method of Http
| Param | Default | | --- | --- | | fn | | | index | false |
http.request(url, req, options) ⇒ AxiosPromise
发起请求
Kind: instance method of Http
| Param | Description | | --- | --- | | url | 请求地址 | | req | 请求参数 | | options | 请求配置 |
http.get(url, params, options) ⇒ AxiosPromise
发起GET请求
Kind: instance method of Http
| Param | Description | | --- | --- | | url | 请求地址 | | params | 请求参数 | | options | 请求配置 |
http.post(url, data, options) ⇒ AxiosPromise
发起POST请求
Kind: instance method of Http
| Param | Description | | --- | --- | | url | 请求地址 | | data | 请求参数 | | options | 请求配置 |
httpClient ⇒ Http
实例化后的Http
Kind: global constant
| Param | Description | | --- | --- | | options | 配置参数 | | options.loading | 请求加载函数 (config, msg) | | options.error | 请求失败函数 (response) | | options.clear | 清除加载或者请求失败的函数 (config) | | options.mockUserHeader | 模拟用户信息头属性名,默认为 userInfo | | options.gateway | 访问线上接口服务网关名,默认为 /app-gateway | | options.encrypt | 是否加密,在请求中也可单独配置 |
httpClientInstall
Vue 插件使用,挂载$http、$get、$post到vue实例
Kind: global constant
| Param | | --- | | Vue | | options |
AbstractRouterFilter
抽象路由过滤器
Kind: global class
- AbstractRouterFilter
- new AbstractRouterFilter(router, option)
- .order() ⇒ number
- .enable() ⇒ boolean
- .matches(to, from) ⇒ boolean
- .onBefore(to, from) ⇒ Promise.<boolean>
- .onAfter(to, from)
new AbstractRouterFilter(router, option)
构造函数
| Param | Description | | --- | --- | | router | 路由实例 | | option | 自定义参数 |
abstractRouterFilter.order() ⇒ number
排序,越小越靠前
Kind: instance method of AbstractRouterFilter
abstractRouterFilter.enable() ⇒ boolean
是否启用该过滤器
Kind: instance method of AbstractRouterFilter
abstractRouterFilter.matches(to, from) ⇒ boolean
判断当前访问是否匹配当前过滤器
Kind: instance method of AbstractRouterFilter
| Param | Description | | --- | --- | | to | 要去的路由 | | from | 从哪来的路由 |
abstractRouterFilter.onBefore(to, from) ⇒ Promise.<boolean>
前置过滤器,返回false则阻止访问,返回string则替换to的path,返回object则替换to,注意返回的object不能直接返回入参的to
Kind: instance method of AbstractRouterFilter
| Param | Description | | --- | --- | | to | 要去的路由 | | from | 从哪来的路由 |
abstractRouterFilter.onAfter(to, from)
后置过滤器
Kind: instance method of AbstractRouterFilter
| Param | Description | | --- | --- | | to | 要去的路由 | | from | 从哪来的路由 |
BudpParamsFilter ⇐ AbstractRouterFilter
中台参数解析路由过滤器
Kind: global class
Extends: AbstractRouterFilter
- BudpParamsFilter ⇐ AbstractRouterFilter
- .defaultQueryKey : string
- .budpParamKey : string
- .decode(str) ⇒ *
budpParamsFilter.defaultQueryKey : string
默认把中台参数转换为query的参数名
Kind: instance property of BudpParamsFilter
budpParamsFilter.budpParamKey : string
中台参数名称
Kind: instance property of BudpParamsFilter
budpParamsFilter.decode(str) ⇒ *
对中台参数转码
Kind: instance method of BudpParamsFilter
| Param | Description | | --- | --- | | str | 中台参数 |
SkeletonFilter ⇐ AbstractRouterFilter
骨架屏过滤器
Kind: global class
Extends: AbstractRouterFilter
ToRootFilter ⇐ AbstractRouterFilter
转到顶层页面(清除路由堆栈)
Kind: global class
Extends: AbstractRouterFilter
