♻️ 迁移apiHubReq

This commit is contained in:
BTMuli
2026-04-15 00:47:38 +08:00
parent b3b683811a
commit 0ed52ff963
9 changed files with 249 additions and 162 deletions

View File

@@ -71,7 +71,12 @@ watch(
async function loadNav(): Promise<void> {
try {
const resp = await apiHubReq.home(props.gid);
nav.value = resp.data.data.navigator;
if (resp.retcode !== 0) {
showSnackbar.error(`加载导航失败:[${resp.retcode}] ${resp.message}`);
await TGLogger.Warn(`[TGameNav][loadNav] 加载导航失败:${resp.retcode} ${resp.message}`);
return;
}
nav.value = resp.data.navigator;
if (loadCode.value) loadCode.value = false;
} catch (e) {
const errMsg = TGHttps.getErrMsg(e);

View File

@@ -232,12 +232,16 @@ async function tryAuto(skip: boolean = false): Promise<void> {
for (const post of listResp.data.list) {
if (!isShare) {
await TGLogger.Script(`[米游币任务]正在分享帖子${post.post.post_id}`);
const shareResp = await apiHubReq.post.share(post.post.post_id, ckShare);
if (shareResp.retcode === 0) {
await TGLogger.Script("[米游币任务]分享成功");
isShare = true;
} else {
await TGLogger.Script(`[米游币任务]分享失败:${shareResp.retcode} ${shareResp.message}`);
try {
const shareResp = await apiHubReq.post.share(post.post.post_id, ckShare);
if (shareResp.retcode === 0) {
await TGLogger.Script("[米游币任务]分享成功");
isShare = true;
} else {
await TGLogger.Script(`[米游币任务]分享失败:${shareResp.retcode} ${shareResp.message}`);
}
} catch (e) {
await TGLogger.Script(`[米游币任务]分享异常:${TGHttps.getErrMsg(e)}`, "error");
}
}
if (likeCnt < 5 || viewCnt < 3) {
@@ -270,24 +274,33 @@ async function tryAuto(skip: boolean = false): Promise<void> {
continue;
}
await TGLogger.Script(`[米游币任务]正在点赞帖子${post.post.post_id}`);
const likeResp = await apiHubReq.post.like(post.post.post_id, ckPost);
if (likeResp.retcode === 0) {
await TGLogger.Script("[米游币任务]点赞成功");
likeCnt++;
} else {
await TGLogger.Script(`[米游币任务]点赞失败:${likeResp.retcode} ${likeResp.message}`);
try {
const likeResp = await apiHubReq.post.like(post.post.post_id, ckPost);
if (likeResp.retcode === 0) {
await TGLogger.Script("[米游币任务]点赞成功");
likeCnt++;
} else {
await TGLogger.Script(`[米游币任务]点赞失败:${likeResp.retcode} ${likeResp.message}`);
continue;
}
} catch (e) {
await TGLogger.Script(`[米游币任务]点赞异常:${TGHttps.getErrMsg(e)}`, "error");
continue;
}
if (cancelLike.value) {
await TGLogger.Script(`[米游币任务]正在取消点赞帖子${post.post.post_id}`);
await new Promise<void>((resolve) => setTimeout(resolve, 1000));
const unlikeResp = await apiHubReq.post.like(post.post.post_id, ckPost, true);
if (unlikeResp.retcode === 0) {
await TGLogger.Script("[米游币任务]取消点赞成功");
} else {
await TGLogger.Script(
`[米游币任务]取消点赞失败:${unlikeResp.retcode} ${unlikeResp.message}`,
);
try {
const unlikeResp = await apiHubReq.post.like(post.post.post_id, ckPost, true);
if (unlikeResp.retcode === 0) {
await TGLogger.Script("[米游币任务]取消点赞成功");
} else {
await TGLogger.Script(
`[米游币任务]取消点赞失败:${unlikeResp.retcode} ${unlikeResp.message}`,
);
}
} catch (e) {
await TGLogger.Script(`[米游币任务]取消点赞异常:${TGHttps.getErrMsg(e)}`, "error");
}
}
}
@@ -309,35 +322,46 @@ async function refreshState(ck: TGApp.App.Account.Cookie): Promise<void> {
await TGLogger.Script("[米游币任务]刷新任务状态");
if (missionList.value.length === 0) {
await TGLogger.Script("[米游币任务]未检测到任务列表,正在获取");
const listResp = await apiHubReq.mission.list(ckState);
console.log("米游币任务列表", listResp);
if (listResp.retcode !== 0) {
await TGLogger.Script(
`[米游币任务]获取任务列表失败:${listResp.retcode} ${listResp.message}`,
);
showSnackbar.error(`[${listResp.retcode}] ${listResp.message}`);
try {
const listResp = await apiHubReq.mission.list(ckState);
console.log("米游币任务列表", listResp);
if (listResp.retcode !== 0) {
await TGLogger.Script(
`[米游币任务]获取任务列表失败:${listResp.retcode} ${listResp.message}`,
"warn",
);
showSnackbar.error(`[${listResp.retcode}] ${listResp.message}`);
return;
}
missionList.value = listResp.data.missions;
await TGLogger.Script("[米游币任务]获取任务列表成功");
} catch (e) {
await TGLogger.Script(`[米游币任务]获取任务列表异常:${TGHttps.getErrMsg(e)}`, "error");
return;
}
missionList.value = listResp.data.missions;
await TGLogger.Script("[米游币任务]获取任务列表成功");
}
await TGLogger.Script("[米游币任务]正在获取任务状态");
const stateResp = await apiHubReq.mission.state(ckState);
console.log("米游币任务状态", stateResp);
if (stateResp.retcode !== 0) {
await TGLogger.Script(
`[米游币任务]获取任务状态失败:${stateResp.retcode} ${stateResp.message}`,
);
showSnackbar.error(`[${stateResp.retcode}] ${stateResp.message}`);
return;
try {
const stateResp = await apiHubReq.mission.state(ckState);
console.log("米游币任务状态", stateResp);
if (stateResp.retcode !== 0) {
await TGLogger.Script(
`[米游币任务]获取任务状态失败:${stateResp.retcode} ${stateResp.message}`,
"warn",
);
showSnackbar.error(`[${stateResp.retcode}] ${stateResp.message}`);
return;
}
await TGLogger.Script("[米游币任务]获取任务状态成功");
todayPoints.value = stateResp.data.already_received_points;
totalPoints.value = stateResp.data.today_total_points;
userPoints.value = stateResp.data.total_points;
await TGLogger.Script("[米游币任务]合并任务数据");
mergeMission(missionList.value, stateResp.data.states);
await TGLogger.Script("[米游币任务]任务数据合并完成");
} catch (e) {
await TGLogger.Script(`[米游币任务]获取任务状态异常:${TGHttps.getErrMsg(e)}`, "error");
}
await TGLogger.Script("[米游币任务]获取任务状态成功");
todayPoints.value = stateResp.data.already_received_points;
totalPoints.value = stateResp.data.today_total_points;
userPoints.value = stateResp.data.total_points;
await TGLogger.Script("[米游币任务]合并任务数据");
mergeMission(missionList.value, stateResp.data.states);
await TGLogger.Script("[米游币任务]任务数据合并完成");
}
async function autoSign(ck: TGApp.App.Account.Cookie, skip: boolean, ch?: string): Promise<void> {
@@ -352,8 +376,14 @@ async function autoSign(ck: TGApp.App.Account.Cookie, skip: boolean, ch?: string
}
await TGLogger.Script("[米游币任务]正在执行打卡");
const ckSign = { stoken: ck.stoken, stuid: ck.stuid, mid: ck.mid };
const resp = await apiHubReq.sign(ckSign, 2, ch);
console.log("打卡情况", resp);
let resp: TGApp.BBS.Response.Base;
try {
resp = await apiHubReq.sign(ckSign, 2, ch);
console.log("打卡情况", resp);
} catch (e) {
await TGLogger.Script(`[米游币任务]打卡异常:${TGHttps.getErrMsg(e)}`, "error");
return;
}
if (resp.retcode !== 0) {
if (resp.retcode !== 1034) {
await TGLogger.Script(`[米游币任务]打卡失败:${resp.retcode} ${resp.message}`);

View File

@@ -27,6 +27,8 @@
</template>
<script lang="ts" setup>
import ApiHubReq from "@req/apiHubReq.js";
import TGHttps from "@utils/TGHttps.js";
import TGLogger from "@utils/TGLogger.js";
import { timestampToDate } from "@utils/toolFunc.js";
import { onMounted, ref, shallowRef } from "vue";
@@ -75,18 +77,41 @@ console.log("tp-vote:", props.data);
onMounted(async () => {
const vote = props.data.insert.vote;
const voteInfo = await ApiHubReq.vote.info(vote.id, vote.uid);
console.log(`[${props.data.insert.vote.id}]voteInfo:`, voteInfo);
const voteResult = await ApiHubReq.vote.result(vote.id, vote.uid);
console.log(`[${props.data.insert.vote.id}]voteResult:`, voteResult);
let voteInfo: TGApp.BBS.Vote.Info | undefined;
let voteResult: TGApp.BBS.Vote.Result | undefined;
try {
const infoResp = await ApiHubReq.vote.info(vote.id, vote.uid);
if (infoResp.retcode !== 0) {
await TGLogger.Warn(`[TpVote] 获取投票信息失败:${infoResp.retcode} ${infoResp.message}`);
return;
}
voteInfo = infoResp.data.data[0];
console.log(`[${props.data.insert.vote.id}]voteInfo:`, voteInfo);
} catch (e) {
await TGLogger.Error(`[TpVote] 获取投票信息异常:${TGHttps.getErrMsg(e)}`);
return;
}
try {
const resultResp = await ApiHubReq.vote.result(vote.id, vote.uid);
if (resultResp.retcode !== 0) {
await TGLogger.Warn(`[TpVote] 获取投票结果失败:${resultResp.retcode} ${resultResp.message}`);
return;
}
voteResult = resultResp.data.data[0];
console.log(`[${props.data.insert.vote.id}]voteResult:`, voteResult);
} catch (e) {
await TGLogger.Error(`[TpVote] 获取投票结果异常:${TGHttps.getErrMsg(e)}`);
return;
}
if (!voteInfo || !voteResult) return;
votes.value = {
title: voteInfo.title,
count: voteResult.user_cnt,
is_over: voteResult.is_over,
data: voteInfo.vote_option_indexes.map((item, index) => ({
title: item,
count: voteResult.option_stats[index] ?? 0,
percent: ((voteResult.option_stats[index] ?? 0) / voteResult.user_cnt) * 100,
count: voteResult!.option_stats[index] ?? 0,
percent: ((voteResult!.option_stats[index] ?? 0) / voteResult!.user_cnt) * 100,
})),
endTime: timestampToDate(voteInfo.end_time * 1000),
};

View File

@@ -1,10 +1,9 @@
/**
* apiHub下的请求
* @since Beta v0.9.9
* @since Beta v0.10.1
*/
import { getRequestHeader } from "@utils/getRequestHeader.js";
import TGHttp from "@utils/TGHttp.js";
import TGHttps from "@utils/TGHttps.js";
// MysApiHubBaseUrl => Mahbu
@@ -13,74 +12,66 @@ const Referer: Readonly<string> = "https://bbs.mihoyo.com/";
/**
* 获取所有版块
* @since Beta v0.6.8
* @returns 版块信息
* @since Beta v0.10.1
* @returns 版块信息响应数据
*/
async function getAllGamesForums(): Promise<Array<TGApp.BBS.Forum.GameForum>> {
return (
await TGHttp<TGApp.BBS.Forum.GameForumResp>(`${Mahbu}wapi/getAllGamesForums`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
})
).data.list;
async function getAllGamesForums(): Promise<TGApp.BBS.Forum.GameForumResp> {
const resp = await TGHttps.get<TGApp.BBS.Forum.GameForumResp>(`${Mahbu}wapi/getAllGamesForums`, {
headers: { "Content-Type": "application/json", referer: Referer },
});
return resp.data;
}
/**
* 获取应用配置
* @since Beta v0.8.2
* @since Beta v0.10.1
* @param gid - 分区ID
* @returns 应用配置
* @returns 应用配置响应数据
*/
async function getAppConfig(
gid?: string,
): Promise<TGApp.BBS.AppConfig.FullData | TGApp.BBS.Response.Base> {
let url = `${Mahbu}api/getAppConfig`;
if (gid) url += `?gid=${gid}`;
const resp = await TGHttp<TGApp.BBS.AppConfig.Resp | TGApp.BBS.Response.Base>(url, {
method: "GET",
async function getAppConfig(gid?: string): Promise<TGApp.BBS.AppConfig.Resp> {
const query = gid ? { gid } : undefined;
const resp = await TGHttps.get<TGApp.BBS.AppConfig.Resp>(`${Mahbu}api/getAppConfig`, {
headers: { "Content-Type": "application/json", referer: Referer },
query,
});
if (resp.retcode === 0) return resp.data.config;
return <TGApp.BBS.Response.Base>resp;
return resp.data;
}
/**
* 获取所有分区
* @since Beta v0.6.8
* @returns 分区信息
* @since Beta v0.10.1
* @returns 分区信息响应数据
*/
async function getGameList(): Promise<Array<TGApp.BBS.Game.Item>> {
return (
await TGHttp<TGApp.BBS.Game.ListResp>(`${Mahbu}wapi/getGameList`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
})
).data.list;
async function getGameList(): Promise<TGApp.BBS.Game.ListResp> {
const resp = await TGHttps.get<TGApp.BBS.Game.ListResp>(`${Mahbu}wapi/getGameList`, {
headers: { "Content-Type": "application/json", referer: Referer },
});
return resp.data;
}
/**
* 获取用户米游币任务列表
* @since Beta v0.7.2
* @since Beta v0.10.1
* @param cookie - 用户 Cookie
* @returns 用户米游币任务列表
* @returns 用户米游币任务列表响应数据
*/
async function getMissions(cookie: Record<string, string>): Promise<TGApp.BBS.Mission.InfoResp> {
const param = { point_sn: "myb" };
const header = getRequestHeader(cookie, "GET", param);
return await TGHttp<TGApp.BBS.Mission.InfoResp>(`${Mahbu}wapi/getMissions`, {
method: "GET",
const resp = await TGHttps.get<TGApp.BBS.Mission.InfoResp>(`${Mahbu}wapi/getMissions`, {
headers: header,
query: param,
});
return resp.data;
}
/**
* 获取分享配置
* @since Beta v0.7.0
* @since Beta v0.10.1
* @remarks **需要验证码登录返回的 Cookie**
* @param postId - 帖子 ID
* @param cookie - 用户 Cookie
* @returns 基础响应
* @returns 基础响应数据
*/
async function getShareConf(
postId: string,
@@ -91,90 +82,84 @@ async function getShareConf(
...getRequestHeader(cookie, "GET", params, "K2", true),
"x-rpc-client_type": "2",
};
return await TGHttp<TGApp.BBS.Response.Base>(`${Mahbu}api/getShareConf`, {
method: "GET",
const resp = await TGHttps.get<TGApp.BBS.Response.Base>(`${Mahbu}api/getShareConf`, {
headers: header,
query: params,
});
return resp.data;
}
/**
* 获取用户米游币任务完成状态
* @since Beta v0.7.2
* @since Beta v0.10.1
* @remarks **需要验证码登录的 Cookie**
* @param cookie - 用户 Cookie
* @returns 米游币任务完成状态
* @returns 米游币任务完成状态响应数据
*/
async function getUserMissionsState(
cookie: Record<string, string>,
): Promise<TGApp.BBS.Mission.StateResp> {
const param = { point_sn: "myb" };
const header = getRequestHeader(cookie, "GET", param);
return await TGHttp<TGApp.BBS.Mission.StateResp>(`${Mahbu}wapi/getUserMissionsState`, {
method: "GET",
const resp = await TGHttps.get<TGApp.BBS.Mission.StateResp>(`${Mahbu}wapi/getUserMissionsState`, {
headers: header,
query: param,
});
return resp.data;
}
/**
* 获取投票信息
* @since Beta v0.6.2
* @since Beta v0.10.1
* @param id - 投票 ID
* @param uid - 用户 ID
* @returns 投票信息
* @returns 投票信息响应数据
*/
async function getVotes(id: string, uid: string): Promise<TGApp.BBS.Vote.Info> {
return (
await TGHttp<TGApp.BBS.Vote.InfoResp>(`${Mahbu}api/getVotes`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id },
})
).data.data[0];
async function getVotes(id: string, uid: string): Promise<TGApp.BBS.Vote.InfoResp> {
const resp = await TGHttps.get<TGApp.BBS.Vote.InfoResp>(`${Mahbu}api/getVotes`, {
headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id },
});
return resp.data;
}
/**
* 获取投票结果
* @since Beta v0.6.2
* @since Beta v0.10.1
* @param id - 投票 ID
* @param uid - 用户 ID
* @returns 投票结果
* @returns 投票结果响应数据
*/
async function getVoteResult(id: string, uid: string): Promise<TGApp.BBS.Vote.Result> {
return (
await TGHttp<TGApp.BBS.Vote.ResultResp>(`${Mahbu}api/getVotesResult`, {
method: "GET",
headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id },
})
).data.data[0];
async function getVoteResult(id: string, uid: string): Promise<TGApp.BBS.Vote.ResultResp> {
const resp = await TGHttps.get<TGApp.BBS.Vote.ResultResp>(`${Mahbu}api/getVotesResult`, {
headers: { "Content-Type": "application/json", referer: Referer },
query: { owner_uid: uid, vote_ids: id },
});
return resp.data;
}
/**
* 获取首页导航列表
* @since Beta v0.9.9
* @since Beta v0.10.1
* @param gid - GID
* @TODO 测试带ck请求
* @returns 首页导航列表
* @returns 首页导航列表响应数据
*/
async function homeNew(
gid: number = 2,
): Promise<TGApp.App.Response.Resp<TGApp.BBS.Navigator.HomeResp>> {
return await TGHttps.get<TGApp.BBS.Navigator.HomeResp>(`${Mahbu}api/home/new`, {
async function homeNew(gid: number = 2): Promise<TGApp.BBS.Navigator.HomeResp> {
const resp = await TGHttps.get<TGApp.BBS.Navigator.HomeResp>(`${Mahbu}api/home/new`, {
headers: { "x-rpc-client_type": "2" },
query: { gids: gid },
});
return resp.data;
}
/**
* 签到
* @since Beta v0.7.1
* @since Beta v0.10.1
* @remarks **需要验证码登录获取的 Cookie**
* @param cookie - 用户 Cookie
* @param gid - 分区ID
* @param challenge - 极验参数
* @returns 基础响应
* @returns 基础响应数据
*/
async function signIn(
cookie: Record<string, string>,
@@ -187,20 +172,20 @@ async function signIn(
"x-rpc-client_type": "2",
};
if (challenge) header = { ...header, "x-rpc-challenge": challenge };
return await TGHttp<TGApp.BBS.Response.Base>(`${Mahbu}app/api/signIn`, {
method: "POST",
const resp = await TGHttps.post<TGApp.BBS.Response.Base>(`${Mahbu}app/api/signIn`, {
headers: header,
body: JSON.stringify(data),
body: data,
});
return resp.data;
}
/**
* 点赞
* @since Beta v0.7.0
* @since Beta v0.10.1
* @param id - 帖子 ID
* @param cookie - 用户 Cookie
* @param cancel - 是否取消点赞
* @returns 基础响应
* @returns 基础响应数据
*/
async function upVotePost(
id: string,
@@ -212,11 +197,11 @@ async function upVotePost(
...getRequestHeader(cookie, "POST", data, "K2", true),
"x-rpc-client_type": "2",
};
return await TGHttp<TGApp.BBS.Response.Base>(`${Mahbu}api/upvotePost`, {
method: "POST",
const resp = await TGHttps.post<TGApp.BBS.Response.Base>(`${Mahbu}api/upvotePost`, {
headers: header,
body: JSON.stringify(data),
body: data,
});
return resp.data;
}
const apiHubReq = {

View File

@@ -1,8 +1,10 @@
/**
* 米社数据状态管理
* @since Beta v0.9.6
* @since Beta v0.10.1
*/
import apiHubReq from "@req/apiHubReq.js";
import TGHttps from "@utils/TGHttps.js";
import TGLogger from "@utils/TGLogger.js";
import { defineStore } from "pinia";
import { shallowRef } from "vue";
@@ -18,22 +20,47 @@ const useBBSStore = defineStore(
// 刷新游戏列表
async function refreshGameList(): Promise<void> {
gameList.value = await apiHubReq.game();
try {
const resp = await apiHubReq.game();
if (resp.retcode !== 0) {
await TGLogger.Warn(`[BBSStore] 获取游戏列表失败:${resp.retcode} ${resp.message}`);
return;
}
gameList.value = resp.data.list;
} catch (e) {
await TGLogger.Error(`[BBSStore] 获取游戏列表异常:${TGHttps.getErrMsg(e)}`);
}
}
// 刷新版块列表
async function refreshForumList(): Promise<void> {
forumList.value = await apiHubReq.forum();
try {
const resp = await apiHubReq.forum();
if (resp.retcode !== 0) {
await TGLogger.Warn(`[BBSStore] 获取版块列表失败:${resp.retcode} ${resp.message}`);
return;
}
forumList.value = resp.data.list;
} catch (e) {
await TGLogger.Error(`[BBSStore] 获取版块列表异常:${TGHttps.getErrMsg(e)}`);
}
}
// 刷新游戏卡片配置项
async function refreshGameUidCards(): Promise<void> {
const resp = await apiHubReq.appConfig();
if ("retcode" in resp) return;
const conf = <TGApp.BBS.AppConfig.GameUidCardConfigParse>(
JSON.parse(resp.game_uid_card_config)
);
gameUidCards.value = conf.game_uid_card_conf;
try {
const resp = await apiHubReq.appConfig();
if (resp.retcode !== 0) {
await TGLogger.Warn(`[BBSStore] 获取游戏卡片配置失败:${resp.retcode} ${resp.message}`);
return;
}
const conf = <TGApp.BBS.AppConfig.GameUidCardConfigParse>(
JSON.parse(resp.data.config.game_uid_card_config)
);
gameUidCards.value = conf.game_uid_card_conf;
} catch (e) {
await TGLogger.Error(`[BBSStore] 获取游戏卡片配置异常:${TGHttps.getErrMsg(e)}`);
}
}
return {

View File

@@ -1,18 +1,22 @@
/**
* 米社版块类型
* @since Beta v0.8.4
* @since Beta v0.10.1
*/
declare namespace TGApp.BBS.Forum {
/**
* 获取所有版块信息返回
* @since Beta v0.6.8
* 获取所有版块信息返回响应
* @since Beta v0.10.1
*/
type GameForumResp = TGApp.BBS.Response.BaseWithData & {
type GameForumResp = TGApp.BBS.Response.BaseWithData<GameForumRes>;
/**
* 获取所有版块信息返回数据
* @since Beta v0.10.1
*/
type GameForumRes = {
/** 所有版块信息 */
data: {
list: Array<GameForum>;
};
list: Array<GameForum>;
};
/**

View File

@@ -1,19 +1,22 @@
/**
* 游戏相关的类型定义
* @since Beta v0.7.2
* @since Beta v0.10.1
*/
declare namespace TGApp.BBS.Game {
/**
* 游戏列表返回
* @since Beta v0.6.8
* 游戏列表返回响应
* @since Beta v0.10.1
*/
type ListResp = TGApp.BBS.Response.BaseWithData & {
/** 游戏列表数据 */
data: {
/** 游戏列表 */
list: Array<Item>;
};
type ListResp = TGApp.BBS.Response.BaseWithData<ListRes>;
/**
* 游戏列表返回数据
* @since Beta v0.10.1
*/
type ListRes = {
/** 游戏列表 */
list: Array<Item>;
};
/**

View File

@@ -17,7 +17,7 @@ declare namespace TGApp.BBS.Vote {
type ResultResp = TGApp.BBS.Response.BaseWithData<ResultRes>;
/**
* 投票信息返回
* 投票信息返回数据
* @since Beta v0.9.1
*/
type InfoRes = {
@@ -26,7 +26,7 @@ declare namespace TGApp.BBS.Vote {
};
/**
* 投票结果返回
* 投票结果返回数据
* @since Beta v0.9.1
*/
type ResultRes = {

View File

@@ -446,9 +446,17 @@ async function tryLike(): Promise<void> {
return;
}
const ck = { ltoken: cookie.value.ltoken, ltuid: cookie.value.ltuid };
const resp = await apiHubReq.post.like(postData.value.post.post_id, ck, isLike.value);
if (resp.retcode !== 0) {
showSnackbar.error(`[${resp.retcode}] ${resp.message}`);
try {
const resp = await apiHubReq.post.like(postData.value.post.post_id, ck, isLike.value);
if (resp.retcode !== 0) {
showSnackbar.error(`[${resp.retcode}] ${resp.message}`);
await TGLogger.Warn(`[t-post][tryLike] 点赞失败:${resp.retcode} ${resp.message}`);
return;
}
} catch (e) {
const errMsg = TGHttps.getErrMsg(e);
showSnackbar.error(`点赞失败:${errMsg}`);
await TGLogger.Error(`[t-post][tryLike] 点赞异常:${errMsg}`);
return;
}
isLike.value = !isLike.value;