generated from tailored/router-template
feat: add summary
This commit is contained in:
@@ -38,6 +38,7 @@ export const getSign = async (signInfo: SignInfo, options?: SignOptions): Promis
|
||||
// signUrl = 'http://localhost:5005/sign';
|
||||
// const urlA1 = ''http://light.xiongxiao.me:5006/a1';
|
||||
// const urlA1 = 'http://localhost:5005/a1';
|
||||
// console.log('sign', signUrl);
|
||||
const signs = await fetch(signUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -215,6 +216,7 @@ export class XhsClient extends XhsClientBase {
|
||||
|
||||
try {
|
||||
const response = await this.post(uri, data, { sign: this.sign.bind(this) });
|
||||
console.log('getNoteById response', response, typeof response);
|
||||
// return response['items'][0]['node_card'];
|
||||
return response;
|
||||
} catch (error) {
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
import './mentions/index.ts'
|
||||
import './mentions/index.ts'
|
||||
import './notes/index.ts'
|
||||
@@ -7,8 +7,8 @@ app
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const client = xhsServices.getClient();
|
||||
const res = await client.c
|
||||
if (res.code === 0) {
|
||||
}
|
||||
// const res = await client.getNote({});
|
||||
// if (res.code === 0) {
|
||||
// }
|
||||
})
|
||||
.addTo(app);
|
||||
|
||||
18
packages/xhs/src/routes/notes/get-note.ts
Normal file
18
packages/xhs/src/routes/notes/get-note.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { app, xhsServices } from '@kevisual/xhs/app.ts';
|
||||
app
|
||||
.route({
|
||||
path: 'note',
|
||||
key: 'getNote',
|
||||
description: '获取笔记详情',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const { node_id, xsec_token } = ctx.query;
|
||||
const client = xhsServices.getClient();
|
||||
const res = await client.getNote(node_id, xsec_token);
|
||||
if (res.code === 200) {
|
||||
ctx.body = res.data || {};
|
||||
} else {
|
||||
ctx.throw(`获取笔记失败: ${node_id}`);
|
||||
}
|
||||
})
|
||||
.addTo(app);
|
||||
@@ -1 +1,2 @@
|
||||
import './create-note.ts'
|
||||
import './create-note.ts'
|
||||
import './get-note.ts'
|
||||
@@ -104,6 +104,16 @@ export class XhsServices {
|
||||
}
|
||||
return user.userid === xhsUserInfo.userid;
|
||||
}
|
||||
isReplayAi(data: any, key?: string) {
|
||||
const mention = data?.mention || {};
|
||||
const user_info = mention?.comment_info?.target_comment?.user_info || {};
|
||||
if (user_info?.userid) {
|
||||
const xhsUserInfo = this.getXhsUserInfo(key);
|
||||
// 处理用户信息
|
||||
return user_info.userid === xhsUserInfo.userid;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
setCookie(cookie: string, key?: string) {
|
||||
const xhsClient = this.map.get(this.getKey(key));
|
||||
if (xhsClient) {
|
||||
@@ -123,4 +133,17 @@ export class XhsServices {
|
||||
xhsClient.options.username = user.username;
|
||||
}
|
||||
}
|
||||
|
||||
setSignConfig(signConfig: { signUrl: string }, key?: string) {
|
||||
const xhsClient = this.map.get(this.getKey(key));
|
||||
if (xhsClient) {
|
||||
xhsClient.options.signConfig = signConfig;
|
||||
xhsClient.client.signConfig = signConfig;
|
||||
}
|
||||
console.log('setSignConfig', xhsClient?.options?.signConfig);
|
||||
}
|
||||
getSignConfig(key?: string) {
|
||||
const xhsClient = this.map.get(this.getKey(key));
|
||||
return xhsClient?.options?.signConfig || {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,17 +8,27 @@ import util from 'node:util';
|
||||
// });
|
||||
const getNoteById = async () => {
|
||||
const client = xhsServices.getClient();
|
||||
client.getNoteById('68136dab0000000007034c46', 'LByEmonX8WfJ9ebpAowVbOZX9Xh8T0Qkjil5KRFqDD6LM').then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
// client.getNoteById('68136dab0000000007034c46', 'LByEmonX8WfJ9ebpAowVbOZX9Xh8T0Qkjil5KRFqDD6LM').then((res) => {
|
||||
// console.log(res);
|
||||
// });
|
||||
|
||||
const res = await client.getNoteById('68136dab0000000007034c46', 'LB6fmNfsd0keAQNjh3zOejDC2TVQLGY3zlTZjeRazBZdI=');
|
||||
// console.log(res);
|
||||
};
|
||||
const getNote = async () => {
|
||||
// const id = '68136dab0000000007034c46';
|
||||
// const x = 'LByEmonX8WfJ9ebpAowVbOZX9Xh8T0Qkjil5KRFqDD6LM=';
|
||||
const id = '68136dab0000000007034c46';
|
||||
const x = 'LByEmonX8WfJ9ebpAowVbOZX9Xh8T0Qkjil5KRFqDD6LM=';
|
||||
const x = 'LB6fmNfsd0keAQNjh3zOejDC2TVQLGY3zlTZjeRazBZdI=';
|
||||
const client = xhsServices.getClient();
|
||||
client.getNote(id, x).then((res) => {
|
||||
const res = await client.getNote(id, x).then((res) => {
|
||||
console.log(util.inspect(res, { depth: null }));
|
||||
return res;
|
||||
});
|
||||
console.log('type res', typeof res);
|
||||
if (res.code === 0) {
|
||||
console.log('desc', res.data.desc);
|
||||
}
|
||||
};
|
||||
program
|
||||
.command('get-note')
|
||||
|
||||
Reference in New Issue
Block a user