feat(vnt-web): 新增 /api/version,顶栏版本号不再依赖组网状态

This commit is contained in:
lbl
2026-08-22 01:38:57 +08:00
parent 39a4e60d39
commit 0ccd045e78
6 changed files with 189 additions and 175 deletions
+3
View File
@@ -26,6 +26,9 @@ export const getRoutes = (fileName) =>
export const getStartStatus = (fileName) =>
request(`/api/start/status?file_name=${encodeURIComponent(fileName)}`);
// GET /api/version
export const getVersion = () => request("/api/version");
// GET /api/instances
export const getInstances = () => request("/api/instances");
+11 -6
View File
@@ -4,6 +4,7 @@ import {
getInstances,
getInstanceInfo,
getConfigList,
getVersion,
startVntApi,
stopVntApi,
restartVntApi,
@@ -54,13 +55,16 @@ export const useAppStore = defineStore("app", () => {
);
return inst ? inst.config_name || inst.file_name : selectedInstance.value;
});
const version = computed(() => {
for (const key in instances.value) {
const item = instances.value[key];
if (item && item.version) return item.version;
// 客户端版本号,来自 /api/version,与组网状态无关
const version = ref("");
const fetchVersion = async () => {
try {
version.value = (await getVersion()) || "";
} catch (e) {
console.error("Fetch version error", e);
}
return "";
});
};
const isServerConnected = computed(
() =>
!!(
@@ -214,6 +218,7 @@ export const useAppStore = defineStore("app", () => {
const init = async () => {
document.addEventListener("visibilitychange", visibilityHandler);
fetchVersion();
await fetchInstances();
fetchConfigList();
// 页面加载时若有正在启动的实例,恢复其日志弹窗