generated from tailored/router-template
temp
This commit is contained in:
17
packages/app-assistant/.gitignore
vendored
Normal file
17
packages/app-assistant/.gitignore
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
node_modules
|
||||
|
||||
dist
|
||||
|
||||
app.config.json5
|
||||
|
||||
apps.config.json
|
||||
|
||||
deploy.tar.gz
|
||||
cache-file
|
||||
|
||||
/apps
|
||||
|
||||
logs
|
||||
|
||||
.env*
|
||||
!.env.example
|
||||
21
packages/app-assistant/package.json
Normal file
21
packages/app-assistant/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "@kevisual/app-assistant",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
||||
"license": "MIT",
|
||||
"packageManager": "pnpm@10.10.0",
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.15.3",
|
||||
"bullmq": "^5.51.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"nanoid": "^5.1.5"
|
||||
}
|
||||
}
|
||||
1
packages/app-assistant/src/index.ts
Normal file
1
packages/app-assistant/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './provider/comments/xhs.ts';
|
||||
7
packages/app-assistant/src/provider/comments/xhs.ts
Normal file
7
packages/app-assistant/src/provider/comments/xhs.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { SocialBase } from '@/social/social-base.ts';
|
||||
|
||||
export class XHS extends SocialBase {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
39
packages/app-assistant/src/social/social-base.ts
Normal file
39
packages/app-assistant/src/social/social-base.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { nanoid } from 'nanoid';
|
||||
|
||||
export class SocialBase<T = any> {
|
||||
id: string = '';
|
||||
/**
|
||||
* 是否运行中
|
||||
*/
|
||||
isRuning: boolean = false;
|
||||
/**
|
||||
* 应用的配置项
|
||||
*/
|
||||
config: T;
|
||||
constructor(opts?: any) {
|
||||
this.config = opts?.config || {};
|
||||
this.id = opts?.id || nanoid();
|
||||
}
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
async getUserInfo() {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
/**
|
||||
* 获取被 call 的信息
|
||||
*/
|
||||
async getMention() {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送评论信息
|
||||
*/
|
||||
async sendComment() {
|
||||
// throw new Error('Method not implemented.');
|
||||
}
|
||||
async getUnread() {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
75
packages/app-assistant/src/test/get-unread.ts
Normal file
75
packages/app-assistant/src/test/get-unread.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
const unreadUrl = 'https://edith.xiaohongshu.com/api/sns/web/unread_count';
|
||||
const cookie =
|
||||
'a1=19686f83a65uiloc0y7wv79une457hsjh5lt00dpe40000147626;abRequestId=0a794332-4561-5f49-93f7-780b8b028e1f;access-token-creator.xiaohongshu.com=customer.creator.AT-68c517498636784561614544frjvxzj7yu8iewie;agora_session=6a0031373435393132333637323735343733393437313634000000000000;customerClientId=536706778174172;galaxy_creator_session_id=OhpHDDSoADhNEhnH5LLnQpletFLApu1fd91f;galaxy.creator.beaker.session.id=1745912429847011598150;gid=yjKqYfK0qDyYyj2DDSqd4ujxyW9kvxIuT62ddkMWhElyuxq8yDd6hl888q2WYy88j8i80yYD;loadts=1746020512562;sec_poison_id=441c932e-a6ac-4d8d-97ae-beb14adb1929;unread={%22ub%22:%2267eaf1fe000000001202c3ea%22%2C%22ue%22:%226803aa37000000001c0319d8%22%2C%22uc%22:35};web_session=040069b2e9c511ca302086ca253a4bde8b1cd1;webBuild=4.62.3;webId=97e5f097499594cad49aa0bd1a8ed83f;websectiga=3633fe24d49c7dd0eb923edc8205740f10fdb18b25d424d2a2322c6196d2a4ad;x-user-id-creator.xiaohongshu.com=639d86590000000026006076;xsecappid=xhs-pc-web;acw_tc=0a00df6217460205042195762e721fba339a0dbe8e4738b961a5ff15e74619;';
|
||||
|
||||
const cookieObj = cookie.split('; ').reduce((acc, item) => {
|
||||
const [key, value] = item.split('=');
|
||||
acc[key] = value;
|
||||
return acc;
|
||||
}, {} as Record<string, string>);
|
||||
const web_session = cookieObj['web_session'] || '';
|
||||
const a1 = cookieObj['a1'] || '';
|
||||
|
||||
const headers = {
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36',
|
||||
Cookie: cookie,
|
||||
};
|
||||
|
||||
const meUri = '/api/sns/web/v2/user/me';
|
||||
const getSign = async (uri: string, data: any, a1: string, web_session?: string) => {
|
||||
const signs = await fetch('http://light.xiongxiao.me:5006/sign', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
uri,
|
||||
data,
|
||||
a1,
|
||||
web_session: web_session,
|
||||
}),
|
||||
}).then((res) => res.json());
|
||||
return signs;
|
||||
};
|
||||
|
||||
const getUserMe = async () => {
|
||||
const sign = await getSign(meUri, null, a1, web_session);
|
||||
// const sign = {
|
||||
// 'x-s':
|
||||
// 'XYW_eyJzaWduU3ZuIjoiNTYiLCJzaWduVHlwZSI6IngyIiwiYXBwSWQiOiJsb2dpbiIsInNpZ25WZXJzaW9uIjoiMSIsInBheWxvYWQiOiJjYWE4NzYyMjk5NzQ0NDkzNGVhMWIxNDBjNzA0NTI2YmI0ZGZiYjcyMWJjMWQyZTEzNDhhNzZmNmM4MTI5NzljM2VkMWRmMjU0MGNkZDRkZmEyZGE0YjIzOTg0MDMyYmNmNGE4NDU1MzU4ZmZhZDQ0NjkxNzg4YWRjN2U2MmU3YjJmMzdmZGMzZTgwOWQ5NDNmOTRkM2JhMzVjNmQ3MzE4MjA1OWI3MTYyZGU0YjgxYzcyMDI2NmQyM2EzMmY1MGQ2NTQ5MmQ0ZTlhOTA3NmExY2JmMTYyZGJhMWJiMzAxNTg3MmY3MWU5MmIyNDllZGM3MmRkMjhiNGQ4Y2I4MjI2ZWY3YTdkYjI3NGQ2Y2YyMjVkZjk2ZjFmNWJlN2M2ZDkwNjY1MTE4MWJkYWNmYmQzYzVhMDk4Nzg3YjNmNThjMjc1ZWNjNDQzODFkOGNjNmU2ODAyNDFiZTRiODIwZjlkMDUyNTAyODk1ODZhYjM1NTRlMDJjYjhmZDlmNzIyNjM0NDMzZDBiZmNjMzg5NGU2ZDJmNGFiNGVlNGY0MzljMSJ9',
|
||||
// 'x-t': '1746022429225',
|
||||
// };
|
||||
console.log('sign', sign);
|
||||
const baseURL = 'https://edith.xiaohongshu.com';
|
||||
const xhsMeUri = baseURL + '/api/sns/web/v2/user/me';
|
||||
const res = await fetch(xhsMeUri, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
...headers,
|
||||
...sign,
|
||||
},
|
||||
});
|
||||
const data = await res.json();
|
||||
return data;
|
||||
};
|
||||
getUserMe().then((res) => {
|
||||
console.log('res', res);
|
||||
});
|
||||
|
||||
export async function getUnread() {
|
||||
const unreadUri = '/api/sns/web/unread_count';
|
||||
const sign = await getSign(unreadUri, null, a1, web_session);
|
||||
console.log('sign', sign);
|
||||
const res = await fetch(unreadUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
...headers,
|
||||
...sign,
|
||||
},
|
||||
});
|
||||
const data = await res.json();
|
||||
return data;
|
||||
}
|
||||
// getUnread().then((res) => {
|
||||
// console.log('res', res);
|
||||
// });
|
||||
15
packages/app-assistant/tsconfig.json
Normal file
15
packages/app-assistant/tsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": "@kevisual/types/json/backend.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
],
|
||||
"exclude": [],
|
||||
}
|
||||
Reference in New Issue
Block a user