2.0.6 • Published 10 months ago
kongj v2.0.6
CORE
修复说明
- 修复 UploadRequestFactory实例导出丢失this问题
- 20241120 处理文件上传请求时请求头令牌设置问题
说明:
用于辅助前端开发的工具包
- 【RequestFactory】基于Axios封装的标准化前端请求模块
- 【UploadRequestFactory】提供Element-Plus组件upload分片上传或者WangEditor编辑器文件分片上传的标准化请求处理器,也可用于其他受支持的上传模块
- 【ProgressComputing】用于提供符合实际情况的进度值计算的工具,比如它可以借助Vue组件的onMounte 和 onUnmounted钩子函数实现页面需要多组件耗时加载的统一进度展示功能。
- 【utils】基本工具库,后期还将扩充
getFileMd5
获取文件的MD5
precision
精度控制
debounce
防抖
throttle
节流
使用
安装
yarn add kongj@latest
OR
npm install kongj@latest
定义配置文件 axiosConfig.ts
const config:AxiosConfig = {
baseUrl: baseURL,
timeout: 3000,
bigUploadApi: '',
normalUploadAPi: '',
refreshTokenApi:'',
headerHook: (headers) => {
console.debug("尚未实现kconfig.api.headerHook",headers)
},
signOut: () => {
store.dispatch('user/loginOut')
},
token: () => {
return store.state.user.token
},
refreshToken: () => {
return store.state.user.refreshToken
},
saveToken: (token) => {
store.commit('user/tokenChange',token)
},
uploadNotify: (e: { uid: string | number; message: string} ) => {
mitter.emit('uploadNotify',e as any)
},
messageBox: (type,message) => {
ElMessage({
message: message || '服务异常',
type: 'error',
duration: 3 * 1000
})
},
chunkSize: 1024 * 1024 * 1,
merge: function (options: Optional<AxiosConfig>): void {
}
}
export default config
定义用于api请求的文件 request.ts
import {baseUrl} from '@/config'
import {RequestFactory} from 'kongj'
import axiosConfig from '@/config/axiosConfig'
import { AxiosRequestConfig } from 'axios'
let baseURL: any = import.meta.env.VITE_BASE_URL
baseURL = baseURL=='/pro-api'?baseUrl:baseURL
const facory = new RequestFactory(axiosConfig)
export const getAxiosResponse= ()=>facory.getAxiosResponse
export const responseProcess= ()=>facory.responseProcess
const request=<T>(config: AxiosRequestConfig)=>{
return facory.request()<T>(config)
}
export default request
2.0.6
10 months ago
2.0.5
10 months ago
2.0.4
10 months ago
2.0.3
10 months ago
2.0.2
10 months ago
2.0.1
10 months ago
2.0.0
10 months ago
1.0.12
10 months ago
1.0.11
10 months ago
1.0.10
10 months ago
1.0.9
10 months ago
1.0.8
10 months ago
1.0.7
10 months ago
1.0.6
10 months ago
1.0.5
10 months ago
1.0.4
10 months ago
1.0.2
10 months ago
1.0.1
10 months ago
1.0.0
10 months ago