From 1695fcd442fe2cefb6d3b63869ad8a72ebd5210a Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期五, 04 七月 2025 23:57:18 +0800 Subject: [PATCH] 测试图书 7.4 --- src/assets/methods/resources.js | 77 +++++++++++++++++++++++++++++--------- 1 files changed, 59 insertions(+), 18 deletions(-) diff --git a/src/assets/methods/resources.js b/src/assets/methods/resources.js index 37168bb..57391ca 100644 --- a/src/assets/methods/resources.js +++ b/src/assets/methods/resources.js @@ -1,19 +1,60 @@ -import fileApi from '@/assets/js/middleGround/api/file' -export const getResourcePath = async(md5,appRefCode = "jingshieke") => { - let path = '' - await fileApi.getAliVod({ - md5,appRefCode - }).then(res => { - if(res.data.length) { - path = res.data - } else { - path = process.env.VUE_APP_API_URL + '/file/api/ApiDownload?md5=' + md5 - } - }) - return path -} -const MT = { - getResourcePath -} +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") => { + // const res = fileApi.getAliVod({ + // md5, + // appRefCode, + // }); -export default MT \ No newline at end of file + // return res.data != "" && res.data != undefined + // ? res.data + // : process.env.VUE_APP_API_URL + "/file/api/ApiDownload?md5=" + md5; + + // 鐩存帴鍘婚樋閲屼簯鑾峰彇 + const res = await fileApi.getAliVod({ + md5, + appRefCode, + }); + if (typeof res === "string" && res.includes("http")) { + return res; + } else if (typeof res === "object" && res.data != "") { + return res.data; + } else { + return 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 MT; -- Gitblit v1.9.1