v0.6.25: Add self-update feature with hot reload
This commit is contained in:
@@ -17,6 +17,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="ohli24-header-right">
|
||||
<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>
|
||||
@@ -855,6 +858,37 @@ function getDragAfterElement(container, x) {
|
||||
}, { 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>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user