From 5992567d554130448db382c2a69368e9e04d2e27 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Thu, 26 Oct 2023 13:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=E5=88=A0=E9=99=A4=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E6=80=A7=E6=A3=80=E6=B5=8B=EF=BC=8C=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/Config.vue | 73 ++++++++++++++----------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/src/pages/common/Config.vue b/src/pages/common/Config.vue index 8b98042a..3f314030 100644 --- a/src/pages/common/Config.vue +++ b/src/pages/common/Config.vue @@ -104,7 +104,7 @@ - + - @@ -162,6 +158,7 @@ import { useAchievementsStore } from "../../store/modules/achievements"; import { useAppStore } from "../../store/modules/app"; import { useHomeStore } from "../../store/modules/home"; import { useUserStore } from "../../store/modules/user"; +import { getBuildTime } from "../../utils/TGBuild"; import { backupUiafData, restoreUiafData } from "../../utils/UIAF"; import TGRequest from "../../web/request/TGRequest"; import { backupAbyssData, backupCookieData } from "../../web/utils/backupData"; @@ -196,6 +193,7 @@ const loading = ref(true); const loadingTitle = ref("正在加载..."); const loadingSub = ref(""); const scan = ref(false); +const showReset = ref(false); // data const showHome = ref(homeStore.getShowValue()); @@ -304,7 +302,7 @@ async function confirmRefreshUser(): Promise { failCount++; } await TGSqlite.saveAppData("cookie", JSON.stringify(ck)); - const infoRes = await TGRequest.User.byCookie.getUserInfo(ck.cookie_token, ck.account_id); + const infoRes = await TGRequest.User.byCookie.getUserInfo(ck.cookie_token, ck.account_id, false); if ("retcode" in infoRes) { console.error(infoRes); loadingTitle.value = "获取失败!正在获取用户游戏账号信息"; @@ -475,6 +473,28 @@ async function confirmResetApp(): Promise { }, 1500); } +// 前置 +async function tryShowReset(): Promise { + const res = await showConfirm({ + title: "请输入验证 Code", + text: "请联系开发者获取", + mode: "input", + }); + const time = getBuildTime(); + const code = time.startsWith("dev.") ? "dev" : time; + if (res === code) { + showReset.value = true; + showSnackbar({ + text: "已开启重置数据库选项", + }); + } else { + showSnackbar({ + color: "error", + text: "验证失败", + }); + } +} + // 重置数据库 async function confirmResetDB(title?: string): Promise { const res = await showConfirm({ @@ -500,45 +520,6 @@ async function confirmResetDB(title?: string): Promise { }, 1500); } -// 检测数据库完整性 -async function confirmCheckDB(): Promise { - const resConfirm = await showConfirm({ - title: "确认检测数据库完整性吗?", - }); - if (!resConfirm) { - showSnackbar({ - color: "grey", - text: "已取消检测", - }); - return; - } - loadingTitle.value = "正在检查数据库表单完整性..."; - loading.value = true; - const res = await TGSqlite.check(); - await new Promise((resolve) => setTimeout(resolve, 1000)); - if (!res) { - loading.value = false; - await confirmResetDB("数据库表单不完整,是否重置数据库?"); - } else { - const appVersion = await app.getVersion(); - const dbVersion = dbInfo.value.find((item) => item.key === "appVersion")?.value; - const dbUpdatedTime = dbInfo.value.find((item) => item.key === "dataUpdated")?.value; - loading.value = false; - if (!dbVersion || dbVersion < appVersion) { - await confirmUpdate("数据库版本过低,是否更新数据库?"); - return; - } else if (!buildTime.value.startsWith("dev")) { - if (!dbUpdatedTime || dbUpdatedTime.startsWith("dev") || dbUpdatedTime < buildTime.value) { - await confirmUpdate("数据库可能过时,是否更新数据库?"); - return; - } - } - showSnackbar({ - text: "数据库已是最新!", - }); - } -} - // 开启 dev 模式 function submitDevMode(): void { appStore.devMode