Skip to content

Commit

Permalink
通用下载方法新增config配置选项
Browse files Browse the repository at this point in the history
  • Loading branch information
yangzongzhuan committed Sep 19, 2022
1 parent 9290e3c commit aad94b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/FileUpload/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const emit = defineEmits();
const number = ref(0);
const uploadList = ref([]);
const baseUrl = import.meta.env.VITE_APP_BASE_API;
const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传的图片服务器地址
const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 上传文件服务器地址
const headers = ref({ Authorization: "Bearer " + getToken() });
const fileList = ref([]);
const showTip = computed(
Expand Down
5 changes: 3 additions & 2 deletions src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,13 @@ service.interceptors.response.use(res => {
)

// 通用下载方法
export function download(url, params, filename) {
export function download(url, params, filename, config) {
downloadLoadingInstance = ElLoading.service({ text: "正在下载数据,请稍候", background: "rgba(0, 0, 0, 0.7)", })
return service.post(url, params, {
transformRequest: [(params) => { return tansParams(params) }],
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob'
responseType: 'blob',
...config
}).then(async (data) => {
const isLogin = await blobValidate(data);
if (isLogin) {
Expand Down

0 comments on commit aad94b2

Please sign in to comment.