This commit is contained in:
2025-05-02 15:39:44 +08:00
parent e58adbc46b
commit ee483aa87e
32 changed files with 919 additions and 621 deletions

View File

@@ -0,0 +1,89 @@
import { app, xhsServices } from '@/app.ts';
app
.route({
path: 'mention',
key: 'getUnread',
description: '获取提及列表',
})
.define(async (ctx) => {
//
const client = xhsServices.getClient();
const res = await client.getUnread();
if (res.code === 0) {
const unread_count = res.data.unread_count;
ctx.body = res.data;
} else {
ctx.body = {
unread_count: 0,
};
}
})
.addTo(app);
app
.route({
path: 'mention',
key: 'getNote',
description: '获取笔记',
validator: {
node_id: {
type: 'string',
required: true,
},
xsec_token: {
type: 'string',
required: true,
},
},
isDebug: true,
})
.define(async (ctx) => {
const node_id = ctx.query.node_id;
const xsec_token = ctx.query.xsec_token;
const client = xhsServices.getClient();
try {
console.log('get note by node_id', node_id, 'xsec_token', xsec_token);
const res = await client.getNoteByIdFromHtml(node_id, xsec_token);
console.log('res====', res);
ctx.body = res;
} catch (error) {
console.log('res', error);
ctx.throw(500, '获取笔记失败');
}
})
.addTo(app);
app
.route({
path: 'mention',
key: 'addComment',
})
.define(async (ctx) => {
const { node_id, comment_id, content } = ctx.query;
const client = xhsServices.getClient();
const res = await client.postComment({
note_id: node_id,
comment_id: comment_id,
content,
});
ctx.body = res.data;
})
.addTo(app);
app
.route({
path: 'mention',
key: 'getMention',
description: '获取提及列表',
validator: {
num: {
type: 'number',
required: true,
},
},
})
.define(async (ctx) => {
const num = ctx.query.num;
const client = xhsServices.getClient();
const res = await client.getMention(num);
ctx.body = res.data;
})
.addTo(app);