import { http } from '@/utils/http'; import { app } from '@/store/mutation-types'; import { getRuntimeServices } from '@/utils/runtime-services'; /** * @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 }, ) { const { store } = getRuntimeServices(); 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) { 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, }, true, ); 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 游戏包并创建启动文件 * @param {object} data 请求数据 * @param {string} data.file_id 文件 ID * @param {string} data.index_file_name 启动文件名称 */ export function H5StartupFile(data) { return http.post(`/FileServer/SI?MethodName=file_store_manager-UnzipH5GamePackCreateStartupFile`, data); } /** * 解压 3D 模型包并创建启动文件 * @param {object} data 请求数据 * @param {string} data.file_id 文件 ID */ export function Unzip3DModelPackCreateStartupFile(data) { return http.post(`/FileServer/SI?MethodName=file_store_manager-Unzip3DModelPackCreateStartupFile`, data); } export function LearnWebSI(MethodName, data) { return http.post(`/GCLSLearnWebSI/ServiceInterface?MethodName=${MethodName}`, data); } /** * 生成教材预览链接 * @param {object} data 请求数据 * @param {string} data.book_id 教材 ID */ export function CreateBookPreviewURL(data) { return http.post(`${process.env.VUE_APP_EepServer}?MethodName=book_preview_manager-CreateBookPreviewURL`, data); } /** * 生成课件预览链接 * @param {object} data 请求数据 * @param {string} data.courseware_id 课件 ID */ export function CreateCoursewarePreviewURL(data) { return http.post(`${process.env.VUE_APP_EepServer}?MethodName=book_preview_manager-CreateCoursewarePreviewURL`, data); } /** * 文本转音频文件-有音色配置 * @param {object} data 请求数据 */ export function TextToAudioFile(data) { return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-TextToAudioFile`, data); } /** * 得到文本转音频的配置参数列表 */ export function GetTextToAudioConfParamList() { return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-GetTextToAudioConfParamList`); } /** * 得到系统版本信息 */ export function GetSysVersionInfo() { return http.post(`${process.env.VUE_APP_EepServer}?MethodName=login_control-GetSysVersionInfo`); } /** * 拼音转音频文件-有音色配置 * @param {object} data 请求数据 */ export function PinyinToAudioFile(data) { return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-PinyinToAudioFile`, data); } /** * @description 得到验证码图像 */ export function GetVerificationCodeImage() { return http.get(`${process.env.VUE_APP_EepServer}?MethodName=login_control-GetVerificationCodeImage`); } /** * @description 重置密码 */ export function ResetPassword(data) { return http.post(`${process.env.VUE_APP_EepServer}?MethodName=user_manager-ResetPassword`, data); } /** * @description 根据主色生成辅助色 */ export function ToAuxiliaryColor(data) { return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-ToAuxiliaryColor`, data); } /** * @description 文本翻译 */ export function TextTrans(data) { return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-Texttrans`, data); }