添加 TpVote

* PostID:44118649
This commit is contained in:
BTMuli
2023-12-28 00:15:08 +08:00
parent 6b4cd2a666
commit ca9c5ca931
5 changed files with 290 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
/**
* @file plugins/Mys/request/getVoteData.ts
* @description Mys 插件投票请求
* @since Beta v0.3.9
*/
import { http } from "@tauri-apps/api";
import MysApi from "../api";
/**
* @description 获取投票信息
* @since Beta v0.3.9
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Info>}
*/
export async function getVoteInfo(id: string, uid: string): Promise<TGApp.Plugins.Mys.Vote.Info> {
const url = `https://bbs-api.miyoushe.com/apihub/api/getVotes?owner_uid=${uid}&vote_ids=${id}`;
return await http
.fetch<TGApp.Plugins.Mys.Vote.InfoResponse>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Referer: MysApi.Post.Referer,
},
})
.then((res) => {
return res.data.data.data[0];
});
}
/**
* @description 获取投票结果
* @since Beta v0.3.9
* @param {string} id 投票 ID
* @param {string} uid 用户 ID
* @return {Promise<TGApp.Plugins.Mys.Vote.Result>}
*/
export async function getVoteResult(
id: string,
uid: string,
): Promise<TGApp.Plugins.Mys.Vote.Result> {
const url = `https://bbs-api.miyoushe.com/apihub/api/getVotesResult?owner_uid=${uid}&vote_ids=${id}`;
return await http
.fetch<TGApp.Plugins.Mys.Vote.ResultResponse>(url, {
method: "GET",
headers: {
"Content-Type": "application/json",
Referer: MysApi.Post.Referer,
},
})
.then((res) => {
return res.data.data.data[0];
});
}