mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
♻️ 移除留影叙佳期,重构卡池组件
This commit is contained in:
@@ -5,18 +5,6 @@
|
||||
<v-icon size="small" style="opacity: 0.8">mdi-calendar-clock</v-icon>
|
||||
<span>今日素材</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 class="calendar-title-mid">
|
||||
<v-btn
|
||||
@@ -76,9 +64,6 @@
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
|
||||
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 TibCalendarItem from "../itembox/tib-calendar-item.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 selectedType = ref<"avatar" | "weapon">("avatar");
|
||||
|
||||
// birthday
|
||||
const birthInfo = ref({
|
||||
isLogin: true,
|
||||
active: false,
|
||||
text: "点击前往留影叙佳期",
|
||||
});
|
||||
|
||||
const btnText = [
|
||||
{
|
||||
week: 7,
|
||||
@@ -147,16 +125,6 @@ interface TCalendarEmits {
|
||||
const emits = defineEmits<TCalendarEmits>();
|
||||
|
||||
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 week = <{ week: number; text: string }>btnText.find((item) => item.week === dayNow);
|
||||
dateNow.value =
|
||||
@@ -207,11 +175,6 @@ async function share(): Promise<void> {
|
||||
await generateShareImg(title, div);
|
||||
emits("loadOuter", { show: false });
|
||||
}
|
||||
|
||||
// 前往留影叙佳期
|
||||
async function toBirthday(): Promise<void> {
|
||||
await TGClient.open("birthday");
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
.calendar-box {
|
||||
|
||||
@@ -28,9 +28,14 @@
|
||||
v-for="character in pool.characters"
|
||||
:key="character.url"
|
||||
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>
|
||||
@@ -66,6 +71,7 @@ import { useHomeStore } from "../../store/modules/home";
|
||||
import { createPost, createTGWindow } from "../../utils/TGWindow";
|
||||
import { stamp2LastTime } from "../../utils/toolFunc";
|
||||
import showSnackbar from "../func/snackbar";
|
||||
import TItembox, { TItemBoxData } from "../main/t-itembox.vue";
|
||||
|
||||
// store
|
||||
const homeStore = useHomeStore();
|
||||
@@ -119,9 +125,9 @@ onMounted(async () => {
|
||||
console.info(gachaData);
|
||||
if (!checkCover(gachaData)) {
|
||||
poolCards.value = await Mys.Gacha.card(gachaData);
|
||||
const coverData: Record<number, string> = {};
|
||||
const coverData: Record<string, string> = {};
|
||||
poolCards.value.map((pool) => {
|
||||
coverData[pool.postId] = pool.cover;
|
||||
coverData[pool.id] = pool.cover;
|
||||
return pool;
|
||||
});
|
||||
homeStore.poolCover = coverData;
|
||||
@@ -160,54 +166,61 @@ onMounted(async () => {
|
||||
|
||||
// 检测新卡池
|
||||
function checkCover(data: TGApp.Plugins.Mys.Gacha.Data[]): boolean {
|
||||
// 如果没有缓存
|
||||
if (!homeStore.poolCover || Object.keys(homeStore.poolCover).length === 0) {
|
||||
return false;
|
||||
}
|
||||
// 获取缓存
|
||||
const cover = homeStore.poolCover satisfies Record<number, string>;
|
||||
if (cover === undefined) {
|
||||
return false;
|
||||
}
|
||||
return data.every((item) => {
|
||||
const postId = item.activity_url.split("/").pop();
|
||||
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";
|
||||
const cover = homeStore.poolCover;
|
||||
if (cover === undefined) return false;
|
||||
let checkList = data.length;
|
||||
Object.entries(cover).forEach(([key, value]) => {
|
||||
const pool = data.find((item) => item.id.toString() === key);
|
||||
if (pool && value !== "/source/UI/empty.webp") {
|
||||
checkList--;
|
||||
}
|
||||
});
|
||||
return checkList === 0;
|
||||
}
|
||||
|
||||
async function toOuter(url: string, title: string): Promise<void> {
|
||||
if (!url) {
|
||||
async function toOuter(
|
||||
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({
|
||||
text: "链接为空!",
|
||||
color: "error",
|
||||
});
|
||||
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);
|
||||
}
|
||||
|
||||
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> {
|
||||
showNew.value = !showNew.value;
|
||||
@@ -345,11 +358,8 @@ onUnmounted(() => {
|
||||
}
|
||||
|
||||
.pool-icon {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border: 1px solid var(--tgc-white-1);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 5px rgb(0 0 0/20%);
|
||||
max-width: 60px;
|
||||
max-height: 60px;
|
||||
transition: all ease-in-out 0.3s;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user