Added update button to main page

This commit is contained in:
Sam 2026-11-07 23:48:55 +08:00
parent 4c6e1e6f7e
commit 854e03fb14

View File

@ -225,6 +225,8 @@ return view.extend({
select.value = st.profile;
// mihomo serves its external-ui at /ui; metacubexd/zashboard take the API from the query
var updState = E('em', 'проверяю обновления…');
// shown only next to "есть обновление"; the same command as on «Система»
var updBtn = this.button('Обновить', 'apply', 'update', null, 'Скачать свежий kit и пересобрать профили?');
callUpdateCheck().then(function(u) {
if (u.error)
return dom.content(updState, '— не удалось проверить обновления: ' + u.error);
@ -232,7 +234,7 @@ return view.extend({
if (u.installed && u.installed.indexOf(u.latest) == 0)
return dom.content(updState, '— актуальная');
dom.content(updState, [ '— ', E('strong', 'есть обновление: '), link(u.commit, u.latest), ' ' + (u.message || '') ]
.concat(u.compare ? [ ' (', link(u.compare, 'что изменилось'), ')' ] : []));
.concat(u.compare ? [ ' (', link(u.compare, 'что изменилось'), ')' ] : []).concat([ ' ', updBtn ]));
}).catch(function(e) { dom.content(updState, '— не удалось проверить обновления: ' + e); });
var host = window.location.hostname;
var dash = 'http://' + host + ':' + st.api_port + '/ui/?hostname=' + encodeURIComponent(host) +