mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
✏️ 合并相同类型数据
This commit is contained in:
10
src/plugins/Mys/types/Forum.d.ts
vendored
10
src/plugins/Mys/types/Forum.d.ts
vendored
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/Forum.d.ts
|
||||
* @description Mys 插件论坛类型定义文件
|
||||
* @since Beta v0.4.0
|
||||
* @since Beta v0.4.5
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Mys 插件论坛类型
|
||||
* @since Beta v0.3.7
|
||||
* @since Beta v0.4.5
|
||||
* @namespace TGApp.Plugins.Mys.Forum
|
||||
* @memberof TGApp.Plugins.Mys
|
||||
*/
|
||||
@@ -25,14 +25,14 @@ declare namespace TGApp.Plugins.Mys.Forum {
|
||||
|
||||
/**
|
||||
* @description 特定论坛数据
|
||||
* @since Beta v0.3.7
|
||||
* @since Beta v0.4.5
|
||||
* @interface FullData
|
||||
* @property {number} last_id 最后一条帖子 ID
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
* @property {boolean} is_origin 是否原创
|
||||
* @property {number} page 页码
|
||||
* @property {unknown} databox 数据盒子
|
||||
* @property {TGApp.Plugins.Mys.News.Item[]} list 帖子列表
|
||||
* @property {TGApp.Plugins.Mys.Post.FullData[]} list 帖子列表
|
||||
* @return FullData
|
||||
*/
|
||||
interface FullData {
|
||||
@@ -41,7 +41,7 @@ declare namespace TGApp.Plugins.Mys.Forum {
|
||||
is_origin: boolean;
|
||||
page: number;
|
||||
databox: unknown;
|
||||
list: TGApp.Plugins.Mys.News.Item[];
|
||||
list: TGApp.Plugins.Mys.Post.FullData[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
75
src/plugins/Mys/types/News.d.ts
vendored
75
src/plugins/Mys/types/News.d.ts
vendored
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @file plugins/Mys/types/news.d.ts
|
||||
* @description Mys 插件咨讯类型定义文件
|
||||
* @since Beta v0.4.0
|
||||
* @since Beta v0.4.5
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description Mys 插件咨讯类型
|
||||
* @since Alpha v0.2.1
|
||||
* @since Beta v0.4.5
|
||||
* @namespace TGApp.Plugins.Mys.News
|
||||
* @memberof TGApp.Plugins.Mys
|
||||
*/
|
||||
@@ -25,7 +25,7 @@ declare namespace TGApp.Plugins.Mys.News {
|
||||
|
||||
/**
|
||||
* @description 咨讯数据
|
||||
* @since Alpha v0.2.1
|
||||
* @since Beta v0.4.5
|
||||
* @interface FullData
|
||||
* @property {number} last_id 最后一条咨讯 ID
|
||||
* @property {boolean} is_last 是否最后一页
|
||||
@@ -35,74 +35,7 @@ declare namespace TGApp.Plugins.Mys.News {
|
||||
interface FullData {
|
||||
last_id: number;
|
||||
is_last: boolean;
|
||||
list: Item[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 咨讯列表项
|
||||
* @since Beta v0.3.7
|
||||
* @interface Item
|
||||
* @property {TGApp.Plugins.Mys.Post.Post} post 帖子
|
||||
* @property {TGApp.Plugins.Mys.Post.Forum} forum 版块
|
||||
* @property {TGApp.Plugins.Mys.Post.Topic[]} topics 话题
|
||||
* @property {TGApp.Plugins.Mys.User.Post} user 发帖用户
|
||||
* @property {TGApp.Plugins.Mys.User.SelfOperation} self_operation 用户操作
|
||||
* @property {TGApp.Plugins.Mys.Post.Stat} stat 帖子统计
|
||||
* @property {TGApp.Plugins.Mys.Post.HelpSys} help_sys 帮助系统,可能为 null
|
||||
* @property {TGApp.Plugins.Mys.Post.Image} cover 封面图片 URL
|
||||
* @property {TGApp.Plugins.Mys.Post.Image[]} image_list 图片列表
|
||||
* @property {boolean} is_official_master 是否为官方
|
||||
* @property {boolean} is_user_master 是否用户
|
||||
* @property {boolean} hot_reply_exist 是否热门回复
|
||||
* @property {number} vote_count 投票数
|
||||
* @property {number} last_modify_time 最后修改时间
|
||||
* @property {string} recommend_type 推荐类型
|
||||
* @property {unknown} collection 合集, 可能为 null
|
||||
* @property {TGApp.Plugins.Mys.Post.Vod[]} vod_list 视频列表
|
||||
* @property {boolean} is_block_on 是否屏蔽
|
||||
* @property {unknown} forum_rank_info 版块排名信息,可能为 null
|
||||
* @property {unknown[]} link_card_list 链接卡片列表,可能为 null
|
||||
* @property {Meta} news_meta 元数据
|
||||
* @property {TGApp.Plugins.Mys.Post.RecommendReason|null} recommend_reason 推荐理由,可能为 null
|
||||
* @property {unknown} villa_card 别墅卡片,可能为 null
|
||||
* @property {boolean} is_mentor 是否为导师
|
||||
* @property {unknown} villa_room_card 别墅房间卡片,可能为 null
|
||||
* @property {unknown} reply_avatar_action_info 回复头像动作信息,可能为 null
|
||||
* @property {TGApp.Plugins.Mys.Post.Challenge} challenge 挑战信息,可能为 null
|
||||
* @property {unknown[]} hot_reply_list 热门回复列表
|
||||
* @property {unknown[]} villa_msg_image_list 别墅消息图片列表
|
||||
* @returns Item
|
||||
*/
|
||||
interface Item {
|
||||
post: TGApp.Plugins.Mys.Post.Post;
|
||||
forum: TGApp.Plugins.Mys.Post.Forum;
|
||||
topics: TGApp.Plugins.Mys.Post.Topic[];
|
||||
user: TGApp.Plugins.Mys.User.Post;
|
||||
self_operation: TGApp.Plugins.Mys.User.SelfOperation;
|
||||
stat: TGApp.Plugins.Mys.Post.Stat;
|
||||
help_sys: TGApp.Plugins.Mys.Post.HelpSys;
|
||||
cover: TGApp.Plugins.Mys.Post.Image;
|
||||
image_list: TGApp.Plugins.Mys.Post.Image[];
|
||||
is_official_master: boolean;
|
||||
is_user_master: boolean;
|
||||
hot_reply_exist: boolean;
|
||||
vote_count: number;
|
||||
last_modify_time: number;
|
||||
recommend_type: string;
|
||||
collection: unknown;
|
||||
vod_list: TGApp.Plugins.Mys.Post.Vod[];
|
||||
is_block_on: boolean;
|
||||
forum_rank_info: unknown;
|
||||
link_card_list: unknown[];
|
||||
news_meta: Meta;
|
||||
recommend_reason: TGApp.Plugins.Mys.Post.RecommendReason | null;
|
||||
villa_card: unknown | null;
|
||||
is_mentor: boolean;
|
||||
villa_room_card: unknown | null;
|
||||
reply_avatar_action_info: unknown | null;
|
||||
challenge: TGApp.Plugins.Mys.Post.Challenge | null;
|
||||
hot_reply_list: unknown[];
|
||||
villa_msg_image_list: unknown[];
|
||||
list: TGApp.Plugins.Mys.Post.FullData[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file plugins/Mys/utils/news.ts
|
||||
* @description Mys 插件咨讯工具
|
||||
* @since Beta v0.4.4
|
||||
* @since Beta v0.4.5
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -53,11 +53,11 @@ export function getActivityStatus(status: number): TGApp.Plugins.Mys.News.Render
|
||||
|
||||
/**
|
||||
* @description 获取封面图
|
||||
* @since Beta v0.4.4
|
||||
* @param {TGApp.Plugins.Mys.News.Item} item 咨讯列表项
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.Post.FullData} item 咨讯列表项
|
||||
* @returns {string} 封面图链接
|
||||
*/
|
||||
export function getPostCover(item: TGApp.Plugins.Mys.News.Item): string {
|
||||
export function getPostCover(item: TGApp.Plugins.Mys.Post.FullData): string {
|
||||
// 默认封面图
|
||||
const defaultCover = "/source/UI/defaultCover.webp";
|
||||
let cover;
|
||||
@@ -75,11 +75,11 @@ export function getPostCover(item: TGApp.Plugins.Mys.News.Item): string {
|
||||
|
||||
/**
|
||||
* @description 获取公共属性
|
||||
* @since Beta v0.4.0
|
||||
* @param {TGApp.Plugins.Mys.News.Item} item 咨讯列表项
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.Post.FullData} item 咨讯列表项
|
||||
* @returns {TGApp.Plugins.Mys.News.RenderCard} 渲染用咨讯列表项
|
||||
*/
|
||||
function getCommonCard(item: TGApp.Plugins.Mys.News.Item): TGApp.Plugins.Mys.News.RenderCard {
|
||||
function getCommonCard(item: TGApp.Plugins.Mys.Post.FullData): TGApp.Plugins.Mys.News.RenderCard {
|
||||
return {
|
||||
title: item.post.subject,
|
||||
cover: getPostCover(item),
|
||||
@@ -102,7 +102,7 @@ function getCommonCard(item: TGApp.Plugins.Mys.News.Item): TGApp.Plugins.Mys.New
|
||||
|
||||
/**
|
||||
* @description 获取渲染用公告数据
|
||||
* @since Alpha v0.2.1
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.News.FullData} noticeData 公告数据
|
||||
* @returns {TGApp.Plugins.Mys.News.RenderCard[]}
|
||||
*/
|
||||
@@ -110,15 +110,13 @@ export function getNoticeCard(
|
||||
noticeData: TGApp.Plugins.Mys.News.FullData,
|
||||
): TGApp.Plugins.Mys.News.RenderCard[] {
|
||||
const noticeCard: TGApp.Plugins.Mys.News.RenderCard[] = [];
|
||||
noticeData.list.map((item: TGApp.Plugins.Mys.News.Item) => {
|
||||
return noticeCard.push(getCommonCard(item));
|
||||
});
|
||||
noticeData.list.map((item) => noticeCard.push(getCommonCard(item)));
|
||||
return noticeCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取渲染用活动数据
|
||||
* @since Alpha v0.2.1
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.News.FullData} activityData 活动数据
|
||||
* @returns {TGApp.Plugins.Mys.News.RenderCard[]}
|
||||
*/
|
||||
@@ -126,10 +124,10 @@ export function getActivityCard(
|
||||
activityData: TGApp.Plugins.Mys.News.FullData,
|
||||
): TGApp.Plugins.Mys.News.RenderCard[] {
|
||||
const activityCard: TGApp.Plugins.Mys.News.RenderCard[] = [];
|
||||
activityData.list.map((item: TGApp.Plugins.Mys.News.Item) => {
|
||||
const startTime = new Date(Number(item.news_meta.start_at_sec) * 1000).toLocaleDateString();
|
||||
const endTime = new Date(Number(item.news_meta.end_at_sec) * 1000).toLocaleDateString();
|
||||
const statusInfo = getActivityStatus(item.news_meta.activity_status);
|
||||
activityData.list.map((item) => {
|
||||
const startTime = new Date(Number(item.news_meta!.start_at_sec) * 1000).toLocaleDateString();
|
||||
const endTime = new Date(Number(item.news_meta!.end_at_sec) * 1000).toLocaleDateString();
|
||||
const statusInfo = getActivityStatus(item.news_meta!.activity_status);
|
||||
const commonCard = getCommonCard(item);
|
||||
commonCard.subtitle = `${startTime} - ${endTime}`;
|
||||
commonCard.status = statusInfo;
|
||||
@@ -140,7 +138,7 @@ export function getActivityCard(
|
||||
|
||||
/**
|
||||
* @description 获取渲染用新闻数据
|
||||
* @since Alpha v0.2.1
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.News.FullData} newsData 新闻数据
|
||||
* @returns {TGApp.Plugins.Mys.News.RenderCard[]}
|
||||
*/
|
||||
@@ -148,8 +146,6 @@ export function getNewsCard(
|
||||
newsData: TGApp.Plugins.Mys.News.FullData,
|
||||
): TGApp.Plugins.Mys.News.RenderCard[] {
|
||||
const newsCard: TGApp.Plugins.Mys.News.RenderCard[] = [];
|
||||
newsData.list.map((item: TGApp.Plugins.Mys.News.Item) => {
|
||||
return newsCard.push(getCommonCard(item));
|
||||
});
|
||||
newsData.list.map((item) => newsCard.push(getCommonCard(item)));
|
||||
return newsCard;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
/**
|
||||
* @file plugins/Mys/utils/getPostsCard.ts
|
||||
* @description Mys 插件帖子渲染
|
||||
* @since Beta v0.4.0
|
||||
* @since Beta v0.4.5
|
||||
*/
|
||||
|
||||
import { getPostCover } from "./getNewsCard";
|
||||
|
||||
/**
|
||||
* @description 解析单个帖子
|
||||
* @since Beta v0.4.0
|
||||
* @param {TGApp.Plugins.Mys.News.Item} post 帖子
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.Post.FullData} post 帖子
|
||||
* @returns {TGApp.Plugins.Mys.Forum.RenderCard} 渲染用帖子
|
||||
*/
|
||||
function getPostCard(post: TGApp.Plugins.Mys.News.Item): TGApp.Plugins.Mys.Forum.RenderCard {
|
||||
export function getPostCard(
|
||||
post: TGApp.Plugins.Mys.Post.FullData,
|
||||
): TGApp.Plugins.Mys.Forum.RenderCard {
|
||||
return {
|
||||
title: post.post.subject,
|
||||
cover: getPostCover(post),
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function getTokensByLoginTicket(
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
if (res.data.retcode !== 0) return res.data;
|
||||
if (res.data.retcode !== 0) return <TGApp.BBS.Response.Base>res.data;
|
||||
return res.data.data.list;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user