generated from tailored/router-db-template
temp
This commit is contained in:
68
packages/xhs/src/libs/modules/get-note.ts
Normal file
68
packages/xhs/src/libs/modules/get-note.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { XhsClient, Result } from '../xhs.ts';
|
||||
interface ImageInfo {
|
||||
image_scene: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
interface ImageItem {
|
||||
file_id: string;
|
||||
height: number;
|
||||
width: number;
|
||||
url: string;
|
||||
trace_id: string;
|
||||
url_pre: string;
|
||||
stream: Record<string, never>; // 空对象类型
|
||||
info_list: ImageInfo[];
|
||||
url_default: string;
|
||||
live_photo: boolean;
|
||||
}
|
||||
|
||||
interface AtUser {
|
||||
xsec_token: string;
|
||||
user_id: string;
|
||||
nickname: string;
|
||||
}
|
||||
|
||||
interface User {
|
||||
user_id: string;
|
||||
nickname: string;
|
||||
avatar: string;
|
||||
xsec_token: string;
|
||||
}
|
||||
|
||||
interface InteractInfo {
|
||||
collected_count: string;
|
||||
comment_count: string;
|
||||
share_count: string;
|
||||
followed: boolean;
|
||||
relation: string;
|
||||
liked: boolean;
|
||||
liked_count: string;
|
||||
collected: boolean;
|
||||
}
|
||||
|
||||
interface ShareInfo {
|
||||
un_share: boolean;
|
||||
}
|
||||
|
||||
interface NoteData {
|
||||
xsec_token: string;
|
||||
desc: string;
|
||||
user: User;
|
||||
interact_info: InteractInfo;
|
||||
tag_list: never[]; // 空数组类型
|
||||
at_user_list: AtUser[];
|
||||
ip_location: string;
|
||||
share_info: ShareInfo;
|
||||
note_id: string;
|
||||
type: string;
|
||||
title: string;
|
||||
image_list: ImageItem[];
|
||||
time: number;
|
||||
last_update_time: number;
|
||||
}
|
||||
export const getNote = async function (id: string, x: string) {
|
||||
const that = this as XhsClient;
|
||||
const res = await that.getNoteByIdFromHtml(id, x);
|
||||
return res as Result<NoteData>;
|
||||
};
|
||||
@@ -2,6 +2,7 @@ import { getApiInfo } from './xhs-api/api.ts';
|
||||
import { XhsClient as XhsClientBase } from '@kevisual/xhs-core';
|
||||
import { Mention, CommonentInfo, ResponseMession } from './xhs-type/mention.ts';
|
||||
import { pick } from 'lodash-es';
|
||||
import { getNote } from './modules/get-note.ts';
|
||||
export type Result<T> = {
|
||||
code: number; // 0: success
|
||||
msg?: string;
|
||||
@@ -211,7 +212,8 @@ export class XhsClient extends XhsClientBase {
|
||||
|
||||
try {
|
||||
const response = await this.post(uri, data, { sign: this.sign.bind(this) });
|
||||
return response['items'][0]['node_card'];
|
||||
// return response['items'][0]['node_card'];
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -221,7 +223,7 @@ export class XhsClient extends XhsClientBase {
|
||||
* @param comment
|
||||
* @returns
|
||||
*/
|
||||
async postComment(comment: { note_id: string; comment_id?: string; content: string; images_info?: any, images?: string[] }) {
|
||||
async postComment(comment: { note_id: string; comment_id?: string; content: string; images_info?: any; images?: string[] }) {
|
||||
const uri = '/api/sns/web/v1/comment/post';
|
||||
try {
|
||||
const data = {
|
||||
@@ -249,6 +251,7 @@ export class XhsClient extends XhsClientBase {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
getNote = getNote;
|
||||
}
|
||||
|
||||
type UnreadCount = {
|
||||
|
||||
Reference in New Issue
Block a user