api.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import {
  2. http
  3. } from '@/utils/http';
  4. import {
  5. getToken
  6. } from '@/utils/auth';
  7. import ENV from '@/config/env.js';
  8. /**
  9. * 解开访问令牌
  10. * @param {object} data 请求数据
  11. * @param {string} data.access_token 访问令牌
  12. */
  13. export function ParseAccessToken(data) {
  14. return http.post(ENV.VUE_APP_FileServer + `?MethodName=login_control-ParseAccessToken`, data);
  15. }
  16. /**
  17. * @description 得到验证码图像
  18. */
  19. export function GetVerificationCodeImage() {
  20. return http.get(ENV.VUE_APP_FileServer + `?MethodName=login_control-GetVerificationCodeImage`);
  21. }
  22. /**
  23. * @description 得到系统标志
  24. * @param {object} data 请求数据
  25. */
  26. export function GetLogo(data) {
  27. return http.post(ENV.VUE_APP_FileServer + `?MethodName=sys_config_manager-GetLogo`, data);
  28. }
  29. /**
  30. * @description 得到文件 ID 与 URL 的映射
  31. * @param {object} data 请求数据
  32. */
  33. export function GetFileURLMap(data) {
  34. return http.post(ENV.VUE_APP_FileServer + `?MethodName=file_store_manager-GetFileURLMap`, data);
  35. }
  36. /**
  37. * @description 得到文件存储信息
  38. * @param {object} data 请求数据
  39. */
  40. export function GetFileStoreInfo(data) {
  41. return http.post(ENV.VUE_APP_FileServer + `?MethodName=file_store_manager-GetFileStoreInfo`, data);
  42. }
  43. /**
  44. * @description 上传文件
  45. * @param {String} SecurityLevel 保密级别
  46. * @param {object} file 文件对象
  47. */
  48. export function fileUpload(SecurityLevel, file) {
  49. let formData = null;
  50. if (file instanceof FormData) {
  51. formData = file;
  52. } else if (file instanceof Array) {
  53. formData = new FormData();
  54. file.map(p => {
  55. formData.append(p.filename, p.file, p.file.name);
  56. })
  57. } else {
  58. formData = new FormData();
  59. formData.append(file.filename, file.file, file.file.name);
  60. }
  61. return http.postForm('/GCLSFileServer/WebFileUpload', formData, {
  62. params: {
  63. SecurityLevel,
  64. },
  65. transformRequest: [
  66. (data) => {
  67. return data;
  68. },
  69. ],
  70. timeout: 0,
  71. });
  72. }
  73. /**
  74. * @description 获取静态资源
  75. * @param {String} MethodName 方法名称
  76. * @param {object} data 请求数据:base64_text(需要生成文件的 Base64 编码文本),file_suffix_name(文件后缀名)
  77. */
  78. export function GetStaticResources(MethodName, data) {
  79. return http.post(ENV.VUE_APP_FileServer + `?MethodName=${MethodName}`, data);
  80. }