feat: 添加强制更新Lua脚本的配置并优化前端更新按钮
新增配置API的force_update字段返回与保存支持,更新终端Lua脚本逻辑以支持强制更新标记,同时简化前端更新按钮,移除模拟进度条并动态切换按钮状态与显示文本。
This commit is contained in:
+1
-11
@@ -1477,13 +1477,11 @@ createApp({
|
||||
};
|
||||
|
||||
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';
|
||||
@@ -1494,20 +1492,12 @@ createApp({
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1762,7 +1752,7 @@ createApp({
|
||||
|
||||
saveCurrentFare, deleteCurrentFare, closeFareModal,
|
||||
|
||||
saveConfig, isPushingUpdate, updateProgress, pushLuaUpdate, exportData, exportFareMap,
|
||||
saveConfig, isPushingUpdate, 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