Keldos commited on
Commit
9e6f963
·
1 Parent(s): 4336d60

feat: 更新时加入加载动画

Browse files
assets/custom.css CHANGED
@@ -119,7 +119,7 @@ span.hideK {
119
  display: none;
120
  }
121
  #updating-info {
122
- margin: 12px 0px 20px;
123
  text-align: start;
124
  width: 100%;
125
  }
 
119
  display: none;
120
  }
121
  #updating-info {
122
+ margin: 16px 0px 24px;
123
  text-align: start;
124
  width: 100%;
125
  }
assets/custom.js CHANGED
@@ -549,6 +549,8 @@ var statusObserver = new MutationObserver(function (mutationsList) {
549
  updatingInfoElement.innerText = getUpdateStatus();
550
  }
551
  updateStatus.parentNode.removeChild(updateStatus);
 
 
552
  }
553
  }
554
  }
@@ -666,10 +668,14 @@ function getUpdateInfo() {
666
  window.open('https://github.com/gaizhenbiao/chuanhuchatgpt/releases/latest', '_blank');
667
  closeUpdateToast();
668
  }
 
669
  function bgUpdateChuanhu() {
670
  updateChuanhuBtn.click();
671
  updatingInfoElement.innerText = updatingMsg_i18n.hasOwnProperty(language) ? updatingMsg_i18n[language] : updatingMsg_i18n['en'];
 
 
672
  updatingInfoElement.classList.remove('hideK');
 
673
  const releaseNoteWrap = document.getElementById('release-note-wrap');
674
  releaseNoteWrap.style.setProperty('display', 'none');
675
  statusObserver.observe(statusDisplay, { childList: true, subtree: true, characterData: true});
@@ -719,6 +725,19 @@ function getUpdateStatus() {
719
  }
720
  }
721
 
 
 
 
 
 
 
 
 
 
 
 
 
 
722
  function setUpdateWindowHeight() {
723
  if (!showingUpdateInfo) {return;}
724
  const scrollPosition = window.scrollY;
 
549
  updatingInfoElement.innerText = getUpdateStatus();
550
  }
551
  updateStatus.parentNode.removeChild(updateStatus);
552
+ enableUpdateBtns();
553
+ updateSpinner.stop();
554
  }
555
  }
556
  }
 
668
  window.open('https://github.com/gaizhenbiao/chuanhuchatgpt/releases/latest', '_blank');
669
  closeUpdateToast();
670
  }
671
+ var updateSpinner = null;
672
  function bgUpdateChuanhu() {
673
  updateChuanhuBtn.click();
674
  updatingInfoElement.innerText = updatingMsg_i18n.hasOwnProperty(language) ? updatingMsg_i18n[language] : updatingMsg_i18n['en'];
675
+ var updatingSpinner = document.getElementById('updating-spinner');
676
+ updateSpinner = new Spin.Spinner({color:'#06AE56',top:'45%',lines:9}).spin(updatingSpinner);
677
  updatingInfoElement.classList.remove('hideK');
678
+ disableUpdateBtns();
679
  const releaseNoteWrap = document.getElementById('release-note-wrap');
680
  releaseNoteWrap.style.setProperty('display', 'none');
681
  statusObserver.observe(statusDisplay, { childList: true, subtree: true, characterData: true});
 
725
  }
726
  }
727
 
728
+ function disableUpdateBtns() {
729
+ const updatesButtons = document.querySelectorAll('.btn-update');
730
+ updatesButtons.forEach( function (btn) {
731
+ btn.disabled = true;
732
+ });
733
+ }
734
+ function enableUpdateBtns() {
735
+ const updatesButtons = document.querySelectorAll('.btn-update');
736
+ updatesButtons.forEach( function (btn) {
737
+ btn.disabled = false;
738
+ });
739
+ }
740
+
741
  function setUpdateWindowHeight() {
742
  if (!showingUpdateInfo) {return;}
743
  const scrollPosition = window.scrollY;
assets/html/update.html CHANGED
@@ -11,6 +11,7 @@
11
  <p id="updating-info" class="hideK">
12
  Getting update...
13
  </p>
 
14
  <div id="release-note-wrap">
15
  <div class="release-note-content" id="release-note-content">
16
  Getting Release Note...
 
11
  <p id="updating-info" class="hideK">
12
  Getting update...
13
  </p>
14
+ <div id="updating-spinner"></div>
15
  <div id="release-note-wrap">
16
  <div class="release-note-content" id="release-note-content">
17
  Getting Release Note...
modules/overwrites.py CHANGED
@@ -81,6 +81,7 @@ def reload_javascript():
81
  print("Reloading javascript...")
82
  js = f'<script>{customJS}</script><script async>{externalScripts}</script>'
83
  js += '<script async src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>'
 
84
  def template_response(*args, **kwargs):
85
  res = GradioTemplateResponseOriginal(*args, **kwargs)
86
  res.body = res.body.replace(b'</html>', f'{js}</html>'.encode("utf8"))
 
81
  print("Reloading javascript...")
82
  js = f'<script>{customJS}</script><script async>{externalScripts}</script>'
83
  js += '<script async src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>'
84
+ js += '<script async type="module" src="http://spin.js.org/spin.umd.js"></script><link type="text/css" href="https://spin.js.org/spin.css" rel="stylesheet" />'
85
  def template_response(*args, **kwargs):
86
  res = GradioTemplateResponseOriginal(*args, **kwargs)
87
  res.body = res.body.replace(b'</html>', f'{js}</html>'.encode("utf8"))