feat: 实现设备注册和精准控制功能,支持双屏管理;更新相关逻辑以优化设备状态跟踪

This commit is contained in:
Pine
2026-08-19 14:19:37 +08:00
parent 93b27cf227
commit e72442dae0
15 changed files with 264 additions and 53 deletions
+13 -4
View File
@@ -6,20 +6,29 @@
import { getApiBase } from '../config';
import { invoke } from '@tauri-apps/api/core';
// 当前版本:发布新版本时同步 package.json 的 version
export const APP_VERSION = '0.1.0';
/** 读取真实安装的应用版本(Tauri getVersion = package.json/tauri.conf.json version);失败时兜底。 */
async function getCurrentVersion() {
try {
const { getVersion } = await import('@tauri-apps/api/app');
const v = await getVersion();
return v || '0.1.0';
} catch {
return '0.1.0';
}
}
export async function checkForUpdate() {
try {
const current = await getCurrentVersion();
const res = await fetch(`${getApiBase()}/api/update/check`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ current: APP_VERSION }),
body: JSON.stringify({ current }),
});
const data = await res.json();
if (data && data.ok) {
return {
current: APP_VERSION,
current,
latest: data.latest_version,
available: !!data.update_available,
url: `${getApiBase()}${data.download_url || '/download'}`,