feat(web): 添加全局Lua脚本批量推送更新
替换原有的单个设备版本升级功能,添加推送前的确认弹窗,自动提升售票机和检票机的补丁版本并开启强制更新,添加推送进度展示,更新前端UI与说明文案,新增推送结果提示与异常处理
This commit is contained in:
+34
-5
@@ -1476,10 +1476,39 @@ createApp({
|
||||
}, { successMessage: '保存成功' });
|
||||
};
|
||||
|
||||
const bumpLuaVersion = async (device) => {
|
||||
if (!config.lua_versions[device]) config.lua_versions[device] = 'v1.0.0';
|
||||
config.lua_versions[device] = bumpPatchVersion(config.lua_versions[device]);
|
||||
await saveConfig();
|
||||
const isPushingUpdate = ref(false);
|
||||
const updateProgress = ref(0);
|
||||
|
||||
const pushLuaUpdate = async () => {
|
||||
if (!confirm('确定要向所有机器推送更新指令吗?这将会使空闲机器静默更新并重启。')) return;
|
||||
|
||||
isPushingUpdate.value = true;
|
||||
updateProgress.value = 0;
|
||||
|
||||
// 自动提升版本号 & 开启 force_update
|
||||
if (!config.lua_versions.ticketmachine) config.lua_versions.ticketmachine = 'v1.0.0';
|
||||
if (!config.lua_versions.gate) config.lua_versions.gate = 'v1.0.0';
|
||||
config.lua_versions.ticketmachine = bumpPatchVersion(config.lua_versions.ticketmachine);
|
||||
config.lua_versions.gate = bumpPatchVersion(config.lua_versions.gate);
|
||||
config.force_update = true;
|
||||
|
||||
try {
|
||||
await requestJson('/api/config', { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(config) }, { expectOk: true });
|
||||
|
||||
// 模拟进度条,持续约 5 秒 (设备5秒轮询一次)
|
||||
for (let i = 0; i <= 100; i += 2) {
|
||||
updateProgress.value = i;
|
||||
await new Promise(resolve => setTimeout(resolve, 100)); // 100ms * 50 = 5000ms
|
||||
}
|
||||
|
||||
toast('推送指令发送完毕,终端将陆续更新', 'success');
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
toast('推送更新失败', 'error');
|
||||
} finally {
|
||||
isPushingUpdate.value = false;
|
||||
updateProgress.value = 100;
|
||||
}
|
||||
};
|
||||
|
||||
const exportData = () => {
|
||||
@@ -1733,7 +1762,7 @@ createApp({
|
||||
|
||||
saveCurrentFare, deleteCurrentFare, closeFareModal,
|
||||
|
||||
saveConfig, bumpLuaVersion, exportData, exportFareMap,
|
||||
saveConfig, isPushingUpdate, updateProgress, pushLuaUpdate, exportData, exportFareMap,
|
||||
formatTime, formatLogDetail, getStationName, getStationInfo, loadFareMap, fetchData, refreshData: fetchData,
|
||||
fareMapScale, fareMapLoading, fareMapError, zoomFareMapIn, zoomFareMapOut, zoomFareMapReset,
|
||||
isTransferStation, getTransferTitleSuffix, getTransferLineBadges
|
||||
|
||||
Reference in New Issue
Block a user