| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import axios from "axios";
- import config from "@/config"
- import http from "@/utils/request"
- export default {
- folder: {
- url: `${config.API_URL}/api/folder`,
- name: "文件上传",
- up: async function (data, config = {}) {
- return await http.post(`${this.url}/up`, data, config);
- },
-
- rm: async function (entityID) {
- return await http.post(`${this.url}/rm`, { querys: [], expands: { entityID } });
- },
- download: async function (entityID, isTxt = false) { // url: string, isTxt: txt解码
- const config = {
- responseType: "blob",
- transformResponse: isTxt && [
- async function (data) {
- return await transformData(data);
- }
- ] || []
- }
- return await http.get(`${this.url}/${entityID}`, {}, config);
- }
- },
- minio: {
- url: `${config.API_URL}/ops/minio`,
- name: "文件上传",
- up: async function (data, config = {}) {
- return await http.post(`${this.url}/uploadAihazard`, data, config);
- },
-
- rm: async function (fileName) {
- return await http.post(`${this.url}/remove`, { fileName });
- },
- download: async function (entityID) {
- return await http.get(`${this.url.replace("/ops", "")}${entityID}`, {}, { responseType: "blob" });
- }
- },
- opsTask: {
- name: "任务列表",
- url: `${config.API_URL}/ops/opsTask`,
- get: async function (data = {}) {
- return await http.post(`${this.url}/getPage`, data);
- },
- stop: async function (data = {}) {
- return await http.post(`${this.url}/stopTask`, data);
- }
- },
- }
- function transformData(data) {
- return new Promise(resolve => {
- const reader = new FileReader();
- reader.readAsText(data, "UTF-8");
- reader.onload = () => {
- if (reader.result.includes("�")) {
- reader.readAsText(data, "GBK");
- reader.onload = () => resolve(reader.result);
- } else resolve(reader.result);
- };
- });
- }
|