app.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. import { http } from '@/utils/http';
  2. import { app } from '@/store/mutation-types';
  3. import { getRuntimeServices } from '@/utils/runtime-services';
  4. /**
  5. * @description 得到系统标志
  6. * @param {object} data 请求数据
  7. */
  8. export function GetLogo(data) {
  9. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=sys_config_manager-GetLogo`, data);
  10. }
  11. /**
  12. * 得到文件 ID 与 URL 的映射
  13. */
  14. export function GetFileURLMap(data) {
  15. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=file_store_manager-GetFileURLMap`, data);
  16. }
  17. /**
  18. * 得到文件存储信息
  19. * @param {object} data 请求数据
  20. * @param {string} data.file_id 文件 ID
  21. */
  22. export function GetFileStoreInfo(data) {
  23. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=file_store_manager-GetFileStoreInfo`, data);
  24. }
  25. /**
  26. * 上传文件
  27. * @param {string} SecurityLevel 保密级别
  28. * @param {object} file 文件对象
  29. * @param {object} option 上传选项
  30. * @param {function} option.handleUploadProgress 上传进度回调
  31. * @param {boolean} option.isGlobalprogress 是否使用全局进度条
  32. */
  33. export async function fileUpload(
  34. SecurityLevel,
  35. file,
  36. { handleUploadProgress, isGlobalprogress = false } = { isGlobalprogress: false },
  37. ) {
  38. const { store } = getRuntimeServices();
  39. let formData = null;
  40. if (file instanceof FormData) {
  41. formData = file;
  42. } else {
  43. formData = new FormData();
  44. formData.append(file.filename, file.file, file.file.name);
  45. }
  46. let onUploadProgress = handleUploadProgress || null;
  47. if (isGlobalprogress && store) {
  48. store.commit(`app/${app.SHOW_PROGRESS}`, true);
  49. onUploadProgress = ({ loaded, progress, total }) => {
  50. // 因为上传进度为 1 后,上传事件还会继续一段时间,所以这里将进度设置为 0.99
  51. let precent = progress >= 1 ? 0.99 : progress;
  52. store.commit(`app/${app.SET_UPLOAD_INFO}`, { loaded, progress: precent, total });
  53. };
  54. }
  55. const controller = new AbortController();
  56. store?.commit(`app/${app.SET_UPLOAD_CONTROLLER}`, controller);
  57. try {
  58. const res = await http.postForm(
  59. '/FileServer/WebFileUpload',
  60. formData,
  61. {
  62. params: {
  63. SecurityLevel,
  64. },
  65. signal: controller.signal,
  66. transformRequest: [(data) => data],
  67. onUploadProgress,
  68. timeout: 0,
  69. },
  70. true,
  71. );
  72. store?.commit(`app/${app.SET_UPLOAD_INFO}`, { progress: 1 });
  73. return res;
  74. } finally {
  75. store?.commit(`app/${app.SET_UPLOAD_CONTROLLER}`, null);
  76. }
  77. }
  78. export function GetStaticResources(MethodName, data) {
  79. return http.post(`/OtherSysTool/GCLSBaseServer/SI?MethodName=${MethodName}`, data);
  80. }
  81. export function GetBookWebSIContent(MethodName, data) {
  82. return http.post(`/GCLSBookWebSI/ServiceInterface?MethodName=${MethodName}`, data);
  83. }
  84. /**
  85. * 解压 H5 游戏包并创建启动文件
  86. * @param {object} data 请求数据
  87. * @param {string} data.file_id 文件 ID
  88. * @param {string} data.index_file_name 启动文件名称
  89. */
  90. export function H5StartupFile(data) {
  91. return http.post(`/FileServer/SI?MethodName=file_store_manager-UnzipH5GamePackCreateStartupFile`, data);
  92. }
  93. /**
  94. * 解压 3D 模型包并创建启动文件
  95. * @param {object} data 请求数据
  96. * @param {string} data.file_id 文件 ID
  97. */
  98. export function Unzip3DModelPackCreateStartupFile(data) {
  99. return http.post(`/FileServer/SI?MethodName=file_store_manager-Unzip3DModelPackCreateStartupFile`, data);
  100. }
  101. export function LearnWebSI(MethodName, data) {
  102. return http.post(`/GCLSLearnWebSI/ServiceInterface?MethodName=${MethodName}`, data);
  103. }
  104. /**
  105. * 生成教材预览链接
  106. * @param {object} data 请求数据
  107. * @param {string} data.book_id 教材 ID
  108. */
  109. export function CreateBookPreviewURL(data) {
  110. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=book_preview_manager-CreateBookPreviewURL`, data);
  111. }
  112. /**
  113. * 生成课件预览链接
  114. * @param {object} data 请求数据
  115. * @param {string} data.courseware_id 课件 ID
  116. */
  117. export function CreateCoursewarePreviewURL(data) {
  118. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=book_preview_manager-CreateCoursewarePreviewURL`, data);
  119. }
  120. /**
  121. * 文本转音频文件-有音色配置
  122. * @param {object} data 请求数据
  123. */
  124. export function TextToAudioFile(data) {
  125. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-TextToAudioFile`, data);
  126. }
  127. /**
  128. * 得到文本转音频的配置参数列表
  129. */
  130. export function GetTextToAudioConfParamList() {
  131. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-GetTextToAudioConfParamList`);
  132. }
  133. /**
  134. * 得到系统版本信息
  135. */
  136. export function GetSysVersionInfo() {
  137. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=login_control-GetSysVersionInfo`);
  138. }
  139. /**
  140. * 拼音转音频文件-有音色配置
  141. * @param {object} data 请求数据
  142. */
  143. export function PinyinToAudioFile(data) {
  144. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-PinyinToAudioFile`, data);
  145. }
  146. /**
  147. * @description 得到验证码图像
  148. */
  149. export function GetVerificationCodeImage() {
  150. return http.get(`${process.env.VUE_APP_EepServer}?MethodName=login_control-GetVerificationCodeImage`);
  151. }
  152. /**
  153. * @description 重置密码
  154. */
  155. export function ResetPassword(data) {
  156. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=user_manager-ResetPassword`, data);
  157. }
  158. /**
  159. * @description 根据主色生成辅助色
  160. */
  161. export function ToAuxiliaryColor(data) {
  162. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-ToAuxiliaryColor`, data);
  163. }
  164. /**
  165. * @description 文本翻译
  166. */
  167. export function TextTrans(data) {
  168. return http.post(`${process.env.VUE_APP_EepServer}?MethodName=tool-Texttrans`, data);
  169. }