feat(vnt-web): 新增 /api/version,顶栏版本号不再依赖组网状态
This commit is contained in:
@@ -496,6 +496,7 @@ pub async fn run_http_server(
|
||||
.allow_headers(Any);
|
||||
|
||||
let app = Router::new()
|
||||
.route("/api/version", get(get_version))
|
||||
.route("/api/info", get(get_info))
|
||||
.route("/api/peers", get(get_peers))
|
||||
.route("/api/routes", get(get_routes))
|
||||
@@ -1021,6 +1022,11 @@ async fn restart_vnt_handler(
|
||||
}
|
||||
}
|
||||
|
||||
/// 客户端版本号,与组网状态无关,任何时刻都可获取
|
||||
async fn get_version() -> Json<ApiResponse<String>> {
|
||||
Json(ApiResponse::success(env!("CARGO_PKG_VERSION").to_string()))
|
||||
}
|
||||
|
||||
async fn get_info(
|
||||
State(state): State<HttpAppState>,
|
||||
Query(req): Query<FileReq>,
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -19,7 +19,7 @@
|
||||
if (dark) document.documentElement.classList.add("dark");
|
||||
})();
|
||||
</script>
|
||||
<script type="module" crossorigin src="/assets/index-CvlopnF8.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DM6YOQ55.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-xUGHQxai.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -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();
|
||||
// 页面加载时若有正在启动的实例,恢复其日志弹窗
|
||||
|
||||
Reference in New Issue
Block a user