12345678910111213141516171819202122232425262728 |
- import { domShowFu, progressDomFu } from '@/utils/domShow'
- import http from '@/utils/http'
- import axios from 'axios'
- import store from '..'
- const CancelToken = axios.CancelToken
- /**
- * 上传封面图和附件
- */
- export const API_upFile = (data: any, url: string) => {
- domShowFu('#UpAsyncLoding', true)
- return http.post(url, data, {
- timeout: 0,
- // 显示进度条
- onUploadProgress: (e: any) => {
- const complete = (e.loaded / e.total) * 100 || 0
- progressDomFu(complete + '%')
- },
- // 取消上传
- cancelToken: new CancelToken(function executor(c) {
- store.dispatch({
- type: 'layout/closeUpFile',
- payload: { fu: c, state: true }
- })
- })
- })
- }
|