mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
@@ -5,6 +5,17 @@
|
||||
<v-icon size="small"> mdi-calendar-clock</v-icon>
|
||||
<span>今日素材</span>
|
||||
<span>{{ dateNow }}</span>
|
||||
<!-- 如果是某人生日,显示礼物图标 -->
|
||||
<span
|
||||
@click="toBirthday"
|
||||
:style="{
|
||||
color: birthInfo.active ? 'var(--tgc-red-1)' : 'inherit',
|
||||
cursor: 'pointer',
|
||||
}"
|
||||
:title="birthInfo.text"
|
||||
>
|
||||
<v-icon size="small">mdi-gift</v-icon>
|
||||
</span>
|
||||
</div>
|
||||
<div class="calendar-title-mid">
|
||||
<v-btn
|
||||
@@ -64,6 +75,8 @@
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
|
||||
import { AppCalendarData } from "../../data";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
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";
|
||||
@@ -88,6 +101,12 @@ 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({
|
||||
active: false,
|
||||
text: "点击前往留影叙佳期",
|
||||
});
|
||||
|
||||
const btnText = [
|
||||
{
|
||||
week: 7,
|
||||
@@ -125,7 +144,14 @@ defineExpose({
|
||||
loading,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
const birthRes = await TGSqlite.isBirthday();
|
||||
if (birthRes !== false) {
|
||||
birthInfo.value = {
|
||||
active: true,
|
||||
text: `今天是${birthRes}的生日,\n快去送上祝福吧!`,
|
||||
};
|
||||
}
|
||||
const dayNow = new Date().getDay() === 0 ? 7 : new Date().getDay();
|
||||
const week = <{ week: number; text: string }>btnText.find((item) => item.week === dayNow);
|
||||
dateNow.value =
|
||||
@@ -174,6 +200,11 @@ async function share(): Promise<void> {
|
||||
const title = `【今日素材】${showType}${btnNow.value}`;
|
||||
await generateShareImg(title, div);
|
||||
}
|
||||
|
||||
// 前往留影叙佳期
|
||||
async function toBirthday(): Promise<void> {
|
||||
await TGClient.open("birthday");
|
||||
}
|
||||
</script>
|
||||
<style lang="css" scoped>
|
||||
.calendar-box {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file plugins Sqlite index.ts
|
||||
* @file plugins/Sqlite/index.ts
|
||||
* @description Sqlite 数据库操作类
|
||||
* @since Beta v0.3.3
|
||||
* @since Beta v0.3.6
|
||||
*/
|
||||
|
||||
import { app } from "@tauri-apps/api";
|
||||
@@ -521,6 +521,21 @@ class Sqlite {
|
||||
await db.execute(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 判断今天是否是某个角色的生日
|
||||
* @since Beta v0.3.6
|
||||
* @returns {Promise<false|string>}
|
||||
*/
|
||||
public async isBirthday(): Promise<false | string> {
|
||||
const db = await this.getDB();
|
||||
const dateNow = new Date();
|
||||
const date = `${dateNow.getMonth() + 1},${dateNow.getDate()}`;
|
||||
const sql = `SELECT name FROM AppCharacters WHERE birthday = '${date}';`;
|
||||
const res: Array<{ name: string }> = await db.select(sql);
|
||||
if (res.length === 0) return false;
|
||||
return res.map((item) => item.name).join("、");
|
||||
}
|
||||
}
|
||||
|
||||
const TGSqlite = new Sqlite();
|
||||
|
||||
@@ -125,7 +125,7 @@ class TGClient {
|
||||
case "tavern":
|
||||
return "https://m.miyoushe.com/ys/#/home/26";
|
||||
case "birthday":
|
||||
return "https://webstatic.mihoyo.com/ys/event/e20220303-birthday/index.html?game_biz=hk4e_cn&bbs_presentation_style=fullscreen&bbs_auth_required=true&bbs_landscape=true&activity_id=20220301153521&mhy_hide_status_bar=true&utm_source=bbs&utm_medium=mys&utm_campaign=arti";
|
||||
return "https://webstatic.mihoyo.com/ys/event/e20220303-birthday/index.html?activity_id=20220301153521";
|
||||
case "toolbox":
|
||||
return "https://webstatic.mihoyo.com/bbs/event/e20200511toolbox/index.html?game_biz=ys_cn";
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user