mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
@@ -2,7 +2,7 @@
|
||||
* @file plugins Mys request news.ts
|
||||
* @description Mys 插件咨讯请求
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.1
|
||||
* @since Alpha v0.1.2
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
@@ -10,7 +10,7 @@ import { NewsData, NewsResponse } from "../interface/news";
|
||||
|
||||
// 咨讯 API
|
||||
const NEWS_LIST_API =
|
||||
"https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids=2&page_size={page_size}&type={news_type}&last_id={last_id}";
|
||||
"https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids={gid}&page_size={page_size}&type={news_type}&last_id={last_id}";
|
||||
|
||||
/**
|
||||
* @description 咨讯类型
|
||||
@@ -29,16 +29,19 @@ enum NewsType {
|
||||
|
||||
/**
|
||||
* @description 获取 Notice 列表
|
||||
* @since Alpha v0.1.1
|
||||
* @since Alpha v0.1.2
|
||||
* @param {string} gid gid: 1 为崩坏3, 2 为原神,3 为崩坏2,4 为未定事件簿,5 为大别野,6 为崩坏:星穹铁道,8 为绝区零
|
||||
* @param {number} page_size 返回数量
|
||||
* @param {number} last_id 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNoticeList(
|
||||
gid: string = "2",
|
||||
page_size: number = 20,
|
||||
last_id: number = 0
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.NOTICE)
|
||||
.replace("{last_id}", last_id.toString());
|
||||
return await http.fetch<NewsResponse>(url).then(res => res.data.data);
|
||||
@@ -46,16 +49,19 @@ export async function getNoticeList(
|
||||
|
||||
/**
|
||||
* @description 获取 Activity 列表
|
||||
* @since Alpha v0.1.1
|
||||
* @since Alpha v0.1.2
|
||||
* @param {string} gid gid: 1 为崩坏3, 2 为原神,3 为崩坏2,4 为未定事件簿,5 为大别野,6 为崩坏:星穹铁道,8 为绝区零
|
||||
* @param {number} page_size 返回数量
|
||||
* @param {number} last_id 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getActivityList(
|
||||
gid: string = "2",
|
||||
page_size: number = 20,
|
||||
last_id: number = 0
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.ACTIVITY)
|
||||
.replace("{last_id}", last_id.toString());
|
||||
return await http.fetch<NewsResponse>(url).then(res => res.data.data);
|
||||
@@ -63,13 +69,19 @@ export async function getActivityList(
|
||||
|
||||
/**
|
||||
* @description 获取 News 列表
|
||||
* @since Alpha v0.1.1
|
||||
* @since Alpha v0.1.2
|
||||
* @param {string} gid gid: 1 为崩坏3, 2 为原神,3 为崩坏2,4 为未定事件簿,5 为大别野,6 为崩坏:星穹铁道,8 为绝区零
|
||||
* @param {number} page_size 返回数量
|
||||
* @param {number} last_id 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNewsList(page_size: number = 20, last_id: number = 0): Promise<NewsData> {
|
||||
export async function getNewsList(
|
||||
gid: string = "2",
|
||||
page_size: number = 20,
|
||||
last_id: number = 0
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
|
||||
.replace("{gid}", gid)
|
||||
.replace("{news_type}", NewsType.NEWS)
|
||||
.replace("{last_id}", last_id.toString());
|
||||
return await http.fetch<NewsResponse>(url).then(res => res.data.data);
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
* @file plugins Mys request post.ts
|
||||
* @description Mys帖子请求
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha
|
||||
* @since Alpha v0.1.2
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
import { PostResponse, PostData } from "../interface/post";
|
||||
|
||||
// 帖子 API
|
||||
const POST_API = "https://bbs-api.mihoyo.com/post/wapi/getPostFull?gids=2&post_id={post_id}";
|
||||
const POST_REFERER = "https://bbs.mihoyo.com/ys/article/{post_id}";
|
||||
const POST_API = "https://bbs-api.mihoyo.com/post/wapi/getPostFull?post_id={post_id}";
|
||||
const POST_REFERER = "https://bbs.mihoyo.com/";
|
||||
|
||||
/**
|
||||
* @description 获取帖子信息
|
||||
* @since Alpha
|
||||
* @since Alpha v0.1.2
|
||||
* @param {number} post_id 帖子 ID
|
||||
* @return {Promise<PostData>}
|
||||
*/
|
||||
@@ -24,7 +24,7 @@ export async function getPostData(post_id: number): Promise<PostData> {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Referer: POST_REFERER.replace("{post_id}", post_id.toString()),
|
||||
Referer: POST_REFERER,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
|
||||
Reference in New Issue
Block a user