import CommonSet from '@/api/setting-center/CommonSet'

const actions = {
  // 获取文件列表
  loadFiles({ commit }, params) {
    var api = new CommonSet()

    console.log(params)
    return new Promise((resolve, reject) => {
      api
        .loadFileList(params)
        .then(response => {
          const { data } = response
          resolve(data)
        })
        .catch(error => {
          console.error(error)
          reject(error)
        })
    })
  },
  // 上传文件
  uploadFile({ commit }, params) {
    var api = new CommonSet()

    return new Promise((resolve, reject) => {
      api
        .uploadFile(params.file, params.fid, '')
        .then(response => {
          resolve(response)
        })
        .catch(error => {
          console.error(error)
          reject(error)
        })
    })
  }
}

export default {
  namespaced: true,
  actions
}
