检测版本更新

close #231
This commit is contained in:
BTMuli
2026-03-10 12:46:46 +08:00
parent b5c7c6e8b1
commit c56b05b4f1
9 changed files with 1103 additions and 941 deletions

View File

@@ -3,7 +3,7 @@
"version": "0.9.7",
"description": "Game Tool for GenshinImpact player",
"private": true,
"packageManager": "pnpm@10.30.1",
"packageManager": "pnpm@10.32.0",
"type": "module",
"scripts": {
"build": "tsx scripts/auto-build.ts",
@@ -72,9 +72,9 @@
"dependencies": {
"@date-fns/tz": "^1.4.1",
"@mdi/font": "7.4.47",
"@sentry/core": "^10.40.0",
"@sentry/core": "^10.42.0",
"@sentry/vite-plugin": "^5.1.1",
"@sentry/vue": "^10.40.0",
"@sentry/vue": "^10.42.0",
"@skipperndt/plugin-machine-uid": "^0.1.3",
"@tauri-apps/api": "^2.10.1",
"@tauri-apps/plugin-cli": "^2.4.1",
@@ -104,24 +104,24 @@
"sass-embedded": "^1.97.3",
"swiper": "^12.1.2",
"uuid": "^13.0.0",
"vue": "^3.5.29",
"vue": "^3.5.30",
"vue-echarts": "^8.0.1",
"vue-json-pretty": "^2.6.0",
"vue-router": "^5.0.3",
"vuetify": "^4.0.0",
"vuetify": "^4.0.1",
"wcag-color": "^1.1.1"
},
"devDependencies": {
"@btmuli/stylelint-plugin-color": "^0.1.0",
"@eslint/eslintrc": "^3.3.4",
"@eslint/eslintrc": "^3.3.5",
"@eslint/js": "9.39.2",
"@microsoft/tsdoc": "^0.16.0",
"@tauri-apps/cli": "2.10.0",
"@tauri-apps/cli": "2.10.1",
"@types/fs-extra": "^11.0.4",
"@types/js-md5": "^0.8.0",
"@types/json-bigint": "^1.0.4",
"@types/node": "^25.3.1",
"@typescript-eslint/parser": "^8.56.1",
"@types/node": "^25.4.0",
"@typescript-eslint/parser": "^8.57.0",
"@typescript/native-preview": "7.0.0-dev.20260222.1",
"@vitejs/plugin-vue": "^6.0.4",
"app-root-path": "^3.1.0",
@@ -133,13 +133,13 @@
"eslint-plugin-prettier": "^5.5.5",
"eslint-plugin-tsdoc": "^0.5.2",
"eslint-plugin-vue": "^10.8.0",
"eslint-plugin-yml": "^3.3.0",
"fs-extra": "^11.3.3",
"globals": "^17.3.0",
"eslint-plugin-yml": "^3.3.1",
"fs-extra": "^11.3.4",
"globals": "^17.4.0",
"husky": "^9.1.7",
"jsonc-eslint-parser": "^3.1.0",
"lint-staged": "^16.2.7",
"oxlint": "^1.50.0",
"lint-staged": "16.2.7",
"oxlint": "^1.52.0",
"postcss-preset-env": "^11.2.0",
"prettier": "3.8.1",
"stylelint": "^17.4.0",
@@ -148,14 +148,14 @@
"stylelint-config-standard-vue": "^1.0.0",
"stylelint-declaration-block-no-ignored-properties": "^3.0.0",
"stylelint-high-performance-animation": "^2.0.0",
"stylelint-order": "^7.0.1",
"stylelint-order": "^8.0.0",
"stylelint-prettier": "^5.0.3",
"stylelint-scss": "^7.0.0",
"tsx": "^4.21.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.56.1",
"typescript-eslint": "^8.57.0",
"vite": "npm:rolldown-vite@^7.3.1",
"vite-plugin-vue-devtools": "^8.0.6",
"vite-plugin-vue-devtools": "^8.0.7",
"vite-plugin-vuetify": "^2.1.3",
"vue-eslint-parser": "^10.4.0",
"vue-tsc": "^3.2.5",

1787
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

74
src-tauri/Cargo.lock generated
View File

@@ -3561,17 +3561,9 @@ checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
dependencies = [
"bitflags 2.11.0",
"block2",
"libc",
"objc2",
"objc2-cloud-kit",
"objc2-core-data",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-core-image",
"objc2-core-text",
"objc2-core-video",
"objc2-foundation",
"objc2-quartz-core",
]
[[package]]
@@ -3591,7 +3583,6 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa"
dependencies = [
"bitflags 2.11.0",
"objc2",
"objc2-foundation",
]
@@ -3652,19 +3643,6 @@ dependencies = [
"objc2-core-graphics",
]
[[package]]
name = "objc2-core-video"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6"
dependencies = [
"bitflags 2.11.0",
"objc2",
"objc2-core-foundation",
"objc2-core-graphics",
"objc2-io-surface",
]
[[package]]
name = "objc2-encode"
version = "4.1.0"
@@ -3704,16 +3682,6 @@ dependencies = [
"objc2-core-foundation",
]
[[package]]
name = "objc2-javascript-core"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a1e6550c4caed348956ce3370c9ffeca70bb1dbed4fa96112e7c6170e074586"
dependencies = [
"objc2",
"objc2-core-foundation",
]
[[package]]
name = "objc2-quartz-core"
version = "0.3.2"
@@ -3726,17 +3694,6 @@ dependencies = [
"objc2-foundation",
]
[[package]]
name = "objc2-security"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a"
dependencies = [
"bitflags 2.11.0",
"objc2",
"objc2-core-foundation",
]
[[package]]
name = "objc2-ui-kit"
version = "0.3.2"
@@ -3780,8 +3737,6 @@ dependencies = [
"objc2-app-kit",
"objc2-core-foundation",
"objc2-foundation",
"objc2-javascript-core",
"objc2-security",
]
[[package]]
@@ -6163,9 +6118,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]]
name = "tauri"
version = "2.10.2"
version = "2.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "463ae8677aa6d0f063a900b9c41ecd4ac2b7ca82f0b058cc4491540e55b20129"
checksum = "da77cc00fb9028caf5b5d4650f75e31f1ef3693459dfca7f7e506d1ecef0ba2d"
dependencies = [
"anyhow",
"bytes",
@@ -6215,9 +6170,9 @@ dependencies = [
[[package]]
name = "tauri-build"
version = "2.5.5"
version = "2.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca7bd893329425df750813e95bd2b643d5369d929438da96d5bbb7cc2c918f74"
checksum = "4bbc990d1dbf57a8e1c7fa2327f2a614d8b757805603c1b9ba5c81bade09fd4d"
dependencies = [
"anyhow",
"cargo_toml",
@@ -6237,9 +6192,9 @@ dependencies = [
[[package]]
name = "tauri-codegen"
version = "2.5.4"
version = "2.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aac423e5859d9f9ccdd32e3cf6a5866a15bedbf25aa6630bcb2acde9468f6ae3"
checksum = "d4a24476afd977c5d5d169f72425868613d82747916dd29e0a357c84c4bd6d29"
dependencies = [
"base64 0.22.1",
"brotli",
@@ -6264,9 +6219,9 @@ dependencies = [
[[package]]
name = "tauri-macros"
version = "2.5.4"
version = "2.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6a1bd2861ff0c8766b1d38b32a6a410f6dc6532d4ef534c47cfb2236092f59"
checksum = "d39b349a98dadaffebb73f0a40dcd1f23c999211e5a2e744403db384d0c33de7"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@@ -6524,9 +6479,9 @@ dependencies = [
[[package]]
name = "tauri-runtime"
version = "2.10.0"
version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b885ffeac82b00f1f6fd292b6e5aabfa7435d537cef57d11e38a489956535651"
checksum = "2826d79a3297ed08cd6ea7f412644ef58e32969504bc4fbd8d7dbeabc4445ea2"
dependencies = [
"cookie",
"dpi",
@@ -6549,9 +6504,9 @@ dependencies = [
[[package]]
name = "tauri-runtime-wry"
version = "2.10.0"
version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5204682391625e867d16584fedc83fc292fb998814c9f7918605c789cd876314"
checksum = "e11ea2e6f801d275fdd890d6c9603736012742a1c33b96d0db788c9cdebf7f9e"
dependencies = [
"gtk",
"http 1.4.0",
@@ -6559,7 +6514,6 @@ dependencies = [
"log",
"objc2",
"objc2-app-kit",
"objc2-foundation",
"once_cell",
"percent-encoding",
"raw-window-handle",
@@ -6591,9 +6545,9 @@ dependencies = [
[[package]]
name = "tauri-utils"
version = "2.8.2"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcd169fccdff05eff2c1033210b9b94acd07a47e6fa9a3431cf09cfd4f01c87e"
checksum = "219a1f983a2af3653f75b5747f76733b0da7ff03069c7a41901a5eb3ace4557d"
dependencies = [
"anyhow",
"brotli",

View File

@@ -17,10 +17,10 @@ name = "teyvat_guide_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2.5.5", features = [] }
tauri-build = { version = "2.5.6", features = [] }
[dependencies]
chrono = "0.4.43"
chrono = "0.4.44"
image = "0.25.9"
log = "0.4.29"
prost = "=0.14.1"
@@ -28,8 +28,8 @@ prost-types = "=0.14.1"
sentry = { version = "0.46.2", features = ["backtrace", "panic"] }
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
tauri = { version = "2.10.2", features = ["tray-icon"] }
tauri-utils = "2.8.2"
tauri = { version = "2.10.3", features = ["tray-icon"] }
tauri-utils = "2.8.3"
tauri-plugin-machine-uid = "0.1.3"
url = "2.5.8"
walkdir = "2.5.0"

View File

@@ -59,7 +59,7 @@
{ "url": "https://*.mihoyo.com/*" },
{ "url": "https://homa.gentle.house/*" },
{ "url": "https://*.hoyoverse.com/*" },
{ "url": "https://api.hakush.in/*" }
{ "url": "https://api.github.com/repos/BTMuli/TeyvatGuide/releases/latest" }
]
}
],

View File

@@ -68,6 +68,7 @@
</template>
<script lang="ts" setup>
import TGameNav from "@comp/app/t-gameNav.vue";
import showDialog from "@comp/func/dialog.js";
import showLoading from "@comp/func/loading.js";
import showSnackbar from "@comp/func/snackbar.js";
import PhCompCalendar from "@comp/pageHome/ph-comp-calendar.vue";
@@ -78,6 +79,10 @@ import TSUserAccount from "@Sqlm/userAccount.js";
import useAppStore from "@store/app.js";
import useBBSStore from "@store/bbs.js";
import useHomeStore from "@store/home.js";
import { getVersion } from "@tauri-apps/api/app";
import { invoke } from "@tauri-apps/api/core";
import { openUrl } from "@tauri-apps/plugin-opener";
import { getLatestReleaseVersion } from "@utils/Github.js";
import TGLogger from "@utils/TGLogger.js";
import { storeToRefs } from "pinia";
import { defineComponent, onMounted, ref, shallowRef, watch } from "vue";
@@ -101,7 +106,7 @@ type SelectItem = {
const homeStore = useHomeStore();
const bbsStore = useBBSStore();
const { devMode, isLogin } = storeToRefs(useAppStore());
const { devMode, isLogin, lastUcts } = storeToRefs(useAppStore());
const { gameList } = storeToRefs(bbsStore);
const curGid = ref<number>(2);
@@ -130,6 +135,7 @@ onMounted(async () => {
}
oldItems.value = showItems.value;
await loadComp();
await checkAppUpdate();
});
watch(
@@ -205,6 +211,37 @@ async function loadEnd(item: ReturnType<typeof defineComponent>): Promise<void>
else showSnackbar.warn(`${compName} 已加载`);
if (loadItems.value.length === components.value.length) await showLoading.end();
}
async function checkAppUpdate(): Promise<void> {
const nowTs = Math.floor(Date.now() / 1000);
const diffTime = nowTs - lastUcts.value;
if (diffTime < 60 * 60 * 24) return;
await TGLogger.Info("[Home][CheckAppUpdate]检测版本更新");
const versionApp = await getVersion();
const versionCheck = await getLatestReleaseVersion();
if (versionCheck === "0") return;
if (versionCheck === versionApp) {
await TGLogger.Info(`[Home][CheckAppUpdate]版本号一致:${versionCheck}`);
lastUcts.value = nowTs;
return;
}
await TGLogger.Info(`[Home][CheckAppUpdate]检测到新版本:${versionCheck}`);
const check = await showDialog.checkF({
title: "检测到新版本",
text: `${versionApp}${versionCheck}`,
otcancel: false,
confirmLabel: "前往更新",
cancelLabel: "稍后提醒",
});
lastUcts.value = nowTs;
if (!check) return;
const isMsix = await invoke<boolean>("is_msix");
if (isMsix) {
await openUrl("ms-windows-store://pdp/?ProductId=9nlbnnnbnsjn");
return;
}
await openUrl("https://github.com/BTMuli/TeyvatGuide/releases/latest");
}
</script>
<style lang="scss" scoped>
.home-top-nav {

View File

@@ -1,6 +1,6 @@
/**
* 应用状态管理
* @since Beta v0.9.1
* @since Beta v0.9.8
*/
import bbsEnum from "@enum/bbs.js";
@@ -67,6 +67,11 @@ const useAppStore = defineStore(
const closeToTray = ref<boolean>(false);
/** 展示反馈按钮 */
const showFeedback = ref<boolean>(true);
/**
* 上次检测更新时间
* @remarks LastUpdateCheckTimeStamp
*/
const lastUcts = ref<number>(0);
/**
* 初始化应用状态
@@ -91,6 +96,7 @@ const useAppStore = defineStore(
cancelLike.value = true;
closeToTray.value = false;
showFeedback.value = true;
lastUcts.value = 0;
initDevice();
}
@@ -149,6 +155,7 @@ const useAppStore = defineStore(
cancelLike,
closeToTray,
showFeedback,
lastUcts,
init,
changeTheme,
getImageUrl,
@@ -178,6 +185,7 @@ const useAppStore = defineStore(
"cancelLike",
"closeToTray",
"showFeedback",
"lastUcts",
],
},
{

64
src/types/Plugins/Github.d.ts vendored Normal file
View File

@@ -0,0 +1,64 @@
/**
* Github API 类型
* @since Beta v0.9.8
*/
declare namespace TGApp.Plugins.Github {
/**
* LatestReleaseResponse
* @since Beta v0.9.8
* @see https://api.github.com/repos/BTMuli/TeyvatGuide/releases/latest
* @remarks 省略了不需要的子数据
*/
type LastestReleaseResp = {
/** URL */
url: string;
/** Assets URL */
assets_url: string;
/** Upload URL */
upload_url: string;
/** Html URL */
html_url: string;
/** Release ID */
id: number;
/** Author */
author: unknown;
/** Node ID */
node_id: string;
/** Tag */
tag_name: string;
/** Commit Hash */
target_commitish: string;
/** Release Name */
name: string;
/** Draft */
draft: boolean;
/** Immutable */
immutable: boolean;
/** PreRelease */
prerelease: boolean;
/**
* CreateTime
* @example 2026-02-26T10:33:04Z
*/
created_at: string;
/**
* UpdateTime
* @example 2026-02-27T08:53:27Z
*/
updated_at: string;
/**
* PublishTime
* @example 2026-02-27T08:53:27Z
*/
published_at: string;
/** Assets */
assets: Array<unknown>;
/** Tarball URL */
tarball_url: string;
/** Zipball URL */
zipball_url: string;
/** Release Body */
body: string;
};
}

26
src/utils/Github.ts Normal file
View File

@@ -0,0 +1,26 @@
/**
* Github API
* @since Beta v0.9.8
*/
import TGHttp from "@utils/TGHttp.js";
/**
* 获取最新Release版本
* @since Beta v0.9.8
* @returns 最新版本
*/
export async function getLatestReleaseVersion(): Promise<string> {
const latestReleaseApi: Readonly<string> =
"https://api.github.com/repos/BTMuli/TeyvatGuide/releases/latest";
try {
const latestReleaseResp = await TGHttp<TGApp.Plugins.Github.LastestReleaseResp>(
latestReleaseApi,
{ method: "GET" },
);
return latestReleaseResp.tag_name.replace("v", "");
} catch (e) {
console.error(e);
return "0";
}
}