🐛 修复部分帖子获取内容异常

This commit is contained in:
BTMuli
2026-01-04 15:38:59 +08:00
parent 2c451c3c01
commit 5834eee6fc
3 changed files with 15 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
/**
* 帖子相关的请求
* @since Beta v0.8.7
* @since Beta v0.9.1
*/
import { getRequestHeader } from "@utils/getRequestHeader.js";
import TGHttp from "@utils/TGHttp.js";
@@ -11,7 +11,7 @@ const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
/**
* 获取单个帖子信息
* @since Beta v0.7.9
* @since Beta v0.9.1
* @param postId - 帖子 ID
* @param cookie - Cookie
* @returns 帖子信息
@@ -21,13 +21,10 @@ async function getPostFull(
cookie?: Record<string, string>,
): Promise<TGApp.BBS.Post.FullData | TGApp.BBS.Response.Base> {
const param = { post_id: postId, read: 1 };
let header;
if (cookie !== undefined) {
header = {
...getRequestHeader(cookie, "GET", param, "K2", true),
"x-rpc-client_type": "2",
};
} else header = { referer: Referer, cookie: "" };
const header = {
...getRequestHeader(cookie ?? {}, "GET", param, "K2", true),
"x-rpc-client_type": "2",
};
const resp = await TGHttp<TGApp.BBS.Post.FullResp>(`${bapBu}getPostFull`, {
method: "GET",
headers: header,

View File

@@ -1,26 +1,26 @@
/**
* 关于 BBS 的工具函数
* @since Beta v0.8.4
* @since Beta v0.9.1
*/
/**
* salt 类型
* @since Beta v0.8.4
* @since Beta v0.9.1
*/
export type SaltKey = "K2" | "LK2" | "X4" | "X6" | "PROD";
const BBS_VERSION: Readonly<string> = "2.95.1";
const BBS_VERSION: Readonly<string> = "2.99.1";
const BBS_UA_MOBILE: Readonly<string> = `Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBS/${BBS_VERSION}`;
const BBS_UA_PC: Readonly<string> = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/${BBS_VERSION}`;
/**
* salt 值
* @since Beta v0.8.4
* @remarks 2.95.1
* @since Beta v0.9.1
* @remarks 2.99.1
*/
const BBS_SALT: Readonly<Record<SaltKey, string>> = {
K2: "sfYPEgpxkOe1I3XVMLdwp1Lyt9ORgZsq",
LK2: "sidQFEglajEz7FA0Aj7HQPV88zpf17SO",
K2: "b0EofkfMKq2saWV9fwux18J5vzcFTlex",
LK2: "DlOUwIupfU6YespEUWDJmXtutuXV6owG",
X4: "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
X6: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
PROD: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",