数据库更新后成就版本自动更新

This commit is contained in:
BTMuli
2023-05-25 18:33:58 +08:00
parent a428c86a7e
commit 71f5c30ff9
2 changed files with 17 additions and 2 deletions

View File

@@ -177,7 +177,7 @@ import { computed, onMounted, ref } from "vue";
import TLoading from "../components/overlay/t-loading.vue";
import TConfirm from "../components/overlay/t-confirm.vue";
// tauri
import { fs, app, os } from "@tauri-apps/api";
import { app, fs, os } from "@tauri-apps/api";
// store
import { useAppStore } from "../store/modules/app";
import { useHomeStore } from "../store/modules/home";
@@ -606,6 +606,7 @@ async function updateDB () {
loadingTitle.value = "正在更新数据库...";
loading.value = true;
await TGSqlite.update();
achievementsStore.lastVersion = await TGSqlite.getLatestAchievementVersion();
loading.value = false;
snackbarText.value = "数据库已是最新!";
snackbarColor.value = "success";

View File

@@ -2,7 +2,7 @@
* @file utils TGSqlite.ts
* @description 数据库操作类
* @author BTMuli<bt-muli@outlook.com>
* @since Alpha v0.1.5
* @since Alpha v0.1.6
*/
// tauri
@@ -263,6 +263,20 @@ class TGSqlite {
return res[0];
}
/**
* @description 获取最新成就版本
* @since Alpha v0.1.6
* @memberOf TGSqlite
* @returns {Promise<string>}
*/
public async getLatestAchievementVersion (): Promise<string> {
const db = await Database.load(this.dbPath);
const sql = "SELECT version FROM AchievementSeries ORDER BY version DESC LIMIT 1;";
const res: Array<{ version: string }> = await db.select(sql);
await db.close();
return res[0].version;
}
/**
* @description 查询成就
* @memberOf TGSqlite