feat(update): add API endpoint to retrieve app version and update client-side calls

This commit is contained in:
t8y2
2026-05-05 16:01:38 +08:00
parent 3acd9280ac
commit 24537093ad
6 changed files with 23 additions and 10 deletions
+7 -10
View File
@@ -332,9 +332,9 @@ onMounted(async () => {
}
if (!needsAuth.value || authenticated.value) initApp();
api
.checkForUpdates()
.then((info) => {
appVersion.value = info.current_version;
.getAppVersion()
.then((v) => {
appVersion.value = v;
})
.catch(() => {});
return;
@@ -342,13 +342,10 @@ onMounted(async () => {
initApp();
setupFileDrop().catch(() => {});
checkUpdates({ silent: true });
import("@tauri-apps/api/app")
.then(({ getVersion }) => {
getVersion()
.then((v) => {
appVersion.value = v;
})
.catch(() => {});
api
.getAppVersion()
.then((v) => {
appVersion.value = v;
})
.catch(() => {});
setupTauriListeners();
+1
View File
@@ -109,6 +109,7 @@ export const deleteHistoryEntry = forward("deleteHistoryEntry");
// Updates
export const checkForUpdates = forward("checkForUpdates");
export const getAppVersion = forward("getAppVersion");
// Layout
export const saveSidebarLayout = forward("saveSidebarLayout");
+5
View File
@@ -543,6 +543,11 @@ export async function checkForUpdates(): Promise<UpdateInfo> {
return get("/api/update/check");
}
export async function getAppVersion(): Promise<string> {
const res: { version: string } = await get("/api/version");
return res.version;
}
// ---------------------------------------------------------------------------
// Layout
// ---------------------------------------------------------------------------
+5
View File
@@ -230,6 +230,11 @@ export async function checkForUpdates(): Promise<UpdateInfo> {
return invoke("check_for_updates");
}
export async function getAppVersion(): Promise<string> {
const { getVersion } = await import("@tauri-apps/api/app");
return getVersion();
}
// --- Redis ---
export interface RedisKeyInfo {
key: string;