layout.ts 711 B

12345678910111213141516171819202122232425262728
  1. import { domShowFu, progressDomFu } from '@/utils/domShow'
  2. import http from '@/utils/http'
  3. import axios from 'axios'
  4. import store from '..'
  5. const CancelToken = axios.CancelToken
  6. /**
  7. * 上传封面图和附件
  8. */
  9. export const API_upFile = (data: any, url: string) => {
  10. domShowFu('#UpAsyncLoding', true)
  11. return http.post(url, data, {
  12. timeout: 0,
  13. // 显示进度条
  14. onUploadProgress: (e: any) => {
  15. const complete = (e.loaded / e.total) * 100 || 0
  16. progressDomFu(complete + '%')
  17. },
  18. // 取消上传
  19. cancelToken: new CancelToken(function executor(c) {
  20. store.dispatch({
  21. type: 'layout/closeUpFile',
  22. payload: { fu: c, state: true }
  23. })
  24. })
  25. })
  26. }