| | |
| | | import fileApi from "@/assets/js/middleGround/api/file"; |
| | | import identityApi from "../js/middleGround/api/identity"; |
| | | export const getResourcePath = async (md5, appRefCode = "jingshieke") => { |
| | | let path = ""; |
| | | await fileApi |
| | | .getAliVod({ |
| | | md5, |
| | | appRefCode, |
| | | }) |
| | | .then((res) => { |
| | | if (res?.data != "" && res?.data != undefined) { |
| | | path = res.data; |
| | | } else { |
| | | path = process.env.VUE_APP_API_URL + "/file/api/ApiDownload?md5=" + md5; |
| | | } |
| | | }); |
| | | return path; |
| | | 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) => { |
| | | let list = [] |
| | | await identityApi |
| | | .getUserKey({ |
| | | if (!localStorage.getItem(tokenKey)) return []; |
| | | const res = 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) => { |
| | | return res.length ? JSON.parse(res[0].value) : []; |
| | | }; |
| | | export const setCollectResource = (key, list) => { |
| | | identityApi.setUserKey({ |
| | | setKeyRequests: [ |
| | | { |
| | |
| | | value: JSON.stringify(list), |
| | | }, |
| | | ], |
| | | }) |
| | | } |
| | | }); |
| | | }; |
| | | const MT = { |
| | | getResourcePath, |
| | | getCollectResource, |
| | | setCollectResource |
| | | setCollectResource, |
| | | uploadFilePath |
| | | }; |
| | | |
| | | export default MT; |