jkesSettings.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const path = require('path')
  2. const defaultJkes = {
  3. apiBase: 'https://jkes.smart-campus.com.cn:50077/api',
  4. userAgent:
  5. 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.69(0x18004539) NetType/WIFI Language/zh_CN',
  6. referer: 'https://servicewechat.com/wxbd35ecd93e780082/11/page-frame.html',
  7. tlsRejectUnauthorized: true,
  8. requestTimeoutMs: 30000,
  9. useSystemProxy: false,
  10. gpsAltitude: 269.75,
  11. gpsDefaultAccuracy: 6,
  12. /** 自动乐跑随机配速:每公里秒数 */
  13. paceRandomMinSecPerKm: 180,
  14. paceRandomMaxSecPerKm: 600,
  15. /** 自动乐跑单次最大公里(用于月底追目标) */
  16. autoSingleRunMaxKm: 5,
  17. /** 自动乐跑距离步进(公里) */
  18. autoDistanceStepKm: 0.5
  19. }
  20. let cached
  21. function getJkesSettings() {
  22. if (cached) return cached
  23. try {
  24. const cfg = require(path.join(__dirname, '../../config.json'))
  25. cached = { ...defaultJkes, ...(cfg.jkes || {}) }
  26. } catch {
  27. cached = { ...defaultJkes }
  28. }
  29. return cached
  30. }
  31. function normalizeApiBase(raw) {
  32. let u = String(raw || defaultJkes.apiBase).trim()
  33. if (u.startsWith('http://')) {
  34. u = `https://${u.slice('http://'.length)}`
  35. }
  36. return u.replace(/\/$/, '')
  37. }
  38. module.exports = {
  39. getJkesSettings,
  40. normalizeApiBase,
  41. defaultJkes
  42. }