jkesSettings.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. gpsAltitude: 269.75,
  10. gpsDefaultAccuracy: 6,
  11. /** 自动乐跑随机配速:每公里秒数 */
  12. paceRandomMinSecPerKm: 180,
  13. paceRandomMaxSecPerKm: 600,
  14. /** 自动乐跑单次最大公里(用于月底追目标) */
  15. autoSingleRunMaxKm: 10,
  16. /** 自动乐跑距离步进(公里) */
  17. autoDistanceStepKm: 0.1
  18. }
  19. let cached
  20. function getJkesSettings() {
  21. if (cached) return cached
  22. try {
  23. const cfg = require(path.join(__dirname, '../../config.json'))
  24. cached = { ...defaultJkes, ...(cfg.jkes || {}) }
  25. } catch {
  26. cached = { ...defaultJkes }
  27. }
  28. return cached
  29. }
  30. function normalizeApiBase(raw) {
  31. let u = String(raw || defaultJkes.apiBase).trim()
  32. if (u.startsWith('http://')) {
  33. u = `https://${u.slice('http://'.length)}`
  34. }
  35. return u.replace(/\/$/, '')
  36. }
  37. module.exports = {
  38. getJkesSettings,
  39. normalizeApiBase,
  40. defaultJkes
  41. }