Check upstream versions and label article-driven components
This commit is contained in:
@@ -1,6 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
jQuery(function ($) {
|
||||
const $updates = $('[data-about-updates]');
|
||||
const $check = $updates.find('[data-update-check]');
|
||||
const $updateStatus = $updates.find('[data-update-status]');
|
||||
$check.prop('hidden', false).on('click', function () {
|
||||
$check.prop('disabled', true);
|
||||
$updateStatus.text('正在查询上游仓库…');
|
||||
$.ajax({url: '/admin/about/update', dataType: 'json', timeout: 7500})
|
||||
.done(({current, latest, comparison}) => {
|
||||
if (comparison > 0) {
|
||||
$updateStatus.text('发现新版本 ' + latest + ',当前版本为 ' + current + '。');
|
||||
} else if (comparison < 0) {
|
||||
$updateStatus.text('当前版本 ' + current + ' 高于上游版本 ' + latest + '。');
|
||||
} else {
|
||||
$updateStatus.text('当前版本 ' + current + ' 已与上游仓库一致。');
|
||||
}
|
||||
})
|
||||
.fail(({status, responseJSON}) => {
|
||||
$updateStatus.text(status === 401 ? '登录已过期,请重新登录。' : (responseJSON?.message ?? '检查更新失败,请重试。'));
|
||||
})
|
||||
.always(() => $check.prop('disabled', false));
|
||||
});
|
||||
|
||||
const $metrics = $('[data-about-metrics]');
|
||||
if (!$metrics.length) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user