fix reboot and updater

This commit is contained in:
kirillius 2026-08-15 00:44:29 +03:00
parent 6495186a15
commit fa7bfc32b3
4 changed files with 39 additions and 20 deletions

View File

@ -50,7 +50,7 @@ public class AppUpdateService extends AppService {
this.appLibraryPath = context.getLauncherConfig().getAppLibrary().toPath();
this.anchorClass = context.getClass();
this.httpClient = HttpClient.newBuilder()
.followRedirects(HttpClient.Redirect.NORMAL)
.followRedirects(HttpClient.Redirect.ALWAYS)
.connectTimeout(Duration.ofSeconds(10))
.build();
}

View File

@ -17,6 +17,7 @@ import { LogsPage } from '../pages/Logs.js';
import { NetworkResourcesPage } from '../pages/NetworkResources.js';
import { UnlockSitePage } from '../pages/UnlockSite.js';
import { LocalStoragesPage } from '../pages/LocalStorages.js';
import { RestartPage } from '../pages/Restart.js';
// Переменная для отслеживания текущего активного хеша (для корректного unmount)
@ -118,6 +119,11 @@ const routes = {
render: LocalStoragesPage.render,
mount: LocalStoragesPage.mount,
unmount: LocalStoragesPage.unmount
},
'#restart': {
render: RestartPage.render,
mount: RestartPage.mount,
unmount: RestartPage.unmount
}
};

View File

@ -0,0 +1,28 @@
import $ from 'jquery';
import { JSONRPC } from '@/json-rpc.js';
const REDIRECT_DELAY = 10000;
function mountRestartPage() {
$('#sidebar').hide();
JSONRPC.System.restart().finally(() => {
setTimeout(() => {
window.location.href = '/';
}, REDIRECT_DELAY);
});
}
export const RestartPage = {
render: () => `
<div class="flex-center" style="height: calc(100vh - 60px);">
<div class="card" style="min-width: 380px;">
<h2 style="margin: 0; color: var(--color-text); text-align: center;">Приложение перезапускается...</h2>
</div>
</div>
`,
mount: mountRestartPage,
unmount: () => {
$('#sidebar').show();
}
};

View File

@ -234,10 +234,8 @@ function attachEventHandlers() {
alert('Обновление ПО запущено!');
await updatePromise;
if (confirm('Обновление завершено. Перезагрузить?')) {
await JSONRPC.System.restart();
setTimeout(() => {
window.location.reload();
}, 10000);
window.location.hash = 'restart';
return;
}
await renderSystemAndManagerStatus();
} catch (e) {
@ -246,21 +244,8 @@ function attachEventHandlers() {
}
});
$('#restart-system-btn').off('click').on('click', async function () {
const $btn = $(this);
$btn.prop('disabled', true).text('Перезагрузка...');
try {
await JSONRPC.System.restart();
alert('Перезагрузка системы инициирована!');
setTimeout(() => {
window.location.reload();
}, 10000);
} catch (e) {
alert('Ошибка при перезагрузке системы!');
$btn.prop('disabled', false).text('Перезагрузить');
}
$('#restart-system-btn').off('click').on('click', function () {
window.location.hash = 'restart';
});
$('#save-config-btn').off('click').on('click', async function () {