🧪 测试获取合集信息失败

This commit is contained in:
目棃
2025-03-28 11:10:15 +08:00
parent 211f689426
commit 1d8e7ec35d
4 changed files with 46 additions and 29 deletions

View File

@@ -26,13 +26,14 @@ import TOverlay from "@comp/app/t-overlay.vue";
import TPostcard from "@comp/app/t-postcard.vue";
import { nextTick, onMounted, shallowRef, useTemplateRef, watch } from "vue";
// import bbsReq from "@/web/request/bbsReq.js";
import bbsReq from "@/web/request/bbsReq.js";
import postReq from "@/web/request/postReq.js";
type TpoCollectionProps = { collection: TGApp.BBS.Post.Collection; gid: number };
const props = defineProps<TpoCollectionProps>();
const visible = defineModel<boolean>();
const info = shallowRef<TGApp.BBS.Collection.InfoRes>();
const postList = shallowRef<Array<TGApp.BBS.Post.FullData>>([]);
const postListEl = useTemplateRef<HTMLDivElement>("postListRef");
@@ -49,11 +50,23 @@ watch(
},
);
onMounted(async () => {
onMounted(async () => await Promise.all([refreshInfo(), refreshPosts()]));
async function refreshInfo(): Promise<void> {
const infoResp = await bbsReq.collection(props.collection.collection_id, props.gid);
if ("retcode" in infoResp) {
// showSnackbar.warn(`[合集信息][${infoResp.retcode}] ${infoResp.message}`);
return;
}
info.value = infoResp;
console.log(info.value);
}
async function refreshPosts(): Promise<void> {
postList.value = await postReq.collection(props.collection.collection_id);
});
}
</script>
<style lang="css" scoped>
<style lang="scss" scoped>
.tpoc-box {
padding: 10px;
border-radius: 5px;

View File

@@ -1,7 +1,7 @@
/**
* @file utils/TGClient.ts
* @desc 负责米游社客户端的 callback 处理
* @since Beta v0.7.2
* @since Beta v0.7.3
*/
import showSnackbar from "@comp/func/snackbar.js";
@@ -586,13 +586,13 @@ class Client {
/**
* @func getDS
* @since Beta v0.3.9
* @since Beta v0.7.3
* @desc 获取米游社客户端的 DS 参数
* @param {TGApp.Plugins.JSBridge.NullArg} arg - 方法参数
* @returns {void} - 无返回值
*/
async getDS(arg: TGApp.Plugins.JSBridge.NullArg): Promise<void> {
const data = { DS: getDS4JS("LK2", 1, undefined, undefined) };
const data = { DS: getDS4JS("LK2", 1) };
await this.callback(arg.callback, data);
}

View File

@@ -1,22 +1,24 @@
/**
* @file web/request/bbsReq.ts
* @description BBS 请求模块
* @since Beta v0.7.2
* @since Beta v0.7.3
*/
import TGHttp from "@/utils/TGHttp.js";
import { getRequestHeader } from "@/web/utils/getRequestHeader.js";
// MysBBSBaseUrl => mbBu
const mbBu: Readonly<string> = "https://bbs-api.miyoushe.com/";
/**
* @description 获取表情包列表
* @since Beta v0.7.2
* @since Beta v0.7.3
* @return {Promise<Record<string,string>|TGApp.BBS.Response.Base>}
*/
async function getEmoticonSet(): Promise<Record<string, string> | TGApp.BBS.Response.Base> {
const resp = await TGHttp<TGApp.BBS.Emoji.Resp>(
"https://bbs-api-static.miyoushe.com/misc/api/emoticon_set",
{ method: "GET" },
);
const resp = await TGHttp<TGApp.BBS.Emoji.Resp>(`${mbBu}misc/api/emoticon_set`, {
method: "GET",
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
const emojis: Record<string, string> = {};
for (const series of resp.data.list) {
@@ -38,10 +40,11 @@ async function getUserFullInfo(
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.User.Info> {
const ck = { cookie_token: cookie.cookie_token, account_id: cookie.account_id };
const params = { gids: "2" };
const resp = await TGHttp<TGApp.BBS.User.InfoResp>(
"https://bbs-api.miyoushe.com/user/wapi/getUserFullInfo",
{ method: "GET", headers: getRequestHeader(ck, "GET", params, "X4", true), query: params },
);
const resp = await TGHttp<TGApp.BBS.User.InfoResp>(`${mbBu}user/wapi/getUserFullInfo`, {
method: "GET",
headers: getRequestHeader(ck, "GET", params, "X4", true),
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data.user_info;
}
@@ -58,20 +61,21 @@ async function getOtherUserInfo(
userId: string,
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.User.Info> {
const params = { gids: gid.toString(), uid: userId };
const resp = await TGHttp<TGApp.BBS.User.InfoResp>(
"https://bbs-api.miyoushe.com/user/wapi/getUserFullInfo",
{ method: "GET", headers: getRequestHeader({}, "GET", params, "X4", true), query: params },
);
const resp = await TGHttp<TGApp.BBS.User.InfoResp>(`${mbBu}user/wapi/getUserFullInfo`, {
method: "GET",
headers: getRequestHeader({}, "GET", params, "X4", true),
query: params,
});
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
return resp.data.user_info;
}
/**
* @description 获取合集信息
* @since Beta v0.7.2
* @todo invalid request
* @param {number} gid - gid
* @since Beta v0.7.3
* @todo salt计算异常
* @param {string} cid - 合集 id
* @param {number} gid - gid
* @returns {Promise<TGApp.BBS.Collection.InfoRes|TGApp.BBS.Response.Base>}
*/
async function getCollectionDetail(
@@ -80,7 +84,7 @@ async function getCollectionDetail(
): Promise<TGApp.BBS.Collection.InfoRes | TGApp.BBS.Response.Base> {
const params = { gids: gid, id: cid };
const resp = await TGHttp<TGApp.BBS.Collection.InfoResp>(
"https://bbs-api.miyoushe.com/collection/wapi/collection/detail",
`${mbBu}collection/wapi/collection/detail`,
{
method: "GET",
headers: getRequestHeader({}, "GET", params, "X4", true),

View File

@@ -127,19 +127,19 @@ export function getRequestHeader(
/**
* @description 获取 DS
* @since Beta v0.3.9
* @since Beta v0.7.3
* @param {SaltKey} saltType salt 类型
* @param {number} dsType ds 类型
* @param {Record<string, string|number>|string} body
* @param {Record<string, string|number>|string} query
* @returns {string} DS
*/
export function getDS4JS(saltType: SaltKey, dsType: 1, body: undefined, query: undefined): string;
export function getDS4JS(saltType: SaltKey, dsType: 1, body?: never, query?: never): string;
export function getDS4JS(
saltType: SaltKey,
dsType: 2,
body: Record<string, string | number> | string,
query: Record<string, string | number> | string,
body?: Record<string, string | number> | string,
query?: Record<string, string | number> | string,
): string;
export function getDS4JS(
saltType: SaltKey,