feat(vnt-web): 配置变化提示与停止交互优化

- /api/info 新增 config_changed:与启动时的配置快照对比,启动后配置被修改(或文件缺失/解析失败)时实例卡片显示「配置发生变化」徽章,重启后自动消失
- 停止操作增加「停止中」中间态:徽章脉冲提示、按钮区禁用,实例真正停止后卡片渐隐消失,失败时自动恢复
- 停止/重启/移除确认弹窗优先显示配置名称,兜底文件名
This commit is contained in:
lbl
2026-08-22 01:27:39 +08:00
parent 6029fd113d
commit 39a4e60d39
11 changed files with 292 additions and 211 deletions
+13
View File
@@ -22,6 +22,8 @@ export const useAppStore = defineStore("app", () => {
const selectedInstance = ref(null);
const configList = ref([]);
const loadingMap = ref({});
// 停止中的实例:key=file_name;点击停止后置位,实例从列表消失或变为 stopped 时清除
const stoppingMap = ref({});
// 页面可见性
const isPageVisible = ref(!document.hidden);
@@ -93,6 +95,13 @@ export const useAppStore = defineStore("app", () => {
delete instances.value[key];
}
}
// 停止已生效(实例消失或进入 stopped)时清除停止中标记
for (const key of Object.keys(stoppingMap.value)) {
const inst = list.find((i) => i.file_name === key);
if (!inst || inst.status === "stopped") {
delete stoppingMap.value[key];
}
}
// 默认选中逻辑:当前选中失效时优先第一个 running,否则第一个,否则 null
if (
!selectedInstance.value ||
@@ -145,6 +154,7 @@ export const useAppStore = defineStore("app", () => {
const stopVnt = async (fileName) => {
if (!fileName || loadingMap.value[fileName]) return;
loadingMap.value[fileName] = true;
stoppingMap.value[fileName] = true;
try {
await stopVntApi(fileName);
ui.toast.success("已停止");
@@ -156,6 +166,8 @@ export const useAppStore = defineStore("app", () => {
} catch (e) {
ui.toast.error("停止失败: " + e.message);
console.error(e);
// 停止失败,恢复可操作状态
delete stoppingMap.value[fileName];
} finally {
loadingMap.value[fileName] = false;
}
@@ -231,6 +243,7 @@ export const useAppStore = defineStore("app", () => {
selectedInstance,
configList,
loadingMap,
stoppingMap,
isPageVisible,
runningCount,
startingCount,