mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2026-05-09 00:34:07 +08:00
* 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>
103 lines
2.7 KiB
Vue
103 lines
2.7 KiB
Vue
<!-- 米社用户切换菜单 -->
|
|
<template>
|
|
<v-menu location="bottom">
|
|
<template v-slot:activator="{ props: menuProps }">
|
|
<div class="sign-user-switch" v-bind="menuProps">
|
|
<span>{{ nickname }}({{ currentUid }})</span>
|
|
<v-icon size="small">mdi-chevron-down</v-icon>
|
|
</div>
|
|
</template>
|
|
<v-list>
|
|
<v-list-item v-for="ac in users" :key="ac.uid">
|
|
<v-list-item-title>{{ ac.brief.nickname }}</v-list-item-title>
|
|
<v-list-item-subtitle>{{ ac.brief.uid }}</v-list-item-subtitle>
|
|
<template #append>
|
|
<div v-if="ac.uid === currentUid" title="当前登录账号">
|
|
<v-icon color="green">mdi-account-check</v-icon>
|
|
</div>
|
|
<v-icon
|
|
v-else
|
|
icon="mdi-account-convert"
|
|
size="small"
|
|
title="切换用户"
|
|
@click="switchUser(ac.uid)"
|
|
/>
|
|
</template>
|
|
</v-list-item>
|
|
</v-list>
|
|
</v-menu>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import showSnackbar from "@comp/func/snackbar.js";
|
|
import TSUserAccount from "@Sqlm/userAccount.js";
|
|
import useUserStore from "@store/user.js";
|
|
import { storeToRefs } from "pinia";
|
|
import { onMounted, shallowRef } from "vue";
|
|
|
|
type Props = {
|
|
nickname: string;
|
|
currentUid: string;
|
|
};
|
|
|
|
type Emits = {
|
|
(e: "switch-user", uid: string): void;
|
|
};
|
|
|
|
const props = defineProps<Props>();
|
|
const emits = defineEmits<Emits>();
|
|
|
|
const { uid, briefInfo, cookie, account } = storeToRefs(useUserStore());
|
|
const users = shallowRef<Array<TGApp.App.Account.User>>([]);
|
|
|
|
onMounted(async () => {
|
|
await loadUsers();
|
|
});
|
|
|
|
async function loadUsers(): Promise<void> {
|
|
users.value = await TSUserAccount.account.getAllAccount();
|
|
}
|
|
|
|
async function switchUser(targetUid: string): Promise<void> {
|
|
if (targetUid === props.currentUid) {
|
|
showSnackbar.warn("该账户已经登录,无需切换");
|
|
return;
|
|
}
|
|
|
|
const accountGet = await TSUserAccount.account.getAccount(targetUid);
|
|
if (!accountGet) {
|
|
showSnackbar.warn(`未找到${targetUid}的账号信息,请重新登录`);
|
|
return;
|
|
}
|
|
|
|
uid.value = targetUid;
|
|
briefInfo.value = accountGet.brief;
|
|
cookie.value = accountGet.cookie;
|
|
|
|
const gameAccount = await TSUserAccount.game.getCurAccount(targetUid);
|
|
if (!gameAccount) {
|
|
showSnackbar.warn(`未找到${targetUid}的游戏账号信息,请尝试刷新`);
|
|
return;
|
|
}
|
|
|
|
account.value = gameAccount;
|
|
showSnackbar.success(`成功切换到用户${targetUid}`);
|
|
|
|
emits("switch-user", targetUid);
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.sign-user-switch {
|
|
display: flex;
|
|
align-items: center;
|
|
cursor: pointer;
|
|
gap: 4px;
|
|
user-select: none;
|
|
|
|
&:hover {
|
|
opacity: 0.8;
|
|
}
|
|
}
|
|
</style>
|