config.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * 应用全局配置
  3. *
  4. * 环境自动检测(基于微信小程序官方 API):
  5. * uni.getAccountInfoSync().miniProgram.envVersion
  6. * 'develop' → 开发版(工具内预览)
  7. * 'trial' → 体验版(上传到体验版)
  8. * 'release' → 正式版(线上发布)
  9. *
  10. * 无需手动修改任何变量,发布到对应环境自动生效。
  11. */
  12. let API_BASE_URL = 'http://cfc.iwintrue.com'
  13. // LangGraph 适配层地址(AI 对话/分析走这里,失败时回退到 Dify)
  14. // 默认本地开发:http://localhost:9000;远程环境按需修改
  15. let LANGGRAPH_BASE_URL = 'http://localhost:9000'
  16. // Dify fallback 地址(LangGraph 不可用时回退到此)
  17. // 默认本地开发:http://localhost:8083;远程环境按需修改
  18. let DIFY_BASE_URL = 'http://localhost:8083'
  19. try {
  20. const accountInfo = uni.getAccountInfoSync()
  21. const env = accountInfo && accountInfo.miniProgram && accountInfo.miniProgram.envVersion
  22. if (env) {
  23. switch (env) {
  24. case 'develop':
  25. API_BASE_URL = 'https://cfc.etotem.com.cn'
  26. LANGGRAPH_BASE_URL = 'http://cfc.etotem.com.cn:9000'
  27. DIFY_BASE_URL = 'http://cfc.etotem.com.cn:8083'
  28. break
  29. case 'trial':
  30. API_BASE_URL = 'https://cfc.iwintrue.com'
  31. LANGGRAPH_BASE_URL = 'https://cfc.iwintrue.com:9000'
  32. DIFY_BASE_URL = 'https://cfc.iwintrue.com:8083'
  33. break
  34. case 'release':
  35. API_BASE_URL = 'https://cfc.etotem.com.cn'
  36. LANGGRAPH_BASE_URL = 'https://cfc.etotem.com.cn:9000'
  37. DIFY_BASE_URL = 'https://cfc.etotem.com.cn:8083'
  38. break
  39. }
  40. }
  41. } catch (e) {
  42. // 非小程序环境(H5/dev),使用默认地址
  43. }
  44. export default {
  45. API_BASE_URL,
  46. LANGGRAPH_BASE_URL,
  47. DIFY_BASE_URL,
  48. api(path) {
  49. return API_BASE_URL + path
  50. }
  51. }