Skip to content

Commit

Permalink
🎨 即时刷新
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Oct 7, 2024
1 parent 735e4fd commit 970a8a6
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions src/components/config/tc-gameBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import { path } from "@tauri-apps/api";
import { exists } from "@tauri-apps/plugin-fs";
import { Command } from "@tauri-apps/plugin-shell";
import { storeToRefs } from "pinia";
import { onMounted, ref } from "vue";
import { computed } from "vue";
import TSUserAccount from "../../plugins/Sqlite/modules/userAccount.js";
import { useAppStore } from "../../store/modules/app.js";
import { useUserStore } from "../../store/modules/user.js";
import TGLogger from "../../utils/TGLogger.js";
Expand All @@ -28,30 +27,13 @@ import showSnackbar from "../func/snackbar.js";
const userStore = storeToRefs(useUserStore());
const appStore = storeToRefs(useAppStore());
const account = ref<TGApp.Sqlite.Account.Game>();
onMounted(async () => {
if (!userStore.uid.value) return;
await refreshAccount();
});
async function refreshAccount(): Promise<void> {
const accountFind = await TSUserAccount.game.getCurAccount(userStore.uid.value!);
if (!accountFind) account.value = undefined;
else account.value = accountFind;
}
const account = computed<TGApp.Sqlite.Account.Game>(() => userStore.account.value);
async function tryPlayGame(): Promise<void> {
await refreshAccount();
if (!userStore.uid.value || !userStore.cookie.value) {
showSnackbar({ text: "请先登录!", color: "warn" });
return;
}
if (account.value === undefined) {
showSnackbar({ text: "未检测到当前登录用户!", color: "warn" });
return;
}
if (account.value.isOfficial === 0) {
showSnackbar({ text: "仅支持官服用户启动!", color: "warn" });
return;
Expand Down

0 comments on commit 970a8a6

Please sign in to comment.