🧪 剧诗表检测

This commit is contained in:
目棃
2024-11-11 17:58:20 +08:00
parent da4a095618
commit d88e1d1429
2 changed files with 24 additions and 0 deletions

View File

@@ -124,6 +124,7 @@ import TuaOverview from "../../components/userAbyss/tua-overview.vue";
import Hutao from "../../plugins/Hutao/index.js";
import TSUserAbyss from "../../plugins/Sqlite/modules/userAbyss.js";
import TSUserAvatar from "../../plugins/Sqlite/modules/userAvatar.js";
import TSUserCombat from "../../plugins/Sqlite/modules/userCombat.js";
import { useUserStore } from "../../store/modules/user.js";
import TGLogger from "../../utils/TGLogger.js";
import { generateShareImg } from "../../utils/TGShare.js";
@@ -169,6 +170,11 @@ watch(
);
async function toCombat(): Promise<void> {
const check = await TSUserCombat.check();
if (!check) {
showSnackbar({ text: "未检测到剧诗表,请更新数据库!", color: "warn" });
return;
}
await router.push({ name: "真境剧诗" });
}

View File

@@ -12,6 +12,23 @@ import { timestampToDate } from "../../../utils/toolFunc.js";
import TGSqlite from "../index.js";
import { transUserCombat } from "../utils/transUserCombat.js";
/**
* @description 数据表检测
* @since Beta v0.6.3
* @todo 版更后移除,该方法仅用于测试版过渡
* @return {Promise<boolean>}
*/
async function check(): Promise<boolean> {
const db = await TGSqlite.getDB();
try {
await db.select("SELECT DISTINCT uid FROM RoleCombat;");
return true;
} catch (e) {
console.log(e);
return false;
}
}
/**
* @description 直接插入数据
* @since Beta v0.6.3
@@ -148,6 +165,7 @@ async function restoreCombat(dir: string): Promise<boolean> {
}
const TSUserCombat = {
check,
getAllUid,
getCombat,
saveCombat,