MCPcopy Index your code
hub / github.com/smallfawn/QLScriptPublic / getActivityToken

Method getActivityToken

wxapp/mxbc.js:313–340  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

311
312 //获取活动token
313 async getActivityToken() {
314 try {
315 const opts = {
316 method: "GET",
317 url: this.activityUrl,
318 maxRedirects: 0,
319 // 关键点 2: 默认 Axios 认为非 2xx 是错误,需定义 302 为合法状态
320 validateStatus: function (status) {
321 return status >= 200 && status < 400; // 允许 302 (或 3xx) 进入 .then
322 },
323 headers: {}
324 }
325 let res = await axios.request(opts);
326
327 let headers = this.ObjectKeys2LowerCase(res?.headers);
328 //对青龙进行兼容
329 let session = Array.isArray(headers['set-cookie']) ? [...new Set(headers['set-cookie'])].join("") : headers['set-cookie'];
330
331 let [wdata4, w_ts, _ac, wdata3, dcustom] = session.match(/(wdata4|w_ts|_ac|wdata3|dcustom)=.+?;/g)
332 this.session = wdata4 + w_ts + _ac + wdata3 + dcustom;
333 $.log(`✅ 获取活动token成功!`)
334
335
336 } catch (e) {
337
338 $.log(`⛔️ 获取活动token失败!${e}`);
339 }
340 }
341 async activityIndex() {
342 try {
343 const opts = {

Callers 1

runMethod · 0.95

Calls 3

ObjectKeys2LowerCaseMethod · 0.95
requestMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected