Keldos commited on
Commit
242b04b
1 Parent(s): e662ff6

fix: 修复总是提示更新的问题等

Browse files

同时修复了双层黑色遮罩无法自己消除的问题

web_assets/javascript/updater.js CHANGED
@@ -1,6 +1,7 @@
1
 
2
  var updateInfoGotten = false;
3
- var isLatestVersion = localStorage.getItem('isLatestVersion') || false;
 
4
 
5
  function setUpdater() {
6
  const enableCheckUpdate = gradioApp().querySelector('#enableCheckUpdate_config').innerText;
@@ -10,11 +11,15 @@ function setUpdater() {
10
  return;
11
  }
12
 
 
 
 
13
  const lastCheckTime = localStorage.getItem('lastCheckTime') || 0;
 
14
  const longTimeNoCheck = currentTime - lastCheckTime > 3 * 24 * 60 * 60 * 1000;
15
- if (longTimeNoCheck && !updateInfoGotten && !isLatestVersion || isLatestVersion && !updateInfoGotten) {
16
- updateLatestVersion();
17
- }
18
  }
19
 
20
  var statusObserver = new MutationObserver(function (mutationsList) {
@@ -26,6 +31,7 @@ var statusObserver = new MutationObserver(function (mutationsList) {
26
  noUpdateHtml();
27
  localStorage.setItem('isLatestVersion', 'true');
28
  isLatestVersion = true;
 
29
  enableUpdateBtns();
30
  } else if (getUpdateStatus() === "failure") {
31
  updatingInfoElement.innerHTML = marked.parse(updateFailure_i18n, {mangle: false, headerIds: false});
@@ -86,11 +92,16 @@ async function updateLatestVersion() {
86
  if (currentVersion) {
87
  if (latestVersion <= currentVersion) {
88
  noUpdate();
 
 
 
89
  } else {
90
  latestVersionElement.textContent = latestVersion;
91
  console.log(`New version ${latestVersion} found!`);
92
  if (!isInIframe) openUpdateToast();
93
  gradioApp().classList.add('is-outdated');
 
 
94
  }
95
  enableUpdateBtns();
96
  } else { //如果当前版本号获取失败,使用时间比较
@@ -119,6 +130,8 @@ async function updateLatestVersion() {
119
  noUpdate("Local version check failed, it seems to be a local rivision. <br>But your revision is newer than the latest release.");
120
  gradioApp().classList.add('is-outdated');
121
  enableUpdateBtns()
 
 
122
  }
123
  }
124
  }
 
1
 
2
  var updateInfoGotten = false;
3
+ var isLatestVersion = localStorage.getItem('isLatestVersion') === "true" || false;
4
+ var shouldCheckUpdate = false;
5
 
6
  function setUpdater() {
7
  const enableCheckUpdate = gradioApp().querySelector('#enableCheckUpdate_config').innerText;
 
11
  return;
12
  }
13
 
14
+ if (!isLatestVersion) {
15
+ gradioApp().classList.add('is-outdated');
16
+ }
17
  const lastCheckTime = localStorage.getItem('lastCheckTime') || 0;
18
+ currentTime = new Date().getTime();
19
  const longTimeNoCheck = currentTime - lastCheckTime > 3 * 24 * 60 * 60 * 1000;
20
+ shouldCheckUpdate = !updateInfoGotten && (!isLatestVersion && longTimeNoCheck || isLatestVersion);
21
+ // console.log(`shouldCheckUpdate`, shouldCheckUpdate);
22
+ if (shouldCheckUpdate) updateLatestVersion();
23
  }
24
 
25
  var statusObserver = new MutationObserver(function (mutationsList) {
 
31
  noUpdateHtml();
32
  localStorage.setItem('isLatestVersion', 'true');
33
  isLatestVersion = true;
34
+ gradioApp().classList.remove('is-outdated');
35
  enableUpdateBtns();
36
  } else if (getUpdateStatus() === "failure") {
37
  updatingInfoElement.innerHTML = marked.parse(updateFailure_i18n, {mangle: false, headerIds: false});
 
92
  if (currentVersion) {
93
  if (latestVersion <= currentVersion) {
94
  noUpdate();
95
+ localStorage.setItem('isLatestVersion', 'true');
96
+ isLatestVersion = true;
97
+ gradioApp().classList.remove('is-outdated');
98
  } else {
99
  latestVersionElement.textContent = latestVersion;
100
  console.log(`New version ${latestVersion} found!`);
101
  if (!isInIframe) openUpdateToast();
102
  gradioApp().classList.add('is-outdated');
103
+ localStorage.setItem('isLatestVersion', 'false');
104
+ isLatestVersion = false;
105
  }
106
  enableUpdateBtns();
107
  } else { //如果当前版本号获取失败,使用时间比较
 
130
  noUpdate("Local version check failed, it seems to be a local rivision. <br>But your revision is newer than the latest release.");
131
  gradioApp().classList.add('is-outdated');
132
  enableUpdateBtns()
133
+ localStorage.setItem('isLatestVersion', 'false');
134
+ isLatestVersion = false;
135
  }
136
  }
137
  }
web_assets/javascript/webui.js CHANGED
@@ -39,11 +39,15 @@ function showMask(obj) {
39
  chatbotArea.querySelector('#chatbot-input-more-area').parentNode.appendChild(mask);
40
  } else if (obj == "update-toast") {
41
  mask.classList.add('chuanhu-top-mask');
 
 
 
 
 
42
  document.body.appendChild(mask);
43
  // mask.classList.add('transparent-mask');
44
  }
45
 
46
-
47
 
48
  mask.addEventListener('click', () => {
49
  if (obj == "box") {
 
39
  chatbotArea.querySelector('#chatbot-input-more-area').parentNode.appendChild(mask);
40
  } else if (obj == "update-toast") {
41
  mask.classList.add('chuanhu-top-mask');
42
+ if (document.querySelector('.chuanhu-top-mask')) {
43
+ for (var i = 0; i < document.querySelectorAll('.chuanhu-top-mask').length; i++) {
44
+ document.querySelectorAll('.chuanhu-top-mask')[i].remove();
45
+ }
46
+ }
47
  document.body.appendChild(mask);
48
  // mask.classList.add('transparent-mask');
49
  }
50
 
 
51
 
52
  mask.addEventListener('click', () => {
53
  if (obj == "box") {