zhongshujie
2025-03-14 21190e54e0fc3f5c5a8bc12500c48cf1853bfd62
src/assets/methods/resources.js
@@ -1,6 +1,45 @@
import config from "../js/config"
const getResourcePath = (md5) => {
  return  config.requestCtx + '/file/api/ApiDownload?md5=' + md5
}
import fileApi from "@/assets/js/middleGround/api/file";
import identityApi from "../js/middleGround/api/identity";
import { tokenKey } from "../js/config";
export const getResourcePath = async (md5, appRefCode = "tourismWebsite") => {
  const res = fileApi.getAliVod({
    md5,
    appRefCode,
  });
  return res.data != "" && res.data != undefined
    ? res.data
    : process.env.VUE_APP_API_URL + "/file/api/ApiDownload?md5=" + md5;
};
//上传资源
export const uploadFilePath = async (fileData) => {
  const res = fileApi.upload(fileData);
  return res;
};
// 获取收藏的资源
export const getCollectResource = async (key) => {
  if (!localStorage.getItem(tokenKey)) return [];
  const res = await identityApi.getUserKey({
    domain: "collectResource",
    keys: [key],
  });
  return res.length ? JSON.parse(res[0].value) : [];
};
export const setCollectResource = (key, list) => {
  identityApi.setUserKey({
    setKeyRequests: [
      {
        domain: "collectResource",
        key,
        value: JSON.stringify(list),
      },
    ],
  });
};
const MT = {
  getResourcePath,
  getCollectResource,
  setCollectResource,
  uploadFilePath
};
export default getResourcePath
export default MT;