-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
182 additions
and
42 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 应用数据库中的角色类型 | ||
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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; | ||
|
@@ -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; | ||
|