feat: 添加强制更新Lua脚本的配置并优化前端更新按钮
新增配置API的force_update字段返回与保存支持,更新终端Lua脚本逻辑以支持强制更新标记,同时简化前端更新按钮,移除模拟进度条并动态切换按钮状态与显示文本。
This commit is contained in:
+4
-8
@@ -815,14 +815,10 @@
|
||||
<div>
|
||||
<label style="display:block; margin-bottom:8px; font-weight:600;">Lua 脚本更新控制</label>
|
||||
<div class="flex" style="flex-direction: column; gap: 10px;">
|
||||
<div v-if="!isPushingUpdate">
|
||||
<button @click="pushLuaUpdate"><i class="fas fa-satellite-dish"></i> 手动推送更新</button>
|
||||
</div>
|
||||
<div v-else class="progress-container" style="width: 100%; max-width: 300px;">
|
||||
<div style="margin-bottom: 5px; font-size: 0.9rem; color: #666;">推送中... {{ updateProgress }}%</div>
|
||||
<div class="progress-bar" style="height: 10px; background: #eee; border-radius: 5px; overflow: hidden;">
|
||||
<div class="progress-fill" :style="{ width: updateProgress + '%', height: '100%', background: '#4caf50', transition: 'width 0.1s' }"></div>
|
||||
</div>
|
||||
<div>
|
||||
<button @click="pushLuaUpdate" :disabled="isPushingUpdate">
|
||||
<i class="fas fa-satellite-dish"></i> {{ isPushingUpdate ? '推送中...' : '手动推送更新' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="text-muted" style="font-size: 0.9rem;">
|
||||
点击按钮后,将向全服所有终端发送更新指令,并在 5 秒内生效。<br>终端将在业务空闲时静默下载更新并重启,未加载的机器在加载后也会第一时间更新。
|
||||
|
||||
+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