This commit is contained in:
2025-06-21 18:21:49 +08:00
parent a76b506327
commit da6d4041ad
9 changed files with 121 additions and 12 deletions

View File

@@ -1,13 +1,13 @@
import { QueryRouterServer } from '@kevisual/router/browser';
import { XhsServices } from '@kevisual/xhs/services/xhs-services.ts';
import { XhsServices, XhsClient } from '@kevisual/xhs/services/xhs-services.ts';
export const app = new QueryRouterServer();
export const xhsServices = new XhsServices();// Semicolon separated Cookie File
export const xhsServices = new XhsServices(); // Semicolon separated Cookie File
const cookie =
'a1=1978d0cdcb7p5neac7cesgfm9yat0b4a7hnesexkp30000220066;abRequestId=f98f27d6-cceb-53d9-a9ef-dbd68786231b;access-token-creator.xiaohongshu.com=customer.creator.AT-68c517518075239703025713copo06lnusenqic1;customer-sso-sid=68c517518075239698553486mipyx4lwk2ac5jaj;customerClientId=716985104518687;galaxy_creator_session_id=wda55FJhoiAWZ8cekT2aGiM9fuztft3mOdRM;galaxy.creator.beaker.session.id=1750438297110093146037;gid=yjWYf8Si4SWjyjWYf8SfSxdCDWU2Id0SWSdMITUki6jv0dq898D40M888JJ88KK8fdKS8jiy;loadts=1750444792784;sec_poison_id=2f592adb-ec34-48cd-a6ce-22b90bd67c3b;unread={%22ub%22:%226852a4100000000022030063%22%2C%22ue%22:%226854e0db00000000100251f6%22%2C%22uc%22:28};web_session=040069b6528dbc23c355980a603a4b3e03bb6a;webBuild=4.68.0;webId=1dbb23b746393db622165a22357897d5;websectiga=10f9a40ba454a07755a08f27ef8194c53637eba4551cf9751c009d9afb564467;x-user-id-creator.xiaohongshu.com=6726cef4000000001c019303;xsecappid=xhs-pc-web;acw_tc=0a00d41117504447915317110e41effee63c597aa77f2c9f0dc1b0a10248f8;';
'a1=****;abRequestId=f98f27d6-cceb-53d9-a9ef-dbd68786231b;access-token-creator.xiaohongshu.com=customer.creator.AT-68c517518075239703025713copo06lnusenqic1;customer-sso-sid=68c517518075239698553486mipyx4lwk2ac5jaj;customerClientId=716985104518687;galaxy_creator_session_id=wda55FJhoiAWZ8cekT2aGiM9fuztft3mOdRM;galaxy.creator.beaker.session.id=1750438297110093146037;gid=yjWYf8Si4SWjyjWYf8SfSxdCDWU2Id0SWSdMITUki6jv0dq898D40M888JJ88KK8fdKS8jiy;loadts=1750444792784;sec_poison_id=2f592adb-ec34-48cd-a6ce-22b90bd67c3b;unread={%22ub%22:%226852a4100000000022030063%22%2C%22ue%22:%226854e0db00000000100251f6%22%2C%22uc%22:28};web_session=040069b6528dbc23c355980a603a4b3e03bb6a;webBuild=4.68.0;webId=1dbb23b746393db622165a22357897d5;websectiga=10f9a40ba454a07755a08f27ef8194c53637eba4551cf9751c009d9afb564467;x-user-id-creator.xiaohongshu.com=6726cef4000000001c019303;xsecappid=xhs-pc-web;acw_tc=0a00d41117504447915317110e41effee63c597aa77f2c9f0dc1b0a10248f8;';
xhsServices.createRoot({
export const xhsRootClient: XhsClient = xhsServices.createRoot({
cookie,
signConfig: {
signUrl: 'http://light.xiongxiao.me:5006/sign',

View File

@@ -1,5 +1,5 @@
import { XhsClient } from './libs/xhs.ts';
import { app, xhsServices } from './app.ts';
import { app, xhsServices, xhsRootClient } from './app.ts';
import './routes/index.ts';
export { XhsClient, app, xhsServices };
export { XhsClient, app, xhsServices, xhsRootClient };

View File

@@ -66,6 +66,9 @@ export class XhsClient extends XhsClientBase {
constructor(opts: XhsOptions) {
super(opts as any);
}
setCookie(cookie: string) {
this.cookie = cookie;
}
getApiInfo = getApiInfo;
printResult(msg: string, data: any) {
if (msg === 'response') {

View File

@@ -3,7 +3,7 @@ import { Sequelize } from 'sequelize';
// import { createSequelize } from '@kevisual/xhs/services/xhs-db/db.ts';
import path from 'node:path';
import fs from 'node:fs';
export { XhsClient };
type XhsClientOptions = {
key: string;
cookie: string;
@@ -69,7 +69,7 @@ export class XhsServices {
createRoot(options: Partial<XhsClientOptions>) {
options.key = options.key || this.root;
return this.createClient(options as XhsClientOptions);
return this.createClient(options as XhsClientOptions) as XhsClient;
}
getKey(key?: string) {
if (!key) key = this.root;