首页添加游戏签到组件,支持补签 (#182)

* Initial plan

* Add sign-in card component to homepage

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Fix v-icon usage in sign-in card buttons

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Fix: Merge new home components into existing localStorage

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Refactor: Remove redundant code in getShowItems

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Add error handling for localStorage parsing

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Redesign sign-in card to show multiple game accounts with compact UI

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Fix reward item spacing with flex properties

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Redesign sign-in card: grid layout, account switching, light mode fixes

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Add forceReload parameter to prevent unnecessary API calls

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Show multiple game accounts with grid layout and MiHoYo account in append

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Use unique keys and concurrent API requests for better performance

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Refactor sign-in component: split into reusable parts with user switcher

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Fix sign-in logic: highlight based on count not date, enable resign button

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Remove duplicate code and fix comment

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Add reward cell component, extra rewards support, and improved visual distinction

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* 🏷️ 添加Store类型,调整首页选项框宽度

* 🏷️签到 → 游戏签到

* ♻️ 首页组件重构,支持组件分享

* ♻️ 调整组件UI

* 💄 调整loading标题文本大小

* 💄 微调样式

* Refactor sign-in component: sequential loading, progress bar, internal data processing

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* Fix code review issues: correct gameInfo reference and add refresh event

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* 🎨 调整逻辑

* Refactor: self-contained data updates and numeric state enums

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* 🚸 调整排序逻辑

* 🚸 调整loading文本

* ✏️ 调整类型,修复打包失败

* ♻️ 添加补签相关请求

* 💄 调整脚本页布局

* 💄 调整首页布局

* Implement resign feature with local data updates and confirmation dialog

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* ✏️ 补充类型描述

* Fix resign logic: check is_sub, optimize resign info loading, improve success message

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* 🎨 调整逻辑,微调样式

* 🎨 调整唤起位置

* Add click handlers to reward cells for sign-in and resign actions

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* 🐛 对ID进行限制

* 💄 微调顶部gameNav样式

* Fix resign logic: only first missed day is clickable

Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>

* 🎨 放宽补签限制

* 🐛 修正删除逻辑判断

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: BTMuli <72692909+BTMuli@users.noreply.github.com>
Co-authored-by: BTMuli <bt-muli@outlook.com>
This commit is contained in:
Copilot
2025-12-14 02:01:26 +08:00
committed by GitHub
parent e000f3924c
commit 53174ffdd7
20 changed files with 1475 additions and 121 deletions

View File

@@ -1,28 +1,55 @@
/**
* @file store/modules/home.ts
* @description Home store module
* @since Beta v0.7.6
* 首页组件状态
* @since Beta v0.9.0
*/
import { defineStore } from "pinia";
import { ref } from "vue";
export type ShowItem = { show: boolean; order: number; label: string };
/**
* 默认展示项
*/
const defaultHomeShow: Array<TGApp.Store.Home.ShowItem> = [
{ show: false, order: 4, label: "游戏签到" },
{ show: true, order: 1, label: "限时祈愿" },
{ show: true, order: 2, label: "近期活动" },
{ show: true, order: 3, label: "素材日历" },
];
const useHomeStore = defineStore("home", () => {
const homeShow = ref<Array<ShowItem>>([
{ show: true, order: 1, label: "限时祈愿" },
{ show: true, order: 2, label: "近期活动" },
{ show: true, order: 3, label: "素材日历" },
]);
const homeShow = ref<Array<TGApp.Store.Home.ShowItem>>(defaultHomeShow);
const poolCover = ref<Record<number, string>>();
function getShowItems(): Array<string> {
const homeShowLocal = localStorage.getItem("homeShow");
if (homeShowLocal === null || !Array.isArray(JSON.parse(homeShowLocal))) {
if (homeShowLocal === null) {
localStorage.setItem("homeShow", JSON.stringify(homeShow.value));
} else {
try {
const storedItems: Array<TGApp.Store.Home.ShowItem> = JSON.parse(homeShowLocal);
if (!Array.isArray(storedItems)) {
// Invalid data, reset to default
localStorage.setItem("homeShow", JSON.stringify(homeShow.value));
} else {
// Merge with default items to add new items
const storedLabels = storedItems.map((i) => i.label);
// Add new items from default that don't exist in stored
for (const defaultItem of homeShow.value) {
if (!storedLabels.includes(defaultItem.label)) {
storedItems.push({ ...defaultItem });
}
}
// Remove items that no longer exist in default
const defaultLabels = homeShow.value.map((i) => i.label);
homeShow.value = storedItems.filter((item) => defaultLabels.includes(item.label));
localStorage.setItem("homeShow", JSON.stringify(homeShow.value));
}
} catch (e) {
console.error(e);
// Invalid JSON, reset to default
localStorage.setItem("homeShow", JSON.stringify(homeShow.value));
}
}
homeShow.value = JSON.parse(localStorage.getItem("homeShow")!);
return homeShow.value
.filter((item) => item.show)
.sort((a, b) => a.order - b.order)
@@ -30,11 +57,7 @@ const useHomeStore = defineStore("home", () => {
}
function init(): void {
homeShow.value = [
{ show: true, order: 1, label: "限时祈愿" },
{ show: true, order: 2, label: "近期活动" },
{ show: true, order: 3, label: "素材日历" },
];
homeShow.value = defaultHomeShow;
localStorage.setItem("homeShow", JSON.stringify(homeShow.value));
}
@@ -42,9 +65,13 @@ const useHomeStore = defineStore("home", () => {
let order = 1;
for (const item of items) {
const findIdx = homeShow.value.findIndex((i) => i.label === item);
if (findIdx === -1) continue;
homeShow.value[findIdx].show = true;
homeShow.value[findIdx].order = order++;
if (findIdx === -1) {
// Add new item if it doesn't exist
homeShow.value.push({ show: true, order: order++, label: item });
} else {
homeShow.value[findIdx].show = true;
homeShow.value[findIdx].order = order++;
}
}
for (const item of homeShow.value) if (!items.includes(item.label)) item.show = false;
localStorage.setItem("homeShow", JSON.stringify(homeShow.value));