mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-10 08:58:15 +08:00
fix(request): 请求更改,支持无限滚动(雾
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @file plugins Mys request news.ts
|
||||
* @description Mys 插件咨讯请求
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha
|
||||
* @since Alpha v0.1.1
|
||||
*/
|
||||
|
||||
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}";
|
||||
"https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids=2&page_size={page_size}&type={news_type}&last_id={last_id}";
|
||||
|
||||
/**
|
||||
* @description 咨讯类型
|
||||
@@ -29,42 +29,48 @@ enum NewsType {
|
||||
|
||||
/**
|
||||
* @description 获取 Notice 列表
|
||||
* @since Alpha
|
||||
* @since Alpha v0.1.1
|
||||
* @param {number} page_size 返回数量
|
||||
* @param {number} last_id 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNoticeList(page_size: number = 20): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString()).replace(
|
||||
"{news_type}",
|
||||
NewsType.NOTICE
|
||||
);
|
||||
export async function getNoticeList(
|
||||
page_size: number = 20,
|
||||
last_id: number = 0
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
|
||||
.replace("{news_type}", NewsType.NOTICE)
|
||||
.replace("{last_id}", last_id.toString());
|
||||
return await http.fetch<NewsResponse>(url).then(res => res.data.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取 Activity 列表
|
||||
* @since Alpha
|
||||
* @since Alpha v0.1.1
|
||||
* @param {number} page_size 返回数量
|
||||
* @param {number} last_id 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getActivityList(page_size: number = 20): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString()).replace(
|
||||
"{news_type}",
|
||||
NewsType.ACTIVITY
|
||||
);
|
||||
export async function getActivityList(
|
||||
page_size: number = 20,
|
||||
last_id: number = 0
|
||||
): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
|
||||
.replace("{news_type}", NewsType.ACTIVITY)
|
||||
.replace("{last_id}", last_id.toString());
|
||||
return await http.fetch<NewsResponse>(url).then(res => res.data.data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取 News 列表
|
||||
* @since Alpha
|
||||
* @since Alpha v0.1.1
|
||||
* @param {number} page_size 返回数量
|
||||
* @param {number} last_id 上一次请求的最后一条数据的 id
|
||||
* @return {Promise<NewsData>}
|
||||
*/
|
||||
export async function getNewsList(page_size: number = 20): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString()).replace(
|
||||
"{news_type}",
|
||||
NewsType.NEWS
|
||||
);
|
||||
export async function getNewsList(page_size: number = 20, last_id: number = 0): Promise<NewsData> {
|
||||
const url = NEWS_LIST_API.replace("{page_size}", page_size.toString())
|
||||
.replace("{news_type}", NewsType.NEWS)
|
||||
.replace("{last_id}", last_id.toString());
|
||||
return await http.fetch<NewsResponse>(url).then(res => res.data.data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user