import { api } from "./fetch";


var CryptoJS = require("crypto-js");

// 更新本地 传参 data => cid pwd
export function syncLocal(data) {
  var sign = CryptoJS.MD5(JSON.stringify(data).replace(/\"/g, "'")).toString().toUpperCase();
  data.sign = sign
  let params = new URLSearchParams();
  params.append('data', JSON.stringify(data));
  return api.post('/download', params)
}

// 更新云端 传参 data => cid pwd content
export function syncCloud(data) {
  let data_cache = Object.assign({}, data)
  delete data_cache.content
  var sign = CryptoJS.MD5(JSON.stringify(data_cache).replace(/\"/g, "'")).toString().toUpperCase();
  data.sign = sign
  let params = new URLSearchParams();
  params.append('data', JSON.stringify(data));
  return api.post('/upload', params)
}