mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
♻️ 修改更新弹窗机制 #45
This commit is contained in:
@@ -13,6 +13,7 @@ import TCalendar from "../../components/home/t-calendar.vue";
|
||||
import TPool from "../../components/home/t-pool.vue";
|
||||
import TPosition from "../../components/home/t-position.vue";
|
||||
import ToLoading from "../../components/overlay/to-loading.vue";
|
||||
import TGSqlite from "../../plugins/Sqlite";
|
||||
import { useAppStore } from "../../store/modules/app";
|
||||
import { useHomeStore } from "../../store/modules/home";
|
||||
import { getBuildTime } from "../../utils/TGBuild";
|
||||
@@ -68,7 +69,8 @@ onMounted(async () => {
|
||||
}),
|
||||
);
|
||||
timer.value = setInterval(readLoading, 100);
|
||||
if (appStore.buildTime !== getBuildTime() && isProdEnv) {
|
||||
const needUpdate = await TGSqlite.checkUpdate();
|
||||
if (needUpdate && isProdEnv) {
|
||||
const confirm = await showConfirm({
|
||||
title: "检测到版本更新",
|
||||
text: "请到设置页手动更新版本,即将弹出更新说明子页面",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* @since Beta v0.3.3
|
||||
*/
|
||||
|
||||
import { app } from "@tauri-apps/api";
|
||||
import Database from "tauri-plugin-sql-api";
|
||||
|
||||
import initDataSql from "./sql/initData";
|
||||
@@ -87,6 +88,19 @@ class Sqlite {
|
||||
return await db.select(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 对比数据判断是否需要更新
|
||||
* @since Beta v0.3.3
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
public async checkUpdate(): Promise<boolean> {
|
||||
const dbData = await this.getAppData();
|
||||
const localVersion = await app.getVersion();
|
||||
const dbVersion = dbData.find((item) => item.key === "appVersion")?.value;
|
||||
if (dbVersion === undefined) return true;
|
||||
return localVersion !== dbVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取 cookie
|
||||
* @since Beta v0.3.3
|
||||
|
||||
26
src/types/Sqlite/AppData.d.ts
vendored
26
src/types/Sqlite/AppData.d.ts
vendored
@@ -1,22 +1,38 @@
|
||||
/**
|
||||
* @file types Sqlite AppData.d.ts
|
||||
* @description Sqlite AppData 类型定义文件
|
||||
* @author BTMuli<bt-muli@outlook.com>
|
||||
* @since Alpha v0.1.5
|
||||
* @since Beta v0.3.3
|
||||
*/
|
||||
|
||||
declare namespace TGApp.Sqlite.AppData {
|
||||
/**
|
||||
* @description AppData 数据库 - key 枚举
|
||||
* @since Beta v0.3.3
|
||||
* @enum {string}
|
||||
* @property {string} APP_VERSION - App 版本
|
||||
* @property {string} DATA_UPDATED - 数据库更新时间
|
||||
* @property {string} COOKIE - Cookie
|
||||
* @property {string} USER_INFO - 用户信息
|
||||
* @return {string}
|
||||
*/
|
||||
enum DBKey {
|
||||
APP_VERSION = "appVersion",
|
||||
DATA_UPDATED = "dataUpdated",
|
||||
COOKIE = "cookie",
|
||||
USER_INFO = "userInfo",
|
||||
}
|
||||
|
||||
/**
|
||||
* @description AppData 数据
|
||||
* @since Alpha v0.1.5
|
||||
* @since Beta v0.3.3
|
||||
* @interface Item
|
||||
* @property {string} key - 键
|
||||
* @property {DBKey} key - 键
|
||||
* @property {string} value - 值
|
||||
* @property {string} updated - 数据库更新时间
|
||||
* @return Item
|
||||
*/
|
||||
export interface Item {
|
||||
key: string;
|
||||
key: DBKey;
|
||||
value: string;
|
||||
updated: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user