闫增涛
2024-11-19 d8c24a06b3e7844ad65e7c821c022dbb36d29430
src/assets/methods/resources.js
@@ -1,4 +1,6 @@
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 = "jingshieke") => {
  let path = "";
  await fileApi
@@ -15,8 +17,37 @@
    });
  return path;
};
// 获取收藏的资源
export const getCollectResource = async (key) => {
  if(!localStorage.getItem(tokenKey)) return []
  let list = []
  await identityApi
  .getUserKey({
    domain: "collectResource",
    keys: [key],
  })
  .then((res) => {
    if(res.length) {
      list = JSON.parse(res[0].value)
    }
  });
  return list
}
export const setCollectResource = (key,list) => {
  identityApi.setUserKey({
    setKeyRequests: [
      {
        domain: "collectResource",
        key,
        value: JSON.stringify(list),
      },
    ],
  })
}
const MT = {
  getResourcePath,
  getCollectResource,
  setCollectResource
};
export default MT;