Skip to content

Commit

Permalink
🧪 剧诗表检测
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Nov 11, 2024
1 parent da4a095 commit d88e1d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pages/User/Abyss.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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: "真境剧诗" });
}
Expand Down
18 changes: 18 additions & 0 deletions src/plugins/Sqlite/modules/userCombat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -148,6 +165,7 @@ async function restoreCombat(dir: string): Promise<boolean> {
}

const TSUserCombat = {
check,
getAllUid,
getCombat,
saveCombat,
Expand Down

0 comments on commit d88e1d1

Please sign in to comment.