Skip to content

Commit 74da1a0

Browse files
committed
feat: 可以点击以重启
chore: update i18n
1 parent 164fb4e commit 74da1a0

13 files changed

+67
-7
lines changed

ChuanhuChatbot.py

+11
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def create_new_model():
5555
update_btn=i18n("更新"),
5656
seenew_btn=i18n("详情"),
5757
ok_btn=i18n("好"),
58+
close_btn=i18n("关闭"),
59+
reboot_btn=i18n("立即重启"),
5860
), visible=check_update)
5961

6062
with gr.Row(equal_height=True, elem_id="chuanhu-body"):
@@ -484,6 +486,8 @@ def create_new_model():
484486
with gr.Box(elem_id="fake-gradio-components", visible=False):
485487
updateChuanhuBtn = gr.Button(
486488
visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
489+
rebootChuanhuBtn = gr.Button(
490+
visible=False, elem_classes="invisible-btn", elem_id="reboot-chuanhu-btn")
487491
changeSingleSessionBtn = gr.Button(
488492
visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
489493
changeOnlineSearchBtn = gr.Button(
@@ -772,6 +776,13 @@ def create_greeting(request: gr.Request):
772776
[status_display],
773777
show_progress=True,
774778
)
779+
rebootChuanhuBtn.click(
780+
reboot_chuanhu,
781+
[],
782+
[],
783+
show_progress=True,
784+
_js='rebootingChuanhu'
785+
)
775786
changeSingleSessionBtn.click(
776787
fn=lambda value: gr.Checkbox.update(value=value),
777788
inputs=[single_turn_checkbox],

locale/en_US.json

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@
141141
"正在获取IP地址信息,请稍候...": "Getting IP address information, please wait...",
142142
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Please clear the files in the knowledge base before trying to upload new files!",
143143
"释放文件以上传": "Drop files to upload",
144+
"关闭": "Close",
145+
"立即重启": "Restart now",
146+
"正在尝试重启...": "Trying to restart...",
144147
"正在进行首次设置,请按照提示进行配置,配置将会被保存在": "First-time setup is in progress, please follow the prompts to configure, and the configuration will be saved in",
145148
"中。": ".",
146149
"在": "",

locale/ja_JP.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,8 @@
140140
"🧹 新的对话": "🧹 新しい会話",
141141
"正在获取IP地址信息,请稍候...": "IPアドレス情報を取得しています、しばらくお待ちください...",
142142
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ ナレッジベースの履歴ファイルを削除してから、アップロードを試してください!",
143-
"释放文件以上传": "ファイルをアップロードするには、ここでドロップしてください"
143+
"释放文件以上传": "ファイルをアップロードするには、ここでドロップしてください",
144+
"关闭": "閉じる",
145+
"立即重启": "今すぐ再起動",
146+
"正在尝试重启...": "再起動を試みています..."
144147
}

locale/ko_KR.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,8 @@
140140
"🧹 新的对话": "🧹 새로운 대화",
141141
"正在获取IP地址信息,请稍候...": "IP 주소 정보를 가져오는 중입니다. 잠시만 기다려주세요...",
142142
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ 먼저 지식 라이브러리에서 기록 파일을 삭제한 후 다시 업로드하세요!",
143-
"释放文件以上传": "파일을 놓아 업로드"
143+
"释放文件以上传": "파일을 놓아 업로드",
144+
"关闭": "닫기",
145+
"立即重启": "지금 재시작",
146+
"正在尝试重启...": "재시작을 시도 중..."
144147
}

locale/ru_RU.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,8 @@
140140
"🧹 新的对话": "🧹 Новый диалог",
141141
"正在获取IP地址信息,请稍候...": "Получение информации об IP-адресе, пожалуйста, подождите...",
142142
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Сначала удалите исторические файлы из базы знаний, а затем попробуйте загрузить!",
143-
"释放文件以上传": "Отпустите файл для загрузки"
143+
"释放文件以上传": "Отпустите файл для загрузки",
144+
"关闭": "Закрыть",
145+
"立即重启": "Перезапустить сейчас",
146+
"正在尝试重启...": "Попытка перезапуска..."
144147
}

locale/sv_SE.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,8 @@
140140
"🧹 新的对话": "🧹 Ny Dialog",
141141
"正在获取IP地址信息,请稍候...": "Hämtar IP-adressinformation, vänta...",
142142
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Ta bort historikfilen i kunskapsbanken innan du försöker ladda upp!",
143-
"释放文件以上传": "Släpp filen för att ladda upp"
143+
"释放文件以上传": "Släpp filen för att ladda upp",
144+
"关闭": "Stäng",
145+
"立即重启": "Starta om nu",
146+
"正在尝试重启...": "Försöker starta om..."
144147
}

locale/vi_VN.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,8 @@
140140
"🧹 新的对话": "🧹 Cuộc trò chuyện mới",
141141
"正在获取IP地址信息,请稍候...": "Đang lấy thông tin địa chỉ IP, vui lòng đợi...",
142142
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Vui lòng xóa tệp lịch sử trong cơ sở kiến thức trước khi tải lên!",
143-
"释放文件以上传": "Thả tệp để tải lên"
143+
"释放文件以上传": "Thả tệp để tải lên",
144+
"关闭": "Đóng",
145+
"立即重启": "Khởi động lại ngay",
146+
"正在尝试重启...": "Đang cố gắng khởi động lại..."
144147
}

modules/utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -1405,3 +1405,8 @@ def setup_wizard():
14051405
wizard.save()
14061406
print(colorama.Back.GREEN + i18n("设置完成。现在请重启本程序。") + colorama.Style.RESET_ALL)
14071407
exit()
1408+
1409+
def reboot_chuanhu():
1410+
import sys
1411+
print(colorama.Back.GREEN + i18n("正在尝试重启...") + colorama.Style.RESET_ALL)
1412+
os.execl(sys.executable, sys.executable, *sys.argv)

web_assets/html/update.html

+4
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@
2525
<button class="btn-update lg secondary svelte-cmf5ev" id="seenew-button" onclick="getUpdateInfo()">{seenew_btn}</button>
2626
<button class="btn-update lg primary svelte-cmf5ev" id="ok-button" onclick="cancelUpdate()">{ok_btn}</button>
2727
</div>
28+
<div id="success-update-btn" class="btn-update-group hideK">
29+
<button class="btn-update lg secondary svelte-cmf5ev" id="close-button" onclick="cancelUpdate()">{close_btn}</button>
30+
<button class="btn-update lg primary svelte-cmf5ev" id="reboot-button" onclick="bgRebootChuanhu()">{reboot_btn}</button>
31+
</div>
2832
</div>
2933
</div>

web_assets/javascript/ChuanhuChat.js

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var sendBtn = null;
2626
var cancelBtn = null;
2727
var sliders = null;
2828
var updateChuanhuBtn = null;
29+
var rebootChuanhuBtn = null;
2930
var statusDisplay = null;
3031

3132
var historySelector = null;
@@ -82,6 +83,7 @@ function initialize() {
8283
cancelBtn = gradioApp().getElementById("cancel-btn");
8384
sliders = gradioApp().querySelectorAll('input[type="range"]');
8485
updateChuanhuBtn = gradioApp().getElementById("update-chuanhu-btn");
86+
rebootChuanhuBtn = gradioApp().getElementById("reboot-chuanhu-btn");
8587
statusDisplay = gradioApp().querySelector('#status-display');
8688

8789
historySelector = gradioApp().querySelector('#history-select-dropdown');

web_assets/javascript/fake-gradio.js

+4
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,7 @@ function bgSelectHistory(a,b){
115115
let file = historySelectorInput.value;
116116
return [a,file]
117117
}
118+
119+
function bgRebootChuanhu() {
120+
rebootChuanhuBtn.click()
121+
}

web_assets/javascript/updater.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ var statusObserver = new MutationObserver(function (mutationsList) {
2727
if (mutation.type === 'attributes' || mutation.type === 'childList') {
2828
if (statusDisplay.innerHTML.includes('id="update-status"')) {
2929
if (getUpdateStatus() === "success") {
30-
updatingInfoElement.innerText = i18n(updateSuccess_i18n);
31-
noUpdateHtml();
30+
// noUpdateHtml();
31+
updateSuccessHtml();
3232
localStorage.setItem('isLatestVersion', 'true');
3333
isLatestVersion = true;
3434
gradioApp().classList.remove('is-outdated');
@@ -187,6 +187,14 @@ function manualCheckUpdate() {
187187
currentTime = new Date().getTime();
188188
localStorage.setItem('lastCheckTime', currentTime);
189189
}
190+
191+
function updateSuccessHtml() {
192+
updatingInfoElement.innerText = i18n(updateSuccess_i18n);
193+
const gotoUpdateBtn = document.getElementById('goto-update-btn');
194+
const successUpdateBtn = document.getElementById('success-update-btn');
195+
gotoUpdateBtn.classList.add('hideK');
196+
successUpdateBtn.classList.remove('hideK');
197+
}
190198
function noUpdate(message="") {
191199
localStorage.setItem('isLatestVersion', 'true');
192200
isLatestVersion = true;

web_assets/javascript/utils.js

+8
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ function bindFancyBox() {
8585
});
8686
}
8787

88+
function rebootingChuanhu() {
89+
reloadSpinner = new Spin.Spinner({color:'#06AE56',lines:9}).spin();
90+
pageInfo = document.createElement('div');
91+
pageInfo.appendChild(reloadSpinner.el);
92+
pageInfo.innerHTML += '<h1 style="position: absolute; left: 50%; top: 50%; transform: translateX(-50%); color: lightgray; text-align: center; font-family: sans-serif;">Rebooting...</h1>'
93+
document.body.innerHTML = '';
94+
document.body.appendChild(pageInfo);
95+
}
8896

8997
/* NOTE: These reload functions are not used in the current version of the code.
9098
* From stable-diffusion-webui

0 commit comments

Comments
 (0)