//API接口
export const exportDownload = (params?: Object, peCallback?: Function) => {
  return new Promise((resolve, reject) => {
    axios({
      method: 'get',
      url: '',
      headers: {
        'access_token': `${getToken()}`,
      },
      responseType: 'blob',
      params,
      onDownloadProgress: (pe) => {
        peCallback ? peCallback(pe) : '';
      },
    })
      .then((res) => {
        resolve(res);
      })
      .catch((err) => {
        console.warn(err);
      });
  });
};
function peCallback(pe) {
                  // 下载回调
//百分比计算
                  defaultPercent.value = Math.round((pe.event.loaded / pe.event.total) * 100);
                  if (pe.event.loaded === pe.event.total) {
                    showProgress.value = false;
                    message.success({ content: '下载完成', key, duration: 3 });
                  }
                }
                try {
                  exportDownload(params peCallback).then((res) => {
                    // 接口3
                    const fileName = 'xxx.xlsx';
                    let bold = new Blob([res.data]);
                    const newUrl = window.URL.createObjectURL(bold);
                    const link = document.createElement('a');
                    link.href = newUrl;
                    link.setAttribute('download', fileName);
                    document.body.appendChild(link);
                    link.click();
                    link.parentNode?.removeChild(link);
                  });
                } catch (error) {
                  message.warn('下载失败,请重试');
                }

GitHub 加速计划 / vu / vue
207.54 K
33.66 K
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:2 个月前 )
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 4 个月前
e428d891 Updated Browser Compatibility reference. The previous currently returns HTTP 404. 5 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐