{"size": 818, "ext": "js", "max_stars_repo_path": "public/interface/src/pages/admin/uploader/uploaderApi.js", "max_stars_repo_name": "ppjun378/firstr_commit", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/interface/src/pages/admin/uploader/uploaderApi.js", "max_issues_repo_name": "ppjun378/firstr_commit", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/interface/src/pages/admin/uploader/uploaderApi.js", "max_forks_repo_name": "ppjun378/firstr_commit", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.0588235294, "max_line_length": 74, "alphanum_fraction": 0.5880195599}
import httpAxios from '@/public/http.js';
import './uploaderApiMock'

export default {
  /**
   * 获取多个文章
   * @param file
   * @param url
   */
  async uploadImg(file, url = null) {
    let result;
    let param = new FormData();
    // 创建form对象
    param.append('img', file);
    param.append('chunk', '0');
    // 通过append向form对象添加数据
    // FormData私有类对象，访问不到，可以通过get判断值是否传进去
    console.log(param.get('file'));

    let config = {
      headers: {
        'X-Requested-With': 'XMLHttpRequest',
        'Content-Type': 'multipart/form-data',
      }
    }; //添加请求头
    return await httpAxios.post(url || 'do/api_upload_img', param, config)
      .then(res => {
        console.info('上传文件成功', res.data);
        window.$store.dispatch('uploadFileSuccess', res.data);
        return result = res.data;
      })
  },
}
