Skip to content

Commit

Permalink
✨ 还是把生日加回来了,不然太空了
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Mar 31, 2024
1 parent d8ade95 commit ad81e0a
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 42 deletions.
15 changes: 0 additions & 15 deletions src/assets/icons/icon-wish.svg

This file was deleted.

64 changes: 64 additions & 0 deletions src/components/home/t-calendar-birth.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<template>
<div class="tcb-container">
<img v-if="isBirthday" src="/source/UI/empty.webp" alt="empty" />
<img @click="toPost()" v-else src="/source/UI/act_birthday.png" alt="empty" class="active" />
<span>{{
isBirthday ? `今天是 ${cur.map((i) => i.name).join("、")} 的生日!` : "没有角色今天过生日哦~"
}}</span>
<span v-if="next.length > 0"
>即将到来:{{ next[0].birthday[0] }}月{{ next[0].birthday[1] }}日</span
>
<span v-if="next.length > 0">{{ next.map((i) => i.name).join("、") }}</span>
</div>
</template>
<script lang="ts" setup>
import { onBeforeMount, ref } from "vue";
import { useRouter } from "vue-router";
import TSAvatarBirth from "../../plugins/Sqlite/modules/avatarBirth";
const isBirthday = ref<boolean>(false);
const router = useRouter();
const cur = ref<TGApp.Sqlite.Character.AppData[]>([]);
const next = ref<TGApp.App.Character.WikiBriefInfo[]>([]);
onBeforeMount(async () => {
const check = await TSAvatarBirth.isAvatarBirth();
if (check.length !== 0) {
isBirthday.value = true;
cur.value = check;
}
next.value = TSAvatarBirth.getNextAvatarBirth();
});
async function toPost() {
await router.push("/news/2");
}
</script>
<style lang="css" scoped>
.tcb-container {
display: flex;
width: 100%;
height: 100%;
flex-direction: column;
align-items: center;
justify-content: center;
box-shadow: 0 0 5px inset var(--common-shadow-2);
overflow-y: auto;
}
.tcb-container img {
width: 100px;
height: 100px;
}
.tcb-container img.active {
cursor: pointer;
}
span {
display: block;
margin-top: 10px;
text-align: center;
}
</style>
38 changes: 26 additions & 12 deletions src/components/home/t-calendar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<THomecard append>
<THomeCard append>
<template #title>今日素材 {{ dateNow }}</template>
<template #title-append>
<v-switch
Expand All @@ -26,23 +26,27 @@
</div>
<v-pagination class="tc-page" v-model="page" total-visible="20" :length="length" />
</div>
<div class="calendar-grid">
<div v-for="item in getGrid()" :key="item.id" @click="selectItem(item)">
<TibCalendarItem
:data="<TGApp.App.Calendar.Item>item"
:model="switchType"
:clickable="true"
/>
<div class="tc-content">
<TCalendarBirth />
<div class="calendar-grid">
<div v-for="item in getGrid()" :key="item.id" @click="selectItem(item)">
<TibCalendarItem
:data="<TGApp.App.Calendar.Item>item"
:model="switchType"
:clickable="true"
/>
</div>
</div>
</div>
</template>
</THomecard>
</THomeCard>
<ToCalendar v-model="showItem" :data-type="selectedType" :data-val="selectedItem" />
</template>
<script lang="ts" setup>
import { onMounted, ref } from "vue";
import THomecard from "./t-homecard.vue";
import TCalendarBirth from "./t-calendar-birth.vue";
import THomeCard from "./t-homecard.vue";
import { AppCalendarData } from "../../data";
import TibCalendarItem from "../itembox/tib-calendar-item.vue";
import ToCalendar from "../overlay/to-calendar.vue";
Expand Down Expand Up @@ -179,10 +183,20 @@ function getContents(day: number): void {
column-gap: 5px;
}
.tc-content {
position: relative;
display: flex;
height: 210px;
align-items: center;
justify-content: space-between;
column-gap: 10px;
}
.calendar-grid {
display: grid;
height: 100%;
grid-gap: 10px;
grid-template-columns: repeat(10, 1fr);
place-items: center flex-start;
grid-template-columns: repeat(10, 100px);
place-items: flex-start flex-start;
}
</style>
6 changes: 3 additions & 3 deletions src/components/home/t-pool.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<THomecard :append="hasNew">
<THomeCard :append="hasNew">
<template #title>限时祈愿</template>
<template #title-append>
<v-switch class="pool-switch" @change="switchPool" />
Expand Down Expand Up @@ -50,13 +50,13 @@
</div>
</div>
</template>
</THomecard>
</THomeCard>
</template>
<script lang="ts" setup>
import { ref, onMounted, onUnmounted } from "vue";
import { useRouter } from "vue-router";
import THomecard from "./t-homecard.vue";
import THomeCard from "./t-homecard.vue";
import Mys from "../../plugins/Mys";
import { useHomeStore } from "../../store/modules/home";
import { createPost, createTGWindow } from "../../utils/TGWindow";
Expand Down
6 changes: 3 additions & 3 deletions src/components/home/t-position.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<THomecard>
<THomeCard>
<template #title>近期活动</template>
<template #default>
<div class="position-grid">
Expand Down Expand Up @@ -35,12 +35,12 @@
</v-card>
</div>
</template>
</THomecard>
</THomeCard>
</template>
<script lang="ts" setup>
import { ref, onMounted, onUnmounted } from "vue";
import THomecard from "./t-homecard.vue";
import THomeCard from "./t-homecard.vue";
import Mys from "../../plugins/Mys";
import { createPost } from "../../utils/TGWindow";
import { stamp2LastTime } from "../../utils/toolFunc";
Expand Down
72 changes: 72 additions & 0 deletions src/plugins/Sqlite/modules/avatarBirth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* @file plugins/Sqlite/modules/avatarBirth.ts
* @description 角色生日模块
* @since Beta v0.4.5
*/

import { AppCharacterData } from "../../../data";
import TGSqlite from "../index";

/**
* @description 判断今天是不是角色生日
* @since Beta v0.4.5
* @param {[number,number]} date - 日期
* @return {Promise<TGApp.Sqlite.Character.AppData[]>} 角色生日
*/
async function isAvatarBirth(date?: [number, number]): Promise<TGApp.Sqlite.Character.AppData[]> {
let dateNow: [number, number];
if (date) {
dateNow = date;
} else {
const date = new Date();
dateNow = [date.getMonth() + 1, date.getDate()];
}
const db = await TGSqlite.getDB();
const sql = "SELECT * FROM AppCharacters WHERE birthday = ?";
return await db.select(sql, [dateNow.join(",")]);
}

/**
* @description 获取下一个角色生日
* @since Beta v0.4.5
* @param {[number,number]} date - 日期
* @return {TGApp.Sqlite.Character.AppData[]} 下一个角色生日
*/
function getNextAvatarBirth(date?: [number, number]): TGApp.App.Character.WikiBriefInfo[] {
const year = new Date().getFullYear();
let month, day;
if (date) {
month = date[0];
day = date[1];
} else {
const dateNow = new Date();
month = dateNow.getMonth() + 1;
day = dateNow.getDate();
}
const birthDateList: Date[] = [];
for (const item of AppCharacterData) {
if (item.birthday[0] === 0) {
continue;
}
if (item.birthday[0] < month || (item.birthday[0] === month && item.birthday[1] < day)) {
birthDateList.push(new Date(year + 1, item.birthday[0] - 1, item.birthday[1]));
} else {
birthDateList.push(new Date(year, item.birthday[0] - 1, item.birthday[1]));
}
}
birthDateList.sort((a, b) => a.getTime() - b.getTime());
const nextDateGet = birthDateList[0];
const nextDate = [nextDateGet.getMonth() + 1, nextDateGet.getDate()];
return (
AppCharacterData.filter(
(item) => item.birthday[0] === nextDate[0] && item.birthday[1] === nextDate[1],
) ?? []
);
}

const TSAvatarBirth = {
isAvatarBirth,
getNextAvatarBirth,
};

export default TSAvatarBirth;
23 changes: 14 additions & 9 deletions src/types/Sqlite/Character.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/**
* @file types Sqlite Character.d.ts
* @file types/Sqlite/Character.d.ts
* @description 角色相关类型定义文件
* @author BTMuli <[email protected]>
* @since Alpha v0.2.0
*/

/**
* @namespace TGApp.Sqlite.Character
* @since Alpha v0.2.0
* @description 角色相关类型定义命名空间
* @memberof TGApp.Sqlite
*/
declare namespace TGApp.Sqlite.Character {
/**
* @description 应用数据库中的角色类型
Expand All @@ -21,7 +26,7 @@ declare namespace TGApp.Sqlite.Character {
* @property {string} updated - 数据更新时间
* @return AppData
*/
export interface AppData {
interface AppData {
id: number;
name: string;
title: string;
Expand Down Expand Up @@ -54,7 +59,7 @@ declare namespace TGApp.Sqlite.Character {
* @property {string} updated - 数据更新时间
* @return UserRole
*/
export interface UserRole {
interface UserRole {
uid: number;
cid: number;
img: string;
Expand Down Expand Up @@ -86,7 +91,7 @@ declare namespace TGApp.Sqlite.Character {
* @property {number} affix - 武器精炼
* @return RoleWeapon
*/
export interface RoleWeapon {
interface RoleWeapon {
id: number;
name: string;
type: string;
Expand Down Expand Up @@ -114,7 +119,7 @@ declare namespace TGApp.Sqlite.Character {
* @property {string} set.effect[].description - 圣遗物套装效果描述
* @return RoleReliquary
*/
export interface RoleReliquary {
interface RoleReliquary {
id: number;
name: string;
pos: number;
Expand Down Expand Up @@ -144,7 +149,7 @@ declare namespace TGApp.Sqlite.Character {
* @property {number} pos - 命座位置
* @return RoleConstellation
*/
export interface RoleConstellation {
interface RoleConstellation {
id: number;
name: string;
icon: string;
Expand All @@ -162,7 +167,7 @@ declare namespace TGApp.Sqlite.Character {
* @property {string} icon - 时装图标
* @return RoleCostume
*/
export interface RoleCostume {
interface RoleCostume {
id: number;
name: string;
icon: string;
Expand All @@ -180,7 +185,7 @@ declare namespace TGApp.Sqlite.Character {
* @property {number} level - 天赋等级
* @return RoleTalent
*/
export interface RoleTalent {
interface RoleTalent {
id: number;
pos: number;
name: string;
Expand Down

0 comments on commit ad81e0a

Please sign in to comment.