generated from tailored/router-db-template
temp
This commit is contained in:
1 parent
d6014b3c40
commit
a412c09da0
20 files changed
+2911
-102
No files matched your search
@@ -128,6 +128,23 @@ class XhsClient {
|
||||
}
|
||||
return {};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {*} data
|
||||
*/
|
||||
setCookieMap(data = {}) {
|
||||
const cookieDict = this.getCookieMap();
|
||||
const newCookieDict = { ...cookieDict, ...data };
|
||||
const cookieStr = Object.entries(newCookieDict)
|
||||
.map(([key, value]) => {
|
||||
const trimmedKey = key.trim();
|
||||
const trimmedValue = value ? value.trim() : '';
|
||||
return `${trimmedKey}=${trimmedValue}`;
|
||||
})
|
||||
.join('; ');
|
||||
this.axiosInstance.defaults.headers.Cookie = cookieStr;
|
||||
this.cookie = cookieStr;
|
||||
}
|
||||
/**
|
||||
* Get X-S and X-T
|
||||
* @param {*} url
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
||||
import { XhsClient } from '../src/index.js';
|
||||
// import { XhsClient } from '../dist/app.mjs';
|
||||
import { cookie } from './common.ts';
|
||||
const client = new XhsClient({ cookie } as any);
|
||||
client.setCookieMap({ a1: 'thisistest' })
|
||||
console.log(client.getCookieMap());
|
||||
console.log(client.cookie);
|
||||
@@ -0,0 +1,4 @@
|
||||
import qs from 'querystring';
|
||||
|
||||
const r = qs.stringify({ a: 1, b: 2, c: 3 });
|
||||
console.log(r); // a=1&b=2&c=3
|
||||
Reference in new issue
Block a user