v0.6.25: Add self-update feature with hot reload

This commit is contained in:
2026-01-09 22:18:48 +09:00
parent 783b44b6b6
commit 1175acd16e
6 changed files with 238 additions and 3 deletions

View File

@@ -8,7 +8,12 @@
<div class="glass-card p-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h2 class="text-white font-weight-bold"><i class="bi bi-gear-fill mr-2"></i>Anilife 설정</h2>
{{ macros.m_button_group([['globalSettingSaveBtn', '설정 저장']])}}
<div>
<button type="button" class="btn btn-outline-info btn-sm mr-2" id="btn-self-update" title="최신 버전으로 업데이트">
<i class="bi bi-arrow-repeat"></i> 업데이트
</button>
{{ macros.m_button_group([['globalSettingSaveBtn', '설정 저장']])}}
</div>
</div>
{{ macros.m_row_start('5') }}
@@ -709,6 +714,37 @@ function getDragAfterElement(container, x) {
return [...container.querySelectorAll('.tag-chip:not(.dragging)')].reduce((c, el) => { var box = el.getBoundingClientRect(); var offset = x - box.left - box.width/2; return (offset < 0 && offset > c.offset) ? {offset, element: el} : c; }, {offset: Number.NEGATIVE_INFINITY}).element;
}
// ======================================
// 자가 업데이트 기능
// ======================================
$('#btn-self-update').on('click', function() {
if (!confirm('최신 코드를 다운로드하고 플러그인을 리로드하시겠습니까?')) return;
var btn = $(this);
var originalHTML = btn.html();
btn.prop('disabled', true).html('<i class="bi bi-arrow-repeat spin"></i> 업데이트 중...');
$.ajax({
url: '/' + package_name + '/ajax/' + sub + '/self_update',
type: 'POST',
dataType: 'json',
success: function(ret) {
if (ret.ret === 'success') {
$.notify('<strong>업데이트 완료!</strong> 페이지를 새로고침합니다.', {type: 'success'});
setTimeout(function() { location.reload(); }, 1500);
} else {
$.notify('<strong>업데이트 실패: ' + ret.msg + '</strong>', {type: 'danger'});
}
},
error: function() {
$.notify('<strong>업데이트 중 오류 발생</strong>', {type: 'danger'});
},
complete: function() {
btn.prop('disabled', false).html(originalHTML);
}
});
});
</script>
<style>