mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
♻️ 移除留影叙佳期,重构卡池组件
This commit is contained in:
@@ -5,18 +5,6 @@
|
|||||||
<v-icon size="small" style="opacity: 0.8">mdi-calendar-clock</v-icon>
|
<v-icon size="small" style="opacity: 0.8">mdi-calendar-clock</v-icon>
|
||||||
<span>今日素材</span>
|
<span>今日素材</span>
|
||||||
<span>{{ dateNow }}</span>
|
<span>{{ dateNow }}</span>
|
||||||
<!-- 如果是某人生日,礼物图标颜色为红色 -->
|
|
||||||
<span
|
|
||||||
v-if="birthInfo.isLogin"
|
|
||||||
@click="toBirthday"
|
|
||||||
class="calendar-title-gift"
|
|
||||||
:style="{
|
|
||||||
color: birthInfo.active ? 'var(--tgc-red-1)' : 'inherit',
|
|
||||||
}"
|
|
||||||
:title="birthInfo.text"
|
|
||||||
>
|
|
||||||
<v-icon size="small">mdi-gift</v-icon>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="calendar-title-mid">
|
<div class="calendar-title-mid">
|
||||||
<v-btn
|
<v-btn
|
||||||
@@ -76,9 +64,6 @@
|
|||||||
import { computed, onMounted, ref } from "vue";
|
import { computed, onMounted, ref } from "vue";
|
||||||
|
|
||||||
import { AppCalendarData } from "../../data";
|
import { AppCalendarData } from "../../data";
|
||||||
import TGSqlite from "../../plugins/Sqlite";
|
|
||||||
import { useAppStore } from "../../store/modules/app";
|
|
||||||
import TGClient from "../../utils/TGClient";
|
|
||||||
import { generateShareImg } from "../../utils/TGShare";
|
import { generateShareImg } from "../../utils/TGShare";
|
||||||
import TibCalendarItem from "../itembox/tib-calendar-item.vue";
|
import TibCalendarItem from "../itembox/tib-calendar-item.vue";
|
||||||
import ToCalendar from "../overlay/to-calendar.vue";
|
import ToCalendar from "../overlay/to-calendar.vue";
|
||||||
@@ -100,13 +85,6 @@ const switchType = ref<string>("avatar");
|
|||||||
const selectedItem = ref<TGApp.App.Calendar.Item>(<TGApp.App.Calendar.Item>{});
|
const selectedItem = ref<TGApp.App.Calendar.Item>(<TGApp.App.Calendar.Item>{});
|
||||||
const selectedType = ref<"avatar" | "weapon">("avatar");
|
const selectedType = ref<"avatar" | "weapon">("avatar");
|
||||||
|
|
||||||
// birthday
|
|
||||||
const birthInfo = ref({
|
|
||||||
isLogin: true,
|
|
||||||
active: false,
|
|
||||||
text: "点击前往留影叙佳期",
|
|
||||||
});
|
|
||||||
|
|
||||||
const btnText = [
|
const btnText = [
|
||||||
{
|
{
|
||||||
week: 7,
|
week: 7,
|
||||||
@@ -147,16 +125,6 @@ interface TCalendarEmits {
|
|||||||
const emits = defineEmits<TCalendarEmits>();
|
const emits = defineEmits<TCalendarEmits>();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const appStore = useAppStore();
|
|
||||||
if (appStore.isLogin) {
|
|
||||||
const birthRes = await TGSqlite.isBirthday();
|
|
||||||
if (birthRes !== false) {
|
|
||||||
birthInfo.value.active = true;
|
|
||||||
birthInfo.value.text = `今天是 ${birthRes} 的生日!`;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
birthInfo.value.isLogin = false;
|
|
||||||
}
|
|
||||||
const dayNow = new Date().getDay() === 0 ? 7 : new Date().getDay();
|
const dayNow = new Date().getDay() === 0 ? 7 : new Date().getDay();
|
||||||
const week = <{ week: number; text: string }>btnText.find((item) => item.week === dayNow);
|
const week = <{ week: number; text: string }>btnText.find((item) => item.week === dayNow);
|
||||||
dateNow.value =
|
dateNow.value =
|
||||||
@@ -207,11 +175,6 @@ async function share(): Promise<void> {
|
|||||||
await generateShareImg(title, div);
|
await generateShareImg(title, div);
|
||||||
emits("loadOuter", { show: false });
|
emits("loadOuter", { show: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 前往留影叙佳期
|
|
||||||
async function toBirthday(): Promise<void> {
|
|
||||||
await TGClient.open("birthday");
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
.calendar-box {
|
.calendar-box {
|
||||||
|
|||||||
@@ -28,9 +28,14 @@
|
|||||||
v-for="character in pool.characters"
|
v-for="character in pool.characters"
|
||||||
:key="character.url"
|
:key="character.url"
|
||||||
class="pool-icon"
|
class="pool-icon"
|
||||||
@click="toOuter(character.url, pool.title)"
|
@click="toOuter(character, pool.title)"
|
||||||
>
|
>
|
||||||
<img :src="character.icon" alt="character" />
|
<TItembox
|
||||||
|
:title="character.info.name"
|
||||||
|
v-if="character.info"
|
||||||
|
:model-value="getCBox(character.info)"
|
||||||
|
/>
|
||||||
|
<img v-else :src="character.icon" alt="character" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -66,6 +71,7 @@ import { useHomeStore } from "../../store/modules/home";
|
|||||||
import { createPost, createTGWindow } from "../../utils/TGWindow";
|
import { createPost, createTGWindow } from "../../utils/TGWindow";
|
||||||
import { stamp2LastTime } from "../../utils/toolFunc";
|
import { stamp2LastTime } from "../../utils/toolFunc";
|
||||||
import showSnackbar from "../func/snackbar";
|
import showSnackbar from "../func/snackbar";
|
||||||
|
import TItembox, { TItemBoxData } from "../main/t-itembox.vue";
|
||||||
|
|
||||||
// store
|
// store
|
||||||
const homeStore = useHomeStore();
|
const homeStore = useHomeStore();
|
||||||
@@ -119,9 +125,9 @@ onMounted(async () => {
|
|||||||
console.info(gachaData);
|
console.info(gachaData);
|
||||||
if (!checkCover(gachaData)) {
|
if (!checkCover(gachaData)) {
|
||||||
poolCards.value = await Mys.Gacha.card(gachaData);
|
poolCards.value = await Mys.Gacha.card(gachaData);
|
||||||
const coverData: Record<number, string> = {};
|
const coverData: Record<string, string> = {};
|
||||||
poolCards.value.map((pool) => {
|
poolCards.value.map((pool) => {
|
||||||
coverData[pool.postId] = pool.cover;
|
coverData[pool.id] = pool.cover;
|
||||||
return pool;
|
return pool;
|
||||||
});
|
});
|
||||||
homeStore.poolCover = coverData;
|
homeStore.poolCover = coverData;
|
||||||
@@ -160,54 +166,61 @@ onMounted(async () => {
|
|||||||
|
|
||||||
// 检测新卡池
|
// 检测新卡池
|
||||||
function checkCover(data: TGApp.Plugins.Mys.Gacha.Data[]): boolean {
|
function checkCover(data: TGApp.Plugins.Mys.Gacha.Data[]): boolean {
|
||||||
// 如果没有缓存
|
|
||||||
if (!homeStore.poolCover || Object.keys(homeStore.poolCover).length === 0) {
|
if (!homeStore.poolCover || Object.keys(homeStore.poolCover).length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 获取缓存
|
const cover = homeStore.poolCover;
|
||||||
const cover = homeStore.poolCover satisfies Record<number, string>;
|
if (cover === undefined) return false;
|
||||||
if (cover === undefined) {
|
let checkList = data.length;
|
||||||
return false;
|
Object.entries(cover).forEach(([key, value]) => {
|
||||||
}
|
const pool = data.find((item) => item.id.toString() === key);
|
||||||
return data.every((item) => {
|
if (pool && value !== "/source/UI/empty.webp") {
|
||||||
const postId = item.activity_url.split("/").pop();
|
checkList--;
|
||||||
if (!postId || isNaN(Number(postId))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!Object.keys(cover).includes(postId)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
const coverUrl = Object.keys(cover).find((key) => key === postId);
|
|
||||||
return coverUrl !== "/source/UI/empty.webp";
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return checkList === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toOuter(url: string, title: string): Promise<void> {
|
async function toOuter(
|
||||||
if (!url) {
|
character: TGApp.Plugins.Mys.Gacha.RenderItem,
|
||||||
|
title: string,
|
||||||
|
): Promise<void> {
|
||||||
|
if (character.info !== undefined) {
|
||||||
|
await router.push({
|
||||||
|
name: "角色图鉴",
|
||||||
|
params: {
|
||||||
|
id: character.info.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const url = character.url;
|
||||||
|
if (url === "") {
|
||||||
showSnackbar({
|
showSnackbar({
|
||||||
text: "链接为空!",
|
text: "链接为空!",
|
||||||
color: "error",
|
color: "error",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// https://bbs.mihoyo.com/ys/obc/content/{content_id}/detail?bbs_presentation_style=no_header
|
|
||||||
const contentId = url.match(/(?<=content\/)\d+/)?.[0];
|
|
||||||
if (contentId) {
|
|
||||||
const character = AppCharacterData.find((item) => item.contentId.toString() === contentId);
|
|
||||||
if (character) {
|
|
||||||
await router.push({
|
|
||||||
name: "角色图鉴",
|
|
||||||
params: {
|
|
||||||
id: character.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
createTGWindow(url, "Sub_window", `Pool_${title}`, 1200, 800, true, true);
|
createTGWindow(url, "Sub_window", `Pool_${title}`, 1200, 800, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCBox(info: TGApp.App.Character.WikiBriefInfo): TItemBoxData {
|
||||||
|
return {
|
||||||
|
bg: `/icon/bg/${info.star}-Star.webp`,
|
||||||
|
icon: `/WIKI/character/${info.id}.webp`,
|
||||||
|
size: "60px",
|
||||||
|
height: "60px",
|
||||||
|
display: "inner",
|
||||||
|
clickable: true,
|
||||||
|
lt: `/icon/element/${info.element}元素.webp`,
|
||||||
|
ltSize: "25px",
|
||||||
|
innerHeight: 20,
|
||||||
|
innerIcon: `/icon/weapon/${info.weapon}.webp`,
|
||||||
|
innerText: info.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// 更换显示的卡池
|
// 更换显示的卡池
|
||||||
async function switchPool(): Promise<void> {
|
async function switchPool(): Promise<void> {
|
||||||
showNew.value = !showNew.value;
|
showNew.value = !showNew.value;
|
||||||
@@ -345,11 +358,8 @@ onUnmounted(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.pool-icon {
|
.pool-icon {
|
||||||
width: 60px;
|
max-width: 60px;
|
||||||
height: 60px;
|
max-height: 60px;
|
||||||
border: 1px solid var(--tgc-white-1);
|
|
||||||
border-radius: 8px;
|
|
||||||
box-shadow: 0 0 5px rgb(0 0 0/20%);
|
|
||||||
transition: all ease-in-out 0.3s;
|
transition: all ease-in-out 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
:multiple="true"
|
:multiple="true"
|
||||||
:chips="true"
|
:chips="true"
|
||||||
/>
|
/>
|
||||||
<v-btn class="select-btn" @click="submitHome">确定</v-btn>
|
<v-btn class="select-btn" @click="submitHome" rounded>确定</v-btn>
|
||||||
</div>
|
</div>
|
||||||
<component
|
<component
|
||||||
:is="item"
|
:is="item"
|
||||||
@@ -125,7 +125,7 @@ onUnmounted(() => {
|
|||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
.home-select {
|
.home-select {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
@@ -133,8 +133,6 @@ onUnmounted(() => {
|
|||||||
.select-btn {
|
.select-btn {
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
border-radius: 10px;
|
|
||||||
margin-top: 8px;
|
|
||||||
background: var(--tgc-btn-1);
|
background: var(--tgc-btn-1);
|
||||||
color: var(--btn-text);
|
color: var(--btn-text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file plugins/Mys/index.ts
|
* @file plugins/Mys/index.ts
|
||||||
* @description Mys plugin index
|
* @description Mys plugin index
|
||||||
* @since Beta v0.3.9
|
* @since Beta v0.4.4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import MysApi from "./api";
|
import MysApi from "./api";
|
||||||
@@ -15,7 +15,7 @@ import getNewsList from "./request/getNewsList";
|
|||||||
import getPositionData from "./request/getPositionData";
|
import getPositionData from "./request/getPositionData";
|
||||||
import getPostData from "./request/getPostData";
|
import getPostData from "./request/getPostData";
|
||||||
import { getVoteInfo, getVoteResult } from "./request/getVoteData";
|
import { getVoteInfo, getVoteResult } from "./request/getVoteData";
|
||||||
import getGachaCard from "./utils/getGachaCard";
|
import { getGachaCard } from "./utils/getGachaCard";
|
||||||
import getLotteryCard from "./utils/getLotteryCard";
|
import getLotteryCard from "./utils/getLotteryCard";
|
||||||
import { getActivityCard, getNewsCard, getNoticeCard } from "./utils/getNewsCard";
|
import { getActivityCard, getNewsCard, getNoticeCard } from "./utils/getNewsCard";
|
||||||
import getPositionCard from "./utils/getPositionCard";
|
import getPositionCard from "./utils/getPositionCard";
|
||||||
|
|||||||
53
src/plugins/Mys/types/Gacha.d.ts
vendored
53
src/plugins/Mys/types/Gacha.d.ts
vendored
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* @file plugins/Mys/types/Gacha.d.ts
|
* @file plugins/Mys/types/Gacha.d.ts
|
||||||
* @description Mys 插件卡池类型定义文件
|
* @description Mys 插件卡池类型定义文件
|
||||||
* @since Beta v0.3.3
|
* @since Beta v0.4.4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Mys 卡池类型定义
|
* @description Mys 卡池类型定义
|
||||||
* @since Beta v0.3.3
|
* @since Beta v0.4.4
|
||||||
* @namespace TGApp.Plugins.Mys.Gacha
|
* @namespace TGApp.Plugins.Mys.Gacha
|
||||||
* @memberof TGApp.Plugins.Mys
|
* @memberof TGApp.Plugins.Mys
|
||||||
*/
|
*/
|
||||||
@@ -27,13 +27,13 @@ declare namespace TGApp.Plugins.Mys.Gacha {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 卡池信息
|
* @description 卡池信息
|
||||||
* @since Alpha v0.2.1
|
* @since Beta v0.4.4
|
||||||
* @interface Data
|
* @interface Data
|
||||||
* @property {string} id 卡池ID
|
* @property {string} id 卡池ID
|
||||||
* @property {string} title 卡池标题
|
* @property {string} title 卡池标题
|
||||||
* @property {string} activity_url 卡池对应帖子
|
* @property {string} activity_url 卡池对应帖子
|
||||||
* @property {string} content_before_act 卡池内容
|
* @property {string} content_before_act 卡池内容
|
||||||
* @property {MiniItem[]} pool 卡池包含的角色
|
* @property {Array<{icon: string; url: string}>} pool 卡池角色头像
|
||||||
* @property {string} voice_icon 卡池角色语音头像
|
* @property {string} voice_icon 卡池角色语音头像
|
||||||
* @property {string} voice_url 卡池角色语音URL
|
* @property {string} voice_url 卡池角色语音URL
|
||||||
* @property {string} voice_status 卡池角色语音状态
|
* @property {string} voice_status 卡池角色语音状态
|
||||||
@@ -43,11 +43,14 @@ declare namespace TGApp.Plugins.Mys.Gacha {
|
|||||||
* @return Data
|
* @return Data
|
||||||
*/
|
*/
|
||||||
interface Data {
|
interface Data {
|
||||||
id: string;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
activity_url: string;
|
activity_url: string;
|
||||||
content_before_act: string;
|
content_before_act: string;
|
||||||
pool: MiniItem[];
|
pool: Array<{
|
||||||
|
icon: string;
|
||||||
|
url: string;
|
||||||
|
}>;
|
||||||
voice_icon: string;
|
voice_icon: string;
|
||||||
voice_url: string;
|
voice_url: string;
|
||||||
voice_status: string;
|
voice_status: string;
|
||||||
@@ -55,45 +58,47 @@ declare namespace TGApp.Plugins.Mys.Gacha {
|
|||||||
end_time: string;
|
end_time: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description 基本信息
|
|
||||||
* @since Alpha v0.2.1
|
|
||||||
* @interface MiniItem
|
|
||||||
* @property {string} icon 图标
|
|
||||||
* @property {string} url 链接
|
|
||||||
* @return MiniItem
|
|
||||||
*/
|
|
||||||
interface MiniItem {
|
|
||||||
icon: string;
|
|
||||||
url: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 用于渲染的卡池数据
|
* @description 用于渲染的卡池数据
|
||||||
* @since Beta v0.3.3
|
* @since Beta v0.4.4
|
||||||
* @interface RenderCard
|
* @interface RenderCard
|
||||||
|
* @property {string} id 卡池ID
|
||||||
* @property {string} title 卡池标题
|
* @property {string} title 卡池标题
|
||||||
* @property {string} subtitle 卡池副标题
|
* @property {string} subtitle 卡池副标题
|
||||||
* @property {string} cover 卡池封面
|
* @property {string} cover 卡池封面
|
||||||
* @property {number} postId 卡池对应帖子ID
|
* @property {number} postId 卡池对应帖子ID
|
||||||
* @property {MiniItem[]} characters 卡池包含的角色
|
* @property {Array<RenderItem>} characters 卡池角色头像
|
||||||
* @property {MiniItem} voice 卡池角色语音
|
|
||||||
* @property {string} time.str 卡池时间字符串
|
* @property {string} time.str 卡池时间字符串
|
||||||
* @property {string} time.startStamp 卡池开始时间戳
|
* @property {string} time.startStamp 卡池开始时间戳
|
||||||
* @property {string} time.endStamp 卡池结束时间戳
|
* @property {string} time.endStamp 卡池结束时间戳
|
||||||
* @return RenderCard
|
* @return RenderCard
|
||||||
*/
|
*/
|
||||||
interface RenderCard {
|
interface RenderCard {
|
||||||
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
subtitle: string;
|
subtitle: string;
|
||||||
cover: string;
|
cover: string;
|
||||||
postId: number;
|
postId: number;
|
||||||
characters: MiniItem[];
|
characters: RenderItem[];
|
||||||
voice: MiniItem;
|
|
||||||
time: {
|
time: {
|
||||||
str: string;
|
str: string;
|
||||||
startStamp: number;
|
startStamp: number;
|
||||||
endStamp: number;
|
endStamp: number;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 用于渲染的卡池角色头像
|
||||||
|
* @since Beta v0.4.4
|
||||||
|
* @interface RenderItem
|
||||||
|
* @property {string} icon 角色头像
|
||||||
|
* @property {string} url 角色详情页URL
|
||||||
|
* @property {TGApp.App.Character.WikiBriefInfo} info 角色简略信息
|
||||||
|
* @return RenderItem
|
||||||
|
*/
|
||||||
|
interface RenderItem {
|
||||||
|
icon: string;
|
||||||
|
url: string;
|
||||||
|
info?: TGApp.App.Character.WikiBriefInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,30 @@
|
|||||||
/**
|
/**
|
||||||
* @file plugins/Mys/utils/getGachaCard.ts
|
* @file plugins/Mys/utils/getGachaCard.ts
|
||||||
* @description Mys 插件抽卡工具
|
* @description Mys 插件抽卡工具
|
||||||
* @since Beta v0.3.9
|
* @since Beta v0.4.4
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { AppCharacterData } from "../../../data";
|
||||||
import getPostData from "../request/getPostData";
|
import getPostData from "../request/getPostData";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description 根据卡池信息转为渲染用的卡池信息
|
* @description 根据单个卡池信息转为渲染用的卡池信息
|
||||||
* @since Beta v0.3.9
|
* @since Beta v0.4.4
|
||||||
* @param {TGApp.Plugins.Mys.Gacha.Data[]} gachaData 卡池信息
|
* @param {TGApp.Plugins.Mys.Gacha.Data} data 卡池信息
|
||||||
* @param {Record<number, string>} poolCover 卡池封面
|
* @param {string} poolCover 卡池封面
|
||||||
* @returns {Promise<TGApp.Plugins.Mys.Gacha.RenderCard[]>}
|
* @returns {Promise<TGApp.Plugins.Mys.Gacha.RenderCard>}
|
||||||
*/
|
*/
|
||||||
async function getGachaCard(
|
async function getGachaItemCard(
|
||||||
gachaData: TGApp.Plugins.Mys.Gacha.Data[],
|
data: TGApp.Plugins.Mys.Gacha.Data,
|
||||||
poolCover?: Record<number, string>,
|
poolCover?: string,
|
||||||
): Promise<TGApp.Plugins.Mys.Gacha.RenderCard[]> {
|
): Promise<TGApp.Plugins.Mys.Gacha.RenderCard> {
|
||||||
const gachaCard: TGApp.Plugins.Mys.Gacha.RenderCard[] = [];
|
|
||||||
await Promise.allSettled(
|
|
||||||
gachaData.map(async (data: TGApp.Plugins.Mys.Gacha.Data) => {
|
|
||||||
let cover = "/source/UI/empty.webp";
|
let cover = "/source/UI/empty.webp";
|
||||||
const postId: number | undefined = Number(data.activity_url.split("/").pop()) || undefined;
|
const postId: number | undefined = Number(data.activity_url.split("/").pop()) || undefined;
|
||||||
if (postId === undefined || isNaN(postId)) {
|
if (postId === undefined || isNaN(postId)) {
|
||||||
throw new Error("无法获取帖子 ID");
|
throw new Error("无法获取帖子 ID");
|
||||||
}
|
}
|
||||||
if (poolCover !== undefined) {
|
if (poolCover !== undefined) {
|
||||||
cover = poolCover[postId];
|
cover = poolCover;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
console.log("调用 getPostData");
|
console.log("调用 getPostData");
|
||||||
@@ -37,28 +35,53 @@ async function getGachaCard(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const timeStr = `${data.start_time} ~ ${data.end_time}`;
|
const timeStr = `${data.start_time} ~ ${data.end_time}`;
|
||||||
return gachaCard.push({
|
const characters: TGApp.Plugins.Mys.Gacha.RenderItem[] = [];
|
||||||
|
for (const character of data.pool) {
|
||||||
|
const item: TGApp.Plugins.Mys.Gacha.RenderItem = {
|
||||||
|
icon: character.icon,
|
||||||
|
url: character.url,
|
||||||
|
};
|
||||||
|
const contentId = character.url.match(/(?<=content\/)\d+/)?.[0];
|
||||||
|
if (contentId) {
|
||||||
|
const itemF = AppCharacterData.find((item) => item.contentId.toString() === contentId);
|
||||||
|
if (itemF) {
|
||||||
|
item.info = itemF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
characters.push(item);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
id: data.id,
|
||||||
title: data.title,
|
title: data.title,
|
||||||
subtitle: data.content_before_act,
|
subtitle: data.content_before_act,
|
||||||
cover,
|
cover,
|
||||||
postId,
|
postId,
|
||||||
characters: data.pool.map((character) => ({
|
characters,
|
||||||
icon: character.icon,
|
|
||||||
url: character.url,
|
|
||||||
})),
|
|
||||||
voice: {
|
|
||||||
icon: data.voice_icon || "/source/UI/lumine.webp",
|
|
||||||
url: data.voice_url,
|
|
||||||
},
|
|
||||||
time: {
|
time: {
|
||||||
str: timeStr,
|
str: timeStr,
|
||||||
startStamp: new Date(data.start_time).getTime(),
|
startStamp: new Date(data.start_time).getTime(),
|
||||||
endStamp: new Date(data.end_time).getTime(),
|
endStamp: new Date(data.end_time).getTime(),
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 根据卡池信息转为渲染用的卡池信息
|
||||||
|
* @since Beta v0.4.4
|
||||||
|
* @param {TGApp.Plugins.Mys.Gacha.Data[]} gachaData 卡池信息
|
||||||
|
* @param {Record<number, string>} poolCover 卡池封面
|
||||||
|
* @returns {Promise<TGApp.Plugins.Mys.Gacha.RenderCard[]>}
|
||||||
|
*/
|
||||||
|
export async function getGachaCard(
|
||||||
|
gachaData: TGApp.Plugins.Mys.Gacha.Data[],
|
||||||
|
poolCover?: Record<number, string>,
|
||||||
|
): Promise<TGApp.Plugins.Mys.Gacha.RenderCard[]> {
|
||||||
|
const gachaCard: TGApp.Plugins.Mys.Gacha.RenderCard[] = [];
|
||||||
|
await Promise.allSettled(
|
||||||
|
gachaData.map(async (data: TGApp.Plugins.Mys.Gacha.Data) => {
|
||||||
|
const item = await getGachaItemCard(data, poolCover?.[Number(data.id)]);
|
||||||
|
gachaCard.push(item);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return gachaCard;
|
return gachaCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getGachaCard;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user