mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
♻️ 将更新检测上移到 app 层 #45
This commit is contained in:
25
src/App.vue
25
src/App.vue
@@ -17,11 +17,13 @@ import { useRouter } from "vue-router";
|
|||||||
|
|
||||||
import TBackTop from "./components/app/t-backTop.vue";
|
import TBackTop from "./components/app/t-backTop.vue";
|
||||||
import TSidebar from "./components/app/t-sidebar.vue";
|
import TSidebar from "./components/app/t-sidebar.vue";
|
||||||
|
import showConfirm from "./components/func/confirm";
|
||||||
import showSnackbar from "./components/func/snackbar";
|
import showSnackbar from "./components/func/snackbar";
|
||||||
import { getEmojis } from "./plugins/Mys/request/getEmojis";
|
import { getEmojis } from "./plugins/Mys/request/getEmojis";
|
||||||
import TGSqlite from "./plugins/Sqlite";
|
import TGSqlite from "./plugins/Sqlite";
|
||||||
import { useAppStore } from "./store/modules/app";
|
import { useAppStore } from "./store/modules/app";
|
||||||
import { useUserStore } from "./store/modules/user";
|
import { useUserStore } from "./store/modules/user";
|
||||||
|
import { getBuildTime } from "./utils/TGBuild";
|
||||||
|
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const isMain = ref<boolean>(false);
|
const isMain = ref<boolean>(false);
|
||||||
@@ -65,6 +67,7 @@ async function listenOnInit(): Promise<void> {
|
|||||||
await emojiLoad();
|
await emojiLoad();
|
||||||
await checkAppLoad();
|
await checkAppLoad();
|
||||||
await checkUserLoad();
|
await checkUserLoad();
|
||||||
|
await checkUpdate();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -204,6 +207,28 @@ async function getDeepLink(): Promise<void> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检测更新
|
||||||
|
async function checkUpdate(): Promise<void> {
|
||||||
|
const isProdEnv = import.meta.env.MODE === "production";
|
||||||
|
const needUpdate = await TGSqlite.checkUpdate();
|
||||||
|
if (needUpdate && isProdEnv) {
|
||||||
|
const confirm = await showConfirm({
|
||||||
|
title: "检测到版本更新",
|
||||||
|
text: "请到设置页手动更新版本,即将弹出更新说明子页面",
|
||||||
|
});
|
||||||
|
if (confirm) {
|
||||||
|
appStore.buildTime = getBuildTime();
|
||||||
|
window.open("https://app.btmuli.ink/docs/Changelogs.html");
|
||||||
|
} else {
|
||||||
|
showSnackbar({
|
||||||
|
text: "请到设置页手动更新版本!",
|
||||||
|
color: "error",
|
||||||
|
timeout: 3000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="css">
|
<style lang="css">
|
||||||
.app-container {
|
.app-container {
|
||||||
|
|||||||
@@ -8,15 +8,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { markRaw, onMounted, onUnmounted, onUpdated, ref } from "vue";
|
import { markRaw, onMounted, onUnmounted, onUpdated, ref } from "vue";
|
||||||
|
|
||||||
import showConfirm from "../../components/func/confirm";
|
|
||||||
import TCalendar from "../../components/home/t-calendar.vue";
|
import TCalendar from "../../components/home/t-calendar.vue";
|
||||||
import TPool from "../../components/home/t-pool.vue";
|
import TPool from "../../components/home/t-pool.vue";
|
||||||
import TPosition from "../../components/home/t-position.vue";
|
import TPosition from "../../components/home/t-position.vue";
|
||||||
import ToLoading from "../../components/overlay/to-loading.vue";
|
import ToLoading from "../../components/overlay/to-loading.vue";
|
||||||
import TGSqlite from "../../plugins/Sqlite";
|
|
||||||
import { useAppStore } from "../../store/modules/app";
|
import { useAppStore } from "../../store/modules/app";
|
||||||
import { useHomeStore } from "../../store/modules/home";
|
import { useHomeStore } from "../../store/modules/home";
|
||||||
import { getBuildTime } from "../../utils/TGBuild";
|
|
||||||
|
|
||||||
// store
|
// store
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
@@ -69,17 +66,6 @@ onMounted(async () => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
timer.value = setInterval(readLoading, 100);
|
timer.value = setInterval(readLoading, 100);
|
||||||
const needUpdate = await TGSqlite.checkUpdate();
|
|
||||||
if (needUpdate && isProdEnv) {
|
|
||||||
const confirm = await showConfirm({
|
|
||||||
title: "检测到版本更新",
|
|
||||||
text: "请到设置页手动更新版本,即将弹出更新说明子页面",
|
|
||||||
});
|
|
||||||
if (confirm) {
|
|
||||||
appStore.buildTime = getBuildTime();
|
|
||||||
}
|
|
||||||
window.open("https://app.btmuli.ink/docs/Changelogs.html");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function setItemRef(item: any): void {
|
function setItemRef(item: any): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user