Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
ce858fc
1
Parent(s):
9478f31
fix: 解决禁用更新后仍显示更新按钮的问题
Browse files- .gitignore +3 -1
- ChuanhuChatbot.py +1 -0
- web_assets/html/web_config.html +1 -0
- web_assets/javascript/ChuanhuChat.js +2 -5
- web_assets/javascript/updater.js +14 -0
- web_assets/stylesheet/ChuanhuChat.css +4 -0
.gitignore
CHANGED
|
@@ -149,4 +149,6 @@ tmp/
|
|
| 149 |
|
| 150 |
scripts/
|
| 151 |
include/
|
| 152 |
-
pyvenv.cfg
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
scripts/
|
| 151 |
include/
|
| 152 |
+
pyvenv.cfg
|
| 153 |
+
|
| 154 |
+
create_release.sh
|
ChuanhuChatbot.py
CHANGED
|
@@ -456,6 +456,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 456 |
|
| 457 |
with gr.Box(elem_id="web-config", visible=False):
|
| 458 |
gr.HTML(get_html('web_config.html').format(
|
|
|
|
| 459 |
hideHistoryWhenNotLoggedIn_config=hide_history_when_not_logged_in,
|
| 460 |
forView_i18n=i18n("仅供查看"),
|
| 461 |
deleteConfirm_i18n_pref=i18n("你真的要删除 "),
|
|
|
|
| 456 |
|
| 457 |
with gr.Box(elem_id="web-config", visible=False):
|
| 458 |
gr.HTML(get_html('web_config.html').format(
|
| 459 |
+
enableCheckUpdate_config=check_update,
|
| 460 |
hideHistoryWhenNotLoggedIn_config=hide_history_when_not_logged_in,
|
| 461 |
forView_i18n=i18n("仅供查看"),
|
| 462 |
deleteConfirm_i18n_pref=i18n("你真的要删除 "),
|
web_assets/html/web_config.html
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
<div aria-label="config-div" style="display:none;">
|
| 2 |
<!-- app config -->
|
| 3 |
<div id="app_config">
|
|
|
|
| 4 |
<span id="hideHistoryWhenNotLoggedIn_config">{hideHistoryWhenNotLoggedIn_config}</span>
|
| 5 |
</div>
|
| 6 |
<!-- i18n config -->
|
|
|
|
| 1 |
<div aria-label="config-div" style="display:none;">
|
| 2 |
<!-- app config -->
|
| 3 |
<div id="app_config">
|
| 4 |
+
<span id="enableCheckUpdate_config">{enableCheckUpdate_config}</span>
|
| 5 |
<span id="hideHistoryWhenNotLoggedIn_config">{hideHistoryWhenNotLoggedIn_config}</span>
|
| 6 |
</div>
|
| 7 |
<!-- i18n config -->
|
web_assets/javascript/ChuanhuChat.js
CHANGED
|
@@ -116,11 +116,8 @@ function initialize() {
|
|
| 116 |
if (!historyLoaded) loadHistoryHtml();
|
| 117 |
if (!usernameGotten) getUserInfo();
|
| 118 |
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
if (longTimeNoCheck && !updateInfoGotten && !isLatestVersion || isLatestVersion && !updateInfoGotten) {
|
| 122 |
-
updateLatestVersion();
|
| 123 |
-
}
|
| 124 |
setChatbotScroll();
|
| 125 |
setTimeout(showOrHideUserInfo(), 2000);
|
| 126 |
|
|
|
|
| 116 |
if (!historyLoaded) loadHistoryHtml();
|
| 117 |
if (!usernameGotten) getUserInfo();
|
| 118 |
|
| 119 |
+
setUpdater();
|
| 120 |
+
|
|
|
|
|
|
|
|
|
|
| 121 |
setChatbotScroll();
|
| 122 |
setTimeout(showOrHideUserInfo(), 2000);
|
| 123 |
|
web_assets/javascript/updater.js
CHANGED
|
@@ -2,6 +2,20 @@
|
|
| 2 |
var updateInfoGotten = false;
|
| 3 |
var isLatestVersion = localStorage.getItem('isLatestVersion') || false;
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
var statusObserver = new MutationObserver(function (mutationsList) {
|
| 7 |
for (const mutation of mutationsList) {
|
|
|
|
| 2 |
var updateInfoGotten = false;
|
| 3 |
var isLatestVersion = localStorage.getItem('isLatestVersion') || false;
|
| 4 |
|
| 5 |
+
function setUpdater() {
|
| 6 |
+
const enableCheckUpdate = gradioApp().querySelector('#enableCheckUpdate_config').innerText;
|
| 7 |
+
|
| 8 |
+
if (enableCheckUpdate == "False" || enableCheckUpdate == "false") {
|
| 9 |
+
gradioApp().classList.add('disable-update');
|
| 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) {
|
| 21 |
for (const mutation of mutationsList) {
|
web_assets/stylesheet/ChuanhuChat.css
CHANGED
|
@@ -1078,6 +1078,10 @@ input:checked + .chatbot-input-more-span {
|
|
| 1078 |
display: block;
|
| 1079 |
}
|
| 1080 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1081 |
#chatbot-area.no-menu #chatbot-header {
|
| 1082 |
padding-left: max(20px, env(safe-area-inset-left));
|
| 1083 |
}
|
|
|
|
| 1078 |
display: block;
|
| 1079 |
}
|
| 1080 |
|
| 1081 |
+
.disable-update .show-on-latest, .disable-update .show-on-outdated {
|
| 1082 |
+
display: none;
|
| 1083 |
+
}
|
| 1084 |
+
|
| 1085 |
#chatbot-area.no-menu #chatbot-header {
|
| 1086 |
padding-left: max(20px, env(safe-area-inset-left));
|
| 1087 |
}
|