serviceURL.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * 因 ts 不鼓励写全局变量,鼓励用模块系统
  3. * 故,全部请求服务地址统一存放在 serviceURL 这个对象中
  4. *
  5. * 使用例子:
  6. * import { serviceURL } from '@/services/request/serviceURL';
  7. *
  8. * serviceURL.commSearchUrl
  9. */
  10. interface URL {
  11. commSearchUrl: string;
  12. goCommonSearchUrl: string;
  13. hsbyBankSignZone: string;
  14. hsbyPayUrlWeb: string;
  15. hsbyRegister: string;
  16. hsbySignUp: string;
  17. mobileAuthUrl: string;
  18. mobileOpenUrl: string;
  19. newsUrl: string;
  20. openApiUrl: string;
  21. quoteHost: string;
  22. quotePort: string;
  23. quoteUrl: string;
  24. tradeHost: string;
  25. tradePort: string;
  26. tradeUrl: string;
  27. uploadUrl: string;
  28. iOS: string;
  29. android: string;
  30. pcNewsUrl: string;
  31. pcMangerUrl: string;
  32. oem: string;
  33. }
  34. export let serviceURL: URL = {
  35. commSearchUrl: '',
  36. goCommonSearchUrl: '',
  37. hsbyBankSignZone: '',
  38. hsbyRegister: '',
  39. hsbyPayUrlWeb: '',
  40. hsbySignUp: '',
  41. mobileAuthUrl: '',
  42. mobileOpenUrl: '',
  43. newsUrl: '',
  44. openApiUrl: '',
  45. quoteHost: '',
  46. quotePort: '',
  47. quoteUrl: '',
  48. tradeHost: '',
  49. tradePort: '',
  50. tradeUrl: '',
  51. uploadUrl: '',
  52. oem: '',
  53. iOS: '',
  54. android: '',
  55. pcNewsUrl: '',
  56. pcMangerUrl: '',
  57. };
  58. /**
  59. * go 通用查询地址模板
  60. * @param url
  61. */
  62. export const goCommonSearchUrl = (url: string): string => {
  63. return serviceURL.goCommonSearchUrl + url;
  64. };
  65. /**
  66. * 管理端查询地址模板
  67. * @param url
  68. */
  69. export const commonSearchUrl = (url: string): string => {
  70. return serviceURL.commSearchUrl + url;
  71. };
  72. export const getUplodaUrl = (): string => {
  73. return serviceURL.uploadUrl
  74. }
  75. export const setServiceURL = (config: URL): void => {
  76. // console.log('URL', config);
  77. //外网环境(175),外包同事使用
  78. serviceURL = config;
  79. // if (process.env.NODE_ENV === 'development') {
  80. // serviceURL.goCommonSearchUrl = 'http://218.17.158.45:21001/api';
  81. // serviceURL.quoteUrl = 'ws://218.17.158.45:21009';
  82. // serviceURL.tradeUrl = 'ws://218.17.158.45:21010';
  83. // }
  84. console.log('api地址:', serviceURL);
  85. };