You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

401 lines
12 KiB

2 years ago
import type {
AxiosError,
AxiosInstance,
AxiosRequestConfig,
AxiosResponse,
InternalAxiosRequestConfig,
} from 'axios'
2 years ago
import axios from 'axios'
import qs from 'qs'
import { cloneDeep } from 'lodash-es'
import type { CreateAxiosOptions } from './axiosTransform'
2 years ago
import { AxiosCanceler } from './axiosCancel'
import { isFunction } from '@/utils/is'
import type { RequestOptions, Result, UploadFileParams } from '@/types/axios'
import { ContentTypeEnum, RequestEnum } from '@/enums/httpEnum'
2 years ago
import { downloadByData } from '@/utils/file/download'
import { useGlobSetting } from '@/hooks/setting'
feat: 系统管理 commit c6577279b8b1c94c9737d32a9ca1ba3437c5979b Author: K <1175047471@qq.com> Date: Fri Apr 12 09:40:22 2024 +0800 chore: 取消 token 刷新 commit 349b8176f28e294fbde7dd8a4c50f064785fdf9d Author: K <1175047471@qq.com> Date: Thu Apr 11 21:20:39 2024 +0800 chore: cleanup commit 309887ade9b8a8bb4efd35f09983ddcd3afb76df Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:15:02 2024 +0800 fix: 岗位查看 commit 0f4f83dd51c2ed454fc1ee3561f315bc7e35dc6a Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:13:47 2024 +0800 feat: 租户管理 commit 04e5d8d685616a601fd1d3b82ab18c4442536de8 Author: K <1175047471@qq.com> Date: Thu Apr 11 21:09:50 2024 +0800 chore: fix useinfo 未更新 commit 75ed18056c878c445ede439f27a1df2af41498dd Author: K <1175047471@qq.com> Date: Thu Apr 11 20:58:47 2024 +0800 chore: 修改首页地址 commit ef93ffc03d6f06f21b996f873b2b36e625c58a89 Author: K <1175047471@qq.com> Date: Thu Apr 11 20:52:27 2024 +0800 feat: 个人中心 commit 476a436f8654b8cd72fefd2105df2ecca7d517f7 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:53:41 2024 +0800 wip: 个人中心 commit e5704dc3ad9dea20af45457dedc72ba65eb9d732 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:36:55 2024 +0800 feat: 用户管理 commit e22200135c29ddbb17cbaae2d857c46478a9d9f7 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:42:25 2024 +0800 fix: 部门删除接口将ids改为id commit bbf42e206fad8a91a23edbbd68a3e2ce2d5ed59f Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:40:20 2024 +0800 feat: 角色管理; commit c7e7e89bfe9100641811823846d1a0f48cd5f584 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 14:11:35 2024 +0800 feat: 岗位管理 commit 355d77d3cfc286664bd78bffbaca2766597e11c1 Author: K <1175047471@qq.com> Date: Thu Apr 11 11:12:33 2024 +0800 chore: 调整行政区划操作按钮位置 commit 9f7927b94625f7b1ffe74a3b396849631cea5bea Author: K <1175047471@qq.com> Date: Thu Apr 11 10:45:24 2024 +0800 wip: 用户管理 commit 87b423b14f5bf795b4f99d120feac6a06f3ac332 Author: K <1175047471@qq.com> Date: Thu Apr 11 09:16:25 2024 +0800 feat: 菜单管理 - 新增子项 commit f2fa565d939802896539e1e07cdf1bd3bfa1bb0e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:12:04 2024 +0800 chore: 菜单路由处理动态参数 commit 3a2c15b69ecd8243f6ca9237b1ff19dbb6d374fe Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:08:23 2024 +0800 Revert "chore: 菜单路由处理动态参数" This reverts commit 3018cb399cd58e8e80285b83fc53ff9bdbd10e14. commit 9724ddc926c5efedc8f72ced29d31d61995b12a5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:05:52 2024 +0800 chore: 菜单路由处理动态参数 commit 5bca711522df26d884669edd50eb53ce35c7ebd5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:40:12 2024 +0800 fix: 删掉测试路由 commit 753306a1e4b7fdf17ac6337ca029a6f411baec1c Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:11:03 2024 +0800 feat: 业务字典 commit 0f551cf23dc20f2750b823ff49864cfa1c55910e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:29:17 2024 +0800 fix: 系统字典-字典配置修改 commit 040923dd0eb3eb3846ddcf17efee9aa9fb2ca2da Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:23:51 2024 +0800 feat: 系统字典 commit 1dfe6a3b221863fa792b8fc7432707c5fe009da2 Author: K <1175047471@qq.com> Date: Wed Apr 10 21:06:30 2024 +0800 fix: 菜单类型显示错误 commit c16cbdf807d7b8d44e2b0ff1b1310109c24c2d5d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:57:36 2024 +0800 fix: 菜单无法跳转 commit f95c62d7faac99aa0700f14d46291fa34eafa0e2 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:26:34 2024 +0800 feat: ImportModal 增加提示 commit 1e0af86b01d54e5ee8b89a5b48c8f2fb5276386f Author: K <1175047471@qq.com> Date: Wed Apr 10 20:21:37 2024 +0800 fix: 批量删除错误 commit 47a807a76e6cb006fb12ef8bf8e6a065f9e293b8 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:19:00 2024 +0800 fix: 批量删除错误 commit 82248511dcb058a6885e64472a47df10bd43218d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:07:28 2024 +0800 chore: cleanup commit fae351c1d131151738e42f82fbd0e98dd21f79bd Author: K <1175047471@qq.com> Date: Wed Apr 10 20:06:58 2024 +0800 feat: 行政区划 commit 9d370465faff6adac276f96e099a42ea015c4e4a Author: K <1175047471@qq.com> Date: Wed Apr 10 11:18:16 2024 +0800 fix: 菜单 icon 不应该是必选项 commit 68734b32e416ff6db4fe0e2748148e6867cd236a Author: K <1175047471@qq.com> Date: Wed Apr 10 10:59:32 2024 +0800 feat: 参数管理 - 批量删除 commit ff3a985a70f97db5ff169b64b2bfe997ce60360d Author: K <1175047471@qq.com> Date: Wed Apr 10 10:51:09 2024 +0800 feat: 参数管理 commit 6b1ec43e7a598a0140452eaae47223302cb6b345 Author: K <1175047471@qq.com> Date: Wed Apr 10 10:24:59 2024 +0800 wip: 菜单管理 commit 19ad299806d14f780ab52fc6d890224b63796750 Author: K <1175047471@qq.com> Date: Tue Apr 9 18:31:16 2024 +0800 wip: 系统管理 commit 8a02a8a64b90206a109d14ebdfc082b0ba1fcbdc Author: K <1175047471@qq.com> Date: Tue Apr 9 18:03:13 2024 +0800 wip: 系统管理
1 year ago
import { getRefreshToken, getTenantId } from '@/utils/auth'
import { useUserStoreWithOut } from '@/store/modules/user'
2 years ago
export * from './axiosTransform'
2 years ago
2 years ago
const globSetting = useGlobSetting()
// 请求队列
feat: 系统管理 commit c6577279b8b1c94c9737d32a9ca1ba3437c5979b Author: K <1175047471@qq.com> Date: Fri Apr 12 09:40:22 2024 +0800 chore: 取消 token 刷新 commit 349b8176f28e294fbde7dd8a4c50f064785fdf9d Author: K <1175047471@qq.com> Date: Thu Apr 11 21:20:39 2024 +0800 chore: cleanup commit 309887ade9b8a8bb4efd35f09983ddcd3afb76df Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:15:02 2024 +0800 fix: 岗位查看 commit 0f4f83dd51c2ed454fc1ee3561f315bc7e35dc6a Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:13:47 2024 +0800 feat: 租户管理 commit 04e5d8d685616a601fd1d3b82ab18c4442536de8 Author: K <1175047471@qq.com> Date: Thu Apr 11 21:09:50 2024 +0800 chore: fix useinfo 未更新 commit 75ed18056c878c445ede439f27a1df2af41498dd Author: K <1175047471@qq.com> Date: Thu Apr 11 20:58:47 2024 +0800 chore: 修改首页地址 commit ef93ffc03d6f06f21b996f873b2b36e625c58a89 Author: K <1175047471@qq.com> Date: Thu Apr 11 20:52:27 2024 +0800 feat: 个人中心 commit 476a436f8654b8cd72fefd2105df2ecca7d517f7 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:53:41 2024 +0800 wip: 个人中心 commit e5704dc3ad9dea20af45457dedc72ba65eb9d732 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:36:55 2024 +0800 feat: 用户管理 commit e22200135c29ddbb17cbaae2d857c46478a9d9f7 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:42:25 2024 +0800 fix: 部门删除接口将ids改为id commit bbf42e206fad8a91a23edbbd68a3e2ce2d5ed59f Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:40:20 2024 +0800 feat: 角色管理; commit c7e7e89bfe9100641811823846d1a0f48cd5f584 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 14:11:35 2024 +0800 feat: 岗位管理 commit 355d77d3cfc286664bd78bffbaca2766597e11c1 Author: K <1175047471@qq.com> Date: Thu Apr 11 11:12:33 2024 +0800 chore: 调整行政区划操作按钮位置 commit 9f7927b94625f7b1ffe74a3b396849631cea5bea Author: K <1175047471@qq.com> Date: Thu Apr 11 10:45:24 2024 +0800 wip: 用户管理 commit 87b423b14f5bf795b4f99d120feac6a06f3ac332 Author: K <1175047471@qq.com> Date: Thu Apr 11 09:16:25 2024 +0800 feat: 菜单管理 - 新增子项 commit f2fa565d939802896539e1e07cdf1bd3bfa1bb0e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:12:04 2024 +0800 chore: 菜单路由处理动态参数 commit 3a2c15b69ecd8243f6ca9237b1ff19dbb6d374fe Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:08:23 2024 +0800 Revert "chore: 菜单路由处理动态参数" This reverts commit 3018cb399cd58e8e80285b83fc53ff9bdbd10e14. commit 9724ddc926c5efedc8f72ced29d31d61995b12a5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:05:52 2024 +0800 chore: 菜单路由处理动态参数 commit 5bca711522df26d884669edd50eb53ce35c7ebd5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:40:12 2024 +0800 fix: 删掉测试路由 commit 753306a1e4b7fdf17ac6337ca029a6f411baec1c Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:11:03 2024 +0800 feat: 业务字典 commit 0f551cf23dc20f2750b823ff49864cfa1c55910e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:29:17 2024 +0800 fix: 系统字典-字典配置修改 commit 040923dd0eb3eb3846ddcf17efee9aa9fb2ca2da Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:23:51 2024 +0800 feat: 系统字典 commit 1dfe6a3b221863fa792b8fc7432707c5fe009da2 Author: K <1175047471@qq.com> Date: Wed Apr 10 21:06:30 2024 +0800 fix: 菜单类型显示错误 commit c16cbdf807d7b8d44e2b0ff1b1310109c24c2d5d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:57:36 2024 +0800 fix: 菜单无法跳转 commit f95c62d7faac99aa0700f14d46291fa34eafa0e2 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:26:34 2024 +0800 feat: ImportModal 增加提示 commit 1e0af86b01d54e5ee8b89a5b48c8f2fb5276386f Author: K <1175047471@qq.com> Date: Wed Apr 10 20:21:37 2024 +0800 fix: 批量删除错误 commit 47a807a76e6cb006fb12ef8bf8e6a065f9e293b8 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:19:00 2024 +0800 fix: 批量删除错误 commit 82248511dcb058a6885e64472a47df10bd43218d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:07:28 2024 +0800 chore: cleanup commit fae351c1d131151738e42f82fbd0e98dd21f79bd Author: K <1175047471@qq.com> Date: Wed Apr 10 20:06:58 2024 +0800 feat: 行政区划 commit 9d370465faff6adac276f96e099a42ea015c4e4a Author: K <1175047471@qq.com> Date: Wed Apr 10 11:18:16 2024 +0800 fix: 菜单 icon 不应该是必选项 commit 68734b32e416ff6db4fe0e2748148e6867cd236a Author: K <1175047471@qq.com> Date: Wed Apr 10 10:59:32 2024 +0800 feat: 参数管理 - 批量删除 commit ff3a985a70f97db5ff169b64b2bfe997ce60360d Author: K <1175047471@qq.com> Date: Wed Apr 10 10:51:09 2024 +0800 feat: 参数管理 commit 6b1ec43e7a598a0140452eaae47223302cb6b345 Author: K <1175047471@qq.com> Date: Wed Apr 10 10:24:59 2024 +0800 wip: 菜单管理 commit 19ad299806d14f780ab52fc6d890224b63796750 Author: K <1175047471@qq.com> Date: Tue Apr 9 18:31:16 2024 +0800 wip: 系统管理 commit 8a02a8a64b90206a109d14ebdfc082b0ba1fcbdc Author: K <1175047471@qq.com> Date: Tue Apr 9 18:03:13 2024 +0800 wip: 系统管理
1 year ago
// const requestList: any[] = []
2 years ago
// 是否正在刷新中
feat: 系统管理 commit c6577279b8b1c94c9737d32a9ca1ba3437c5979b Author: K <1175047471@qq.com> Date: Fri Apr 12 09:40:22 2024 +0800 chore: 取消 token 刷新 commit 349b8176f28e294fbde7dd8a4c50f064785fdf9d Author: K <1175047471@qq.com> Date: Thu Apr 11 21:20:39 2024 +0800 chore: cleanup commit 309887ade9b8a8bb4efd35f09983ddcd3afb76df Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:15:02 2024 +0800 fix: 岗位查看 commit 0f4f83dd51c2ed454fc1ee3561f315bc7e35dc6a Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:13:47 2024 +0800 feat: 租户管理 commit 04e5d8d685616a601fd1d3b82ab18c4442536de8 Author: K <1175047471@qq.com> Date: Thu Apr 11 21:09:50 2024 +0800 chore: fix useinfo 未更新 commit 75ed18056c878c445ede439f27a1df2af41498dd Author: K <1175047471@qq.com> Date: Thu Apr 11 20:58:47 2024 +0800 chore: 修改首页地址 commit ef93ffc03d6f06f21b996f873b2b36e625c58a89 Author: K <1175047471@qq.com> Date: Thu Apr 11 20:52:27 2024 +0800 feat: 个人中心 commit 476a436f8654b8cd72fefd2105df2ecca7d517f7 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:53:41 2024 +0800 wip: 个人中心 commit e5704dc3ad9dea20af45457dedc72ba65eb9d732 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:36:55 2024 +0800 feat: 用户管理 commit e22200135c29ddbb17cbaae2d857c46478a9d9f7 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:42:25 2024 +0800 fix: 部门删除接口将ids改为id commit bbf42e206fad8a91a23edbbd68a3e2ce2d5ed59f Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:40:20 2024 +0800 feat: 角色管理; commit c7e7e89bfe9100641811823846d1a0f48cd5f584 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 14:11:35 2024 +0800 feat: 岗位管理 commit 355d77d3cfc286664bd78bffbaca2766597e11c1 Author: K <1175047471@qq.com> Date: Thu Apr 11 11:12:33 2024 +0800 chore: 调整行政区划操作按钮位置 commit 9f7927b94625f7b1ffe74a3b396849631cea5bea Author: K <1175047471@qq.com> Date: Thu Apr 11 10:45:24 2024 +0800 wip: 用户管理 commit 87b423b14f5bf795b4f99d120feac6a06f3ac332 Author: K <1175047471@qq.com> Date: Thu Apr 11 09:16:25 2024 +0800 feat: 菜单管理 - 新增子项 commit f2fa565d939802896539e1e07cdf1bd3bfa1bb0e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:12:04 2024 +0800 chore: 菜单路由处理动态参数 commit 3a2c15b69ecd8243f6ca9237b1ff19dbb6d374fe Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:08:23 2024 +0800 Revert "chore: 菜单路由处理动态参数" This reverts commit 3018cb399cd58e8e80285b83fc53ff9bdbd10e14. commit 9724ddc926c5efedc8f72ced29d31d61995b12a5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:05:52 2024 +0800 chore: 菜单路由处理动态参数 commit 5bca711522df26d884669edd50eb53ce35c7ebd5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:40:12 2024 +0800 fix: 删掉测试路由 commit 753306a1e4b7fdf17ac6337ca029a6f411baec1c Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:11:03 2024 +0800 feat: 业务字典 commit 0f551cf23dc20f2750b823ff49864cfa1c55910e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:29:17 2024 +0800 fix: 系统字典-字典配置修改 commit 040923dd0eb3eb3846ddcf17efee9aa9fb2ca2da Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:23:51 2024 +0800 feat: 系统字典 commit 1dfe6a3b221863fa792b8fc7432707c5fe009da2 Author: K <1175047471@qq.com> Date: Wed Apr 10 21:06:30 2024 +0800 fix: 菜单类型显示错误 commit c16cbdf807d7b8d44e2b0ff1b1310109c24c2d5d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:57:36 2024 +0800 fix: 菜单无法跳转 commit f95c62d7faac99aa0700f14d46291fa34eafa0e2 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:26:34 2024 +0800 feat: ImportModal 增加提示 commit 1e0af86b01d54e5ee8b89a5b48c8f2fb5276386f Author: K <1175047471@qq.com> Date: Wed Apr 10 20:21:37 2024 +0800 fix: 批量删除错误 commit 47a807a76e6cb006fb12ef8bf8e6a065f9e293b8 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:19:00 2024 +0800 fix: 批量删除错误 commit 82248511dcb058a6885e64472a47df10bd43218d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:07:28 2024 +0800 chore: cleanup commit fae351c1d131151738e42f82fbd0e98dd21f79bd Author: K <1175047471@qq.com> Date: Wed Apr 10 20:06:58 2024 +0800 feat: 行政区划 commit 9d370465faff6adac276f96e099a42ea015c4e4a Author: K <1175047471@qq.com> Date: Wed Apr 10 11:18:16 2024 +0800 fix: 菜单 icon 不应该是必选项 commit 68734b32e416ff6db4fe0e2748148e6867cd236a Author: K <1175047471@qq.com> Date: Wed Apr 10 10:59:32 2024 +0800 feat: 参数管理 - 批量删除 commit ff3a985a70f97db5ff169b64b2bfe997ce60360d Author: K <1175047471@qq.com> Date: Wed Apr 10 10:51:09 2024 +0800 feat: 参数管理 commit 6b1ec43e7a598a0140452eaae47223302cb6b345 Author: K <1175047471@qq.com> Date: Wed Apr 10 10:24:59 2024 +0800 wip: 菜单管理 commit 19ad299806d14f780ab52fc6d890224b63796750 Author: K <1175047471@qq.com> Date: Tue Apr 9 18:31:16 2024 +0800 wip: 系统管理 commit 8a02a8a64b90206a109d14ebdfc082b0ba1fcbdc Author: K <1175047471@qq.com> Date: Tue Apr 9 18:03:13 2024 +0800 wip: 系统管理
1 year ago
// const isRefreshToken = false
2 years ago
/**
2 years ago
* @description: axios
2 years ago
*/
export class VAxios {
private axiosInstance: AxiosInstance
private readonly options: CreateAxiosOptions
constructor(options: CreateAxiosOptions) {
this.options = options
this.axiosInstance = axios.create(options)
this.setupInterceptors()
}
/**
2 years ago
* @description: axios
2 years ago
*/
private createAxios(config: CreateAxiosOptions): void {
this.axiosInstance = axios.create(config)
}
private getTransform() {
const { transform } = this.options
return transform
}
getAxios(): AxiosInstance {
return this.axiosInstance
}
2 years ago
refreshToken() {
axios.defaults.headers.common['tenant-id'] = getTenantId()
2 years ago
const refreshToken = getRefreshToken()
2 years ago
return axios.post(`${globSetting.apiUrl}/system/auth/refresh-token?refreshToken=${refreshToken}`)
2 years ago
}
2 years ago
/**
2 years ago
* @description: axios
2 years ago
*/
configAxios(config: CreateAxiosOptions) {
if (!this.axiosInstance)
2 years ago
return
2 years ago
this.createAxios(config)
}
/**
2 years ago
* @description:
2 years ago
*/
setHeader(headers: any): void {
if (!this.axiosInstance)
2 years ago
return
2 years ago
Object.assign(this.axiosInstance.defaults.headers, headers)
}
/**
* @description: Interceptor configuration
*/
private setupInterceptors() {
2 years ago
// const transform = this.getTransform();
2 years ago
const {
axiosInstance,
options: { transform },
2 years ago
} = this
if (!transform)
2 years ago
return
2 years ago
const {
requestInterceptors,
requestInterceptorsCatch,
responseInterceptors,
responseInterceptorsCatch,
} = transform
2 years ago
const axiosCanceler = new AxiosCanceler()
2 years ago
// 请求拦截器配置处理
2 years ago
this.axiosInstance.interceptors.request.use((config: InternalAxiosRequestConfig) => {
2 years ago
// If cancel repeat request is turned on, then cancel repeat request is prohibited
const requestOptions
= (config as unknown as any).requestOptions ?? this.options.requestOptions
2 years ago
const ignoreCancelToken = requestOptions?.ignoreCancelToken ?? true
!ignoreCancelToken && axiosCanceler.addPending(config)
2 years ago
if (requestInterceptors && isFunction(requestInterceptors))
2 years ago
config = requestInterceptors(config, this.options)
2 years ago
return config
}, undefined)
2 years ago
// 请求拦截器错误捕获
requestInterceptorsCatch
&& isFunction(requestInterceptorsCatch)
&& this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch)
2 years ago
2 years ago
// 响应结果拦截器处理
this.axiosInstance.interceptors.response.use(async (res: AxiosResponse<any>) => {
if (res.data.code === 401) {
feat: 系统管理 commit c6577279b8b1c94c9737d32a9ca1ba3437c5979b Author: K <1175047471@qq.com> Date: Fri Apr 12 09:40:22 2024 +0800 chore: 取消 token 刷新 commit 349b8176f28e294fbde7dd8a4c50f064785fdf9d Author: K <1175047471@qq.com> Date: Thu Apr 11 21:20:39 2024 +0800 chore: cleanup commit 309887ade9b8a8bb4efd35f09983ddcd3afb76df Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:15:02 2024 +0800 fix: 岗位查看 commit 0f4f83dd51c2ed454fc1ee3561f315bc7e35dc6a Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:13:47 2024 +0800 feat: 租户管理 commit 04e5d8d685616a601fd1d3b82ab18c4442536de8 Author: K <1175047471@qq.com> Date: Thu Apr 11 21:09:50 2024 +0800 chore: fix useinfo 未更新 commit 75ed18056c878c445ede439f27a1df2af41498dd Author: K <1175047471@qq.com> Date: Thu Apr 11 20:58:47 2024 +0800 chore: 修改首页地址 commit ef93ffc03d6f06f21b996f873b2b36e625c58a89 Author: K <1175047471@qq.com> Date: Thu Apr 11 20:52:27 2024 +0800 feat: 个人中心 commit 476a436f8654b8cd72fefd2105df2ecca7d517f7 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:53:41 2024 +0800 wip: 个人中心 commit e5704dc3ad9dea20af45457dedc72ba65eb9d732 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:36:55 2024 +0800 feat: 用户管理 commit e22200135c29ddbb17cbaae2d857c46478a9d9f7 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:42:25 2024 +0800 fix: 部门删除接口将ids改为id commit bbf42e206fad8a91a23edbbd68a3e2ce2d5ed59f Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:40:20 2024 +0800 feat: 角色管理; commit c7e7e89bfe9100641811823846d1a0f48cd5f584 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 14:11:35 2024 +0800 feat: 岗位管理 commit 355d77d3cfc286664bd78bffbaca2766597e11c1 Author: K <1175047471@qq.com> Date: Thu Apr 11 11:12:33 2024 +0800 chore: 调整行政区划操作按钮位置 commit 9f7927b94625f7b1ffe74a3b396849631cea5bea Author: K <1175047471@qq.com> Date: Thu Apr 11 10:45:24 2024 +0800 wip: 用户管理 commit 87b423b14f5bf795b4f99d120feac6a06f3ac332 Author: K <1175047471@qq.com> Date: Thu Apr 11 09:16:25 2024 +0800 feat: 菜单管理 - 新增子项 commit f2fa565d939802896539e1e07cdf1bd3bfa1bb0e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:12:04 2024 +0800 chore: 菜单路由处理动态参数 commit 3a2c15b69ecd8243f6ca9237b1ff19dbb6d374fe Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:08:23 2024 +0800 Revert "chore: 菜单路由处理动态参数" This reverts commit 3018cb399cd58e8e80285b83fc53ff9bdbd10e14. commit 9724ddc926c5efedc8f72ced29d31d61995b12a5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:05:52 2024 +0800 chore: 菜单路由处理动态参数 commit 5bca711522df26d884669edd50eb53ce35c7ebd5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:40:12 2024 +0800 fix: 删掉测试路由 commit 753306a1e4b7fdf17ac6337ca029a6f411baec1c Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:11:03 2024 +0800 feat: 业务字典 commit 0f551cf23dc20f2750b823ff49864cfa1c55910e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:29:17 2024 +0800 fix: 系统字典-字典配置修改 commit 040923dd0eb3eb3846ddcf17efee9aa9fb2ca2da Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:23:51 2024 +0800 feat: 系统字典 commit 1dfe6a3b221863fa792b8fc7432707c5fe009da2 Author: K <1175047471@qq.com> Date: Wed Apr 10 21:06:30 2024 +0800 fix: 菜单类型显示错误 commit c16cbdf807d7b8d44e2b0ff1b1310109c24c2d5d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:57:36 2024 +0800 fix: 菜单无法跳转 commit f95c62d7faac99aa0700f14d46291fa34eafa0e2 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:26:34 2024 +0800 feat: ImportModal 增加提示 commit 1e0af86b01d54e5ee8b89a5b48c8f2fb5276386f Author: K <1175047471@qq.com> Date: Wed Apr 10 20:21:37 2024 +0800 fix: 批量删除错误 commit 47a807a76e6cb006fb12ef8bf8e6a065f9e293b8 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:19:00 2024 +0800 fix: 批量删除错误 commit 82248511dcb058a6885e64472a47df10bd43218d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:07:28 2024 +0800 chore: cleanup commit fae351c1d131151738e42f82fbd0e98dd21f79bd Author: K <1175047471@qq.com> Date: Wed Apr 10 20:06:58 2024 +0800 feat: 行政区划 commit 9d370465faff6adac276f96e099a42ea015c4e4a Author: K <1175047471@qq.com> Date: Wed Apr 10 11:18:16 2024 +0800 fix: 菜单 icon 不应该是必选项 commit 68734b32e416ff6db4fe0e2748148e6867cd236a Author: K <1175047471@qq.com> Date: Wed Apr 10 10:59:32 2024 +0800 feat: 参数管理 - 批量删除 commit ff3a985a70f97db5ff169b64b2bfe997ce60360d Author: K <1175047471@qq.com> Date: Wed Apr 10 10:51:09 2024 +0800 feat: 参数管理 commit 6b1ec43e7a598a0140452eaae47223302cb6b345 Author: K <1175047471@qq.com> Date: Wed Apr 10 10:24:59 2024 +0800 wip: 菜单管理 commit 19ad299806d14f780ab52fc6d890224b63796750 Author: K <1175047471@qq.com> Date: Tue Apr 9 18:31:16 2024 +0800 wip: 系统管理 commit 8a02a8a64b90206a109d14ebdfc082b0ba1fcbdc Author: K <1175047471@qq.com> Date: Tue Apr 9 18:03:13 2024 +0800 wip: 系统管理
1 year ago
useUserStoreWithOut().logout(true)
return res
2 years ago
}
feat: 系统管理 commit c6577279b8b1c94c9737d32a9ca1ba3437c5979b Author: K <1175047471@qq.com> Date: Fri Apr 12 09:40:22 2024 +0800 chore: 取消 token 刷新 commit 349b8176f28e294fbde7dd8a4c50f064785fdf9d Author: K <1175047471@qq.com> Date: Thu Apr 11 21:20:39 2024 +0800 chore: cleanup commit 309887ade9b8a8bb4efd35f09983ddcd3afb76df Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:15:02 2024 +0800 fix: 岗位查看 commit 0f4f83dd51c2ed454fc1ee3561f315bc7e35dc6a Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 21:13:47 2024 +0800 feat: 租户管理 commit 04e5d8d685616a601fd1d3b82ab18c4442536de8 Author: K <1175047471@qq.com> Date: Thu Apr 11 21:09:50 2024 +0800 chore: fix useinfo 未更新 commit 75ed18056c878c445ede439f27a1df2af41498dd Author: K <1175047471@qq.com> Date: Thu Apr 11 20:58:47 2024 +0800 chore: 修改首页地址 commit ef93ffc03d6f06f21b996f873b2b36e625c58a89 Author: K <1175047471@qq.com> Date: Thu Apr 11 20:52:27 2024 +0800 feat: 个人中心 commit 476a436f8654b8cd72fefd2105df2ecca7d517f7 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:53:41 2024 +0800 wip: 个人中心 commit e5704dc3ad9dea20af45457dedc72ba65eb9d732 Author: K <1175047471@qq.com> Date: Thu Apr 11 19:36:55 2024 +0800 feat: 用户管理 commit e22200135c29ddbb17cbaae2d857c46478a9d9f7 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:42:25 2024 +0800 fix: 部门删除接口将ids改为id commit bbf42e206fad8a91a23edbbd68a3e2ce2d5ed59f Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 17:40:20 2024 +0800 feat: 角色管理; commit c7e7e89bfe9100641811823846d1a0f48cd5f584 Author: lipenghui <mrkezhi@163.com> Date: Thu Apr 11 14:11:35 2024 +0800 feat: 岗位管理 commit 355d77d3cfc286664bd78bffbaca2766597e11c1 Author: K <1175047471@qq.com> Date: Thu Apr 11 11:12:33 2024 +0800 chore: 调整行政区划操作按钮位置 commit 9f7927b94625f7b1ffe74a3b396849631cea5bea Author: K <1175047471@qq.com> Date: Thu Apr 11 10:45:24 2024 +0800 wip: 用户管理 commit 87b423b14f5bf795b4f99d120feac6a06f3ac332 Author: K <1175047471@qq.com> Date: Thu Apr 11 09:16:25 2024 +0800 feat: 菜单管理 - 新增子项 commit f2fa565d939802896539e1e07cdf1bd3bfa1bb0e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:12:04 2024 +0800 chore: 菜单路由处理动态参数 commit 3a2c15b69ecd8243f6ca9237b1ff19dbb6d374fe Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:08:23 2024 +0800 Revert "chore: 菜单路由处理动态参数" This reverts commit 3018cb399cd58e8e80285b83fc53ff9bdbd10e14. commit 9724ddc926c5efedc8f72ced29d31d61995b12a5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 21:05:52 2024 +0800 chore: 菜单路由处理动态参数 commit 5bca711522df26d884669edd50eb53ce35c7ebd5 Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:40:12 2024 +0800 fix: 删掉测试路由 commit 753306a1e4b7fdf17ac6337ca029a6f411baec1c Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 20:11:03 2024 +0800 feat: 业务字典 commit 0f551cf23dc20f2750b823ff49864cfa1c55910e Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:29:17 2024 +0800 fix: 系统字典-字典配置修改 commit 040923dd0eb3eb3846ddcf17efee9aa9fb2ca2da Author: lipenghui <mrkezhi@163.com> Date: Wed Apr 10 18:23:51 2024 +0800 feat: 系统字典 commit 1dfe6a3b221863fa792b8fc7432707c5fe009da2 Author: K <1175047471@qq.com> Date: Wed Apr 10 21:06:30 2024 +0800 fix: 菜单类型显示错误 commit c16cbdf807d7b8d44e2b0ff1b1310109c24c2d5d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:57:36 2024 +0800 fix: 菜单无法跳转 commit f95c62d7faac99aa0700f14d46291fa34eafa0e2 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:26:34 2024 +0800 feat: ImportModal 增加提示 commit 1e0af86b01d54e5ee8b89a5b48c8f2fb5276386f Author: K <1175047471@qq.com> Date: Wed Apr 10 20:21:37 2024 +0800 fix: 批量删除错误 commit 47a807a76e6cb006fb12ef8bf8e6a065f9e293b8 Author: K <1175047471@qq.com> Date: Wed Apr 10 20:19:00 2024 +0800 fix: 批量删除错误 commit 82248511dcb058a6885e64472a47df10bd43218d Author: K <1175047471@qq.com> Date: Wed Apr 10 20:07:28 2024 +0800 chore: cleanup commit fae351c1d131151738e42f82fbd0e98dd21f79bd Author: K <1175047471@qq.com> Date: Wed Apr 10 20:06:58 2024 +0800 feat: 行政区划 commit 9d370465faff6adac276f96e099a42ea015c4e4a Author: K <1175047471@qq.com> Date: Wed Apr 10 11:18:16 2024 +0800 fix: 菜单 icon 不应该是必选项 commit 68734b32e416ff6db4fe0e2748148e6867cd236a Author: K <1175047471@qq.com> Date: Wed Apr 10 10:59:32 2024 +0800 feat: 参数管理 - 批量删除 commit ff3a985a70f97db5ff169b64b2bfe997ce60360d Author: K <1175047471@qq.com> Date: Wed Apr 10 10:51:09 2024 +0800 feat: 参数管理 commit 6b1ec43e7a598a0140452eaae47223302cb6b345 Author: K <1175047471@qq.com> Date: Wed Apr 10 10:24:59 2024 +0800 wip: 菜单管理 commit 19ad299806d14f780ab52fc6d890224b63796750 Author: K <1175047471@qq.com> Date: Tue Apr 9 18:31:16 2024 +0800 wip: 系统管理 commit 8a02a8a64b90206a109d14ebdfc082b0ba1fcbdc Author: K <1175047471@qq.com> Date: Tue Apr 9 18:03:13 2024 +0800 wip: 系统管理
1 year ago
// // 如果未认证,并且未进行刷新令牌,说明可能是访问令牌过期了
// if (!isRefreshToken) {
// isRefreshToken = true
// // 1. 获取到刷新token
// if (getRefreshToken()) {
// // 2. 进行刷新访问令牌
// try {
// const refreshTokenRes = await this.refreshToken()
// // 2.1 刷新成功,则回放队列的请求 + 当前请求
// const refreshToken = getRefreshToken()
// setAccessToken(refreshTokenRes.data.data.accessToken)
// ;(config as Recordable).headers.Authorization = `Bearer ${refreshToken}`
// requestList.forEach((cb: any) => {
// cb()
// })
// requestList = []
// return new Promise((resolve) => {
// resolve(this.axiosInstance(config))
// })
// // res = await Promise.all([this.axiosInstance(config)])[0]
// }
// catch (e) {
// requestList.forEach((cb: any) => {
// cb()
// })
// }
// finally {
// requestList = []
// isRefreshToken = false
// }
// }
// }
// else {
// // 添加到队列,等待刷新获取到新的令牌
// return new Promise((resolve) => {
// const refreshToken = getRefreshToken()
// requestList.push(() => {
// ;(config as Recordable).headers.Authorization = `Bearer ${refreshToken}` // 让每个请求携带自定义token 请根据实际情况自行修改
// resolve(this.axiosInstance(config))
// })
// })
// }
2 years ago
res && axiosCanceler.removePending(res.config)
if (responseInterceptors && isFunction(responseInterceptors))
2 years ago
res = responseInterceptors(res)
2 years ago
return res
}, undefined)
2 years ago
// 响应结果拦截器错误捕获
responseInterceptorsCatch
&& isFunction(responseInterceptorsCatch)
&& this.axiosInstance.interceptors.response.use(undefined, (error) => {
return responseInterceptorsCatch(axiosInstance, error)
})
2 years ago
}
/**
2 years ago
* @description:
2 years ago
*/
uploadFile<T = any>(config: AxiosRequestConfig, params: UploadFileParams) {
const formData = new window.FormData()
const customFilename = params.name || 'file'
if (params.filename)
2 years ago
formData.append(customFilename, params.file, params.filename)
2 years ago
else
2 years ago
formData.append(customFilename, params.file)
if (params.data) {
Object.keys(params.data).forEach((key) => {
const value = params.data![key]
if (Array.isArray(value)) {
value.forEach((item) => {
formData.append(`${key}[]`, item)
})
return
}
formData.append(key, params.data![key])
})
}
return this.axiosInstance.request<T>({
...config,
method: 'POST',
data: formData,
headers: {
'Content-type': ContentTypeEnum.FORM_DATA,
'ignoreCancelToken': true,
},
2 years ago
})
}
2 years ago
// 支持表单数据
2 years ago
supportFormData(config: AxiosRequestConfig) {
const headers = config.headers || this.options.headers
const contentType = headers?.['Content-Type'] || headers?.['content-type']
if (
contentType !== ContentTypeEnum.FORM_URLENCODED
|| !Reflect.has(config, 'data')
|| config.method?.toUpperCase() === RequestEnum.GET
11 months ago
) {
2 years ago
return config
11 months ago
}
2 years ago
return {
...config,
data: qs.stringify(config.data, { arrayFormat: 'brackets' }),
2 years ago
}
}
get<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
return this.request({ ...config, method: 'GET' }, options)
}
post<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
return this.request({ ...config, method: 'POST' }, options)
}
put<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
return this.request({ ...config, method: 'PUT' }, options)
}
delete<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
return this.request({ ...config, method: 'DELETE' }, options)
}
download<T = any>(config: AxiosRequestConfig, title?: string, options?: RequestOptions): Promise<T> {
2 years ago
let conf: CreateAxiosOptions = cloneDeep({
...config,
method: 'GET',
responseType: 'blob',
2 years ago
})
const transform = this.getTransform()
const { requestOptions } = this.options
const opt: RequestOptions = Object.assign({}, requestOptions, options)
const { beforeRequestHook, requestCatchHook } = transform || {}
if (beforeRequestHook && isFunction(beforeRequestHook))
2 years ago
conf = beforeRequestHook(conf, opt)
2 years ago
conf.requestOptions = opt
conf = this.supportFormData(conf)
return new Promise((resolve, reject) => {
this.axiosInstance
.request<any, AxiosResponse<Result>>(conf)
.then((res: AxiosResponse<Result>) => {
resolve(res as unknown as Promise<T>)
// download file
2 years ago
if (typeof res != 'undefined')
downloadByData(res?.data as unknown as BlobPart, title || 'export')
2 years ago
})
.catch((e: Error | AxiosError) => {
if (requestCatchHook && isFunction(requestCatchHook)) {
reject(requestCatchHook(e, opt))
return
}
if (axios.isAxiosError(e)) {
// rewrite error message from axios in here
}
reject(e)
})
})
}
export<T = any>(config: AxiosRequestConfig, title: string, options?: RequestOptions): Promise<T> {
let conf: CreateAxiosOptions = cloneDeep({
...config,
method: 'POST',
responseType: 'blob',
2 years ago
})
const transform = this.getTransform()
const { requestOptions } = this.options
const opt: RequestOptions = Object.assign({}, requestOptions, options)
const { beforeRequestHook, requestCatchHook } = transform || {}
if (beforeRequestHook && isFunction(beforeRequestHook))
2 years ago
conf = beforeRequestHook(conf, opt)
2 years ago
conf.requestOptions = opt
conf = this.supportFormData(conf)
return new Promise((resolve, reject) => {
this.axiosInstance
.request<any, AxiosResponse<Result>>(conf)
.then((res: AxiosResponse<Result>) => {
resolve(res as unknown as Promise<T>)
// download file
2 years ago
if (typeof res != 'undefined')
2 years ago
downloadByData(res?.data as unknown as BlobPart, title)
})
.catch((e: Error | AxiosError) => {
if (requestCatchHook && isFunction(requestCatchHook)) {
reject(requestCatchHook(e, opt))
return
}
if (axios.isAxiosError(e)) {
// rewrite error message from axios in here
}
reject(e)
})
})
}
2 years ago
request<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
let conf: CreateAxiosOptions = cloneDeep(config)
// cancelToken 如果被深拷贝,会导致最外层无法使用cancel方法来取消请求
if (config.cancelToken)
2 years ago
conf.cancelToken = config.cancelToken
if (config.signal)
conf.signal = config.signal
2 years ago
const transform = this.getTransform()
const { requestOptions } = this.options
const opt: RequestOptions = Object.assign({}, requestOptions, options)
const { beforeRequestHook, requestCatchHook, transformResponseHook } = transform || {}
if (beforeRequestHook && isFunction(beforeRequestHook))
2 years ago
conf = beforeRequestHook(conf, opt)
2 years ago
conf.requestOptions = opt
conf = this.supportFormData(conf)
return new Promise((resolve, reject) => {
this.axiosInstance
.request<any, AxiosResponse<Result>>(conf)
.then((res: AxiosResponse<Result>) => {
if (transformResponseHook && isFunction(transformResponseHook)) {
try {
const ret = transformResponseHook(res, opt)
resolve(ret)
}
catch (err) {
2 years ago
reject(err || new Error('request error!'))
}
return
}
resolve(res as unknown as Promise<T>)
})
.catch((e: Error | AxiosError) => {
if (requestCatchHook && isFunction(requestCatchHook)) {
reject(requestCatchHook(e, opt))
return
}
if (axios.isAxiosError(e)) {
2 years ago
// 在此处重写来自 axios 的错误消息
2 years ago
}
reject(e)
})
})
}
}