mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🔥 移除无用文件
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file plugins/Mys/index.ts
|
||||
* @description Mys plugin index
|
||||
* @since Beta v0.4.4
|
||||
* @since Beta v0.4.5
|
||||
*/
|
||||
|
||||
import MysApi from "./api";
|
||||
@@ -17,9 +17,7 @@ import getPostData from "./request/getPostData";
|
||||
import { getVoteInfo, getVoteResult } from "./request/getVoteData";
|
||||
import { getGachaCard } from "./utils/getGachaCard";
|
||||
import getLotteryCard from "./utils/getLotteryCard";
|
||||
import { getActivityCard, getNewsCard, getNoticeCard } from "./utils/getNewsCard";
|
||||
import getPositionCard from "./utils/getPositionCard";
|
||||
import { getPostsCard } from "./utils/getPostsCard";
|
||||
|
||||
const Mys = {
|
||||
Api: MysApi,
|
||||
@@ -32,7 +30,6 @@ const Mys = {
|
||||
},
|
||||
Posts: {
|
||||
get: getForumList,
|
||||
card: getPostsCard,
|
||||
nav: getHomeNavigator,
|
||||
},
|
||||
Gacha: {
|
||||
@@ -43,14 +40,7 @@ const Mys = {
|
||||
get: getPositionData,
|
||||
card: getPositionCard,
|
||||
},
|
||||
News: {
|
||||
get: getNewsList,
|
||||
card: {
|
||||
notice: getNoticeCard,
|
||||
activity: getActivityCard,
|
||||
news: getNewsCard,
|
||||
},
|
||||
},
|
||||
News: getNewsList,
|
||||
Lottery: {
|
||||
get: getLotteryData,
|
||||
card: getLotteryCard,
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
/**
|
||||
* @file plugins/Mys/utils/news.ts
|
||||
* @description Mys 插件咨讯工具
|
||||
* @since Beta v0.4.5
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description 活动状态
|
||||
* @since Alpha v0.2.1
|
||||
* @enum {TGApp.Plugins.Mys.News.RenderStatus}
|
||||
* @property {TGApp.Plugins.Mys.News.RenderStatus} STARTED 进行中
|
||||
* @property {TGApp.Plugins.Mys.News.RenderStatus} FINISHED 已结束
|
||||
* @property {TGApp.Plugins.Mys.News.RenderStatus} SELECTION 评选中
|
||||
* @return EnumStatus
|
||||
*/
|
||||
const EnumStatus = {
|
||||
STARTED: {
|
||||
status: "进行中",
|
||||
colorCss: "#1EE2BA",
|
||||
},
|
||||
FINISHED: {
|
||||
status: "已结束",
|
||||
colorCss: "#C0C5C8",
|
||||
},
|
||||
SELECTION: {
|
||||
status: "评选中",
|
||||
colorCss: "#FF983B",
|
||||
},
|
||||
UNKNOWN: {
|
||||
status: "未知",
|
||||
colorCss: "#F03F24", // 胭脂红
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 获取活动状态
|
||||
* @since Alpha
|
||||
* @param {number} status 活动状态码
|
||||
* @returns {string}
|
||||
*/
|
||||
export function getActivityStatus(status: number): TGApp.Plugins.Mys.News.RenderStatus {
|
||||
switch (status) {
|
||||
case 1:
|
||||
return EnumStatus.STARTED;
|
||||
case 2:
|
||||
return EnumStatus.SELECTION;
|
||||
case 3:
|
||||
return EnumStatus.FINISHED;
|
||||
default:
|
||||
return EnumStatus.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取封面图
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.Post.FullData} item 咨讯列表项
|
||||
* @returns {string} 封面图链接
|
||||
*/
|
||||
export function getPostCover(item: TGApp.Plugins.Mys.Post.FullData): string {
|
||||
// 默认封面图
|
||||
const defaultCover = "/source/UI/defaultCover.webp";
|
||||
let cover;
|
||||
if (item.cover) {
|
||||
cover = item.cover.url;
|
||||
} else if (item.post.cover) {
|
||||
cover = item.post.cover;
|
||||
} else if (item.post.images.length > 0) {
|
||||
cover = item.post.images[0];
|
||||
}
|
||||
if (cover === undefined) return defaultCover;
|
||||
if (cover.endsWith(".gif")) return cover;
|
||||
return `${cover}?x-oss-process=image/format,png`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取公共属性
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.Post.FullData} item 咨讯列表项
|
||||
* @returns {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),
|
||||
postId: Number(item.post.post_id),
|
||||
subtitle: item.post.post_id,
|
||||
user: item.user,
|
||||
forum: {
|
||||
name: item.forum.name,
|
||||
icon: item.forum.icon,
|
||||
},
|
||||
data: {
|
||||
mark: item.stat.bookmark_num,
|
||||
forward: item.stat.forward_num,
|
||||
like: item.stat.like_num,
|
||||
reply: item.stat.reply_num,
|
||||
view: item.stat.view_num,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取渲染用公告数据
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.News.FullData} noticeData 公告数据
|
||||
* @returns {TGApp.Plugins.Mys.News.RenderCard[]}
|
||||
*/
|
||||
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) => noticeCard.push(getCommonCard(item)));
|
||||
return noticeCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取渲染用活动数据
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.News.FullData} activityData 活动数据
|
||||
* @returns {TGApp.Plugins.Mys.News.RenderCard[]}
|
||||
*/
|
||||
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) => {
|
||||
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;
|
||||
return activityCard.push(commonCard);
|
||||
});
|
||||
return activityCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取渲染用新闻数据
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.News.FullData} newsData 新闻数据
|
||||
* @returns {TGApp.Plugins.Mys.News.RenderCard[]}
|
||||
*/
|
||||
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) => newsCard.push(getCommonCard(item)));
|
||||
return newsCard;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* @file plugins/Mys/utils/getPostsCard.ts
|
||||
* @description Mys 插件帖子渲染
|
||||
* @since Beta v0.4.5
|
||||
*/
|
||||
|
||||
import { getPostCover } from "./getNewsCard";
|
||||
|
||||
/**
|
||||
* @description 解析单个帖子
|
||||
* @since Beta v0.4.5
|
||||
* @param {TGApp.Plugins.Mys.Post.FullData} post 帖子
|
||||
* @returns {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),
|
||||
postId: post.post.post_id,
|
||||
subtitle: post.post.post_id,
|
||||
user: post.user,
|
||||
forum: {
|
||||
name: post.forum.name,
|
||||
icon: post.forum.icon,
|
||||
},
|
||||
data: {
|
||||
mark: post.stat.bookmark_num,
|
||||
forward: post.stat.forward_num,
|
||||
like: post.stat.like_num,
|
||||
reply: post.stat.reply_num,
|
||||
view: post.stat.view_num,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取渲染用帖子数据
|
||||
* @since Beta v0.3.7
|
||||
* @param {TGApp.Plugins.Mys.Forum.FullData} posts
|
||||
* @returns {TGApp.Plugins.Mys.Forum.RenderCard[]}
|
||||
*/
|
||||
export function getPostsCard(
|
||||
posts: TGApp.Plugins.Mys.Forum.FullData,
|
||||
): TGApp.Plugins.Mys.Forum.RenderCard[] {
|
||||
const postsCard: TGApp.Plugins.Mys.Forum.RenderCard[] = [];
|
||||
posts.list.map((post) => {
|
||||
return postsCard.push(getPostCard(post));
|
||||
});
|
||||
return postsCard;
|
||||
}
|
||||
Reference in New Issue
Block a user