12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import { http } from '@/utils/http';
- import store from '@/store';
- import { app } from '@/store/mutation-types';
- /**
- * @description 得到系统标志
- * @param {object} data 请求数据
- */
- export function GetLogo(data) {
- return http.post(`${process.env.VUE_APP_EepServer}?MethodName=sys_config_manager-GetLogo`, data);
- }
- /**
- * 得到文件 ID 与 URL 的映射
- */
- export function GetFileURLMap(data) {
- return http.post(`${process.env.VUE_APP_EepServer}?MethodName=file_store_manager-GetFileURLMap`, data);
- }
- /**
- * 得到文件存储信息
- * @param {object} data 请求数据
- * @param {string} data.file_id 文件 ID
- */
- export function GetFileStoreInfo(data) {
- return http.post(`${process.env.VUE_APP_EepServer}?MethodName=file_store_manager-GetFileStoreInfo`, data);
- }
- /**
- * 上传文件
- * @param {string} SecurityLevel 保密级别
- * @param {object} file 文件对象
- * @param {object} option 上传选项
- * @param {function} option.handleUploadProgress 上传进度回调
- * @param {boolean} option.isGlobalprogress 是否使用全局进度条
- */
- export async function fileUpload(
- SecurityLevel,
- file,
- { handleUploadProgress, isGlobalprogress = false } = { isGlobalprogress: false },
- ) {
- let formData = null;
- if (file instanceof FormData) {
- formData = file;
- } else {
- formData = new FormData();
- formData.append(file.filename, file.file, file.file.name);
- }
- let onUploadProgress = handleUploadProgress || null;
- if (isGlobalprogress) {
- store.commit(`app/${app.SHOW_PROGRESS}`, true);
- onUploadProgress = ({ loaded, progress, total }) => {
- // 因为上传进度为 1 后,上传事件还会继续一段时间,所以这里将进度设置为 0.99
- let precent = progress >= 1 ? 0.99 : progress;
- store.commit(`app/${app.SET_UPLOAD_INFO}`, { loaded, progress: precent, total });
- };
- }
- const controller = new AbortController();
- store.commit(`app/${app.SET_UPLOAD_CONTROLLER}`, controller);
- try {
- const res = await http.postForm('/FileServer/WebFileUpload', formData, {
- params: {
- SecurityLevel,
- },
- signal: controller.signal,
- transformRequest: [(data) => data],
- onUploadProgress,
- timeout: 0,
- });
- store.commit(`app/${app.SET_UPLOAD_INFO}`, { progress: 1 });
- return res;
- } finally {
- store.commit(`app/${app.SET_UPLOAD_CONTROLLER}`, null);
- }
- }
- export function GetStaticResources(MethodName, data) {
- return http.post(`/OtherSysTool/GCLSBaseServer/SI?MethodName=${MethodName}`, data);
- }
- export function GetBookWebSIContent(MethodName, data) {
- return http.post(`/GCLSBookWebSI/ServiceInterface?MethodName=${MethodName}`, data);
- }
- /**
- * 解压 H5 游戏包并创建启动文件
- */
- export function H5StartupFile(data) {
- return http.post(`/FileServer/SI?MethodName=file_store_manager-UnzipH5GamePackCreateStartupFile`, data);
- }
- export function LearnWebSI(MethodName, data) {
- return http.post(`/GCLSLearnWebSI/ServiceInterface?MethodName=${MethodName}`, data);
- }
|