Skip to content

Commit

Permalink
feat: 可以点击以重启
Browse files Browse the repository at this point in the history
chore: update i18n
  • Loading branch information
Keldos-Li committed Jan 20, 2024
1 parent 164fb4e commit 74da1a0
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 7 deletions.
11 changes: 11 additions & 0 deletions ChuanhuChatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def create_new_model():
update_btn=i18n("更新"),
seenew_btn=i18n("详情"),
ok_btn=i18n("好"),
close_btn=i18n("关闭"),
reboot_btn=i18n("立即重启"),
), visible=check_update)

with gr.Row(equal_height=True, elem_id="chuanhu-body"):
Expand Down Expand Up @@ -484,6 +486,8 @@ def create_new_model():
with gr.Box(elem_id="fake-gradio-components", visible=False):
updateChuanhuBtn = gr.Button(
visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
rebootChuanhuBtn = gr.Button(
visible=False, elem_classes="invisible-btn", elem_id="reboot-chuanhu-btn")
changeSingleSessionBtn = gr.Button(
visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
changeOnlineSearchBtn = gr.Button(
Expand Down Expand Up @@ -772,6 +776,13 @@ def create_greeting(request: gr.Request):
[status_display],
show_progress=True,
)
rebootChuanhuBtn.click(
reboot_chuanhu,
[],
[],
show_progress=True,
_js='rebootingChuanhu'
)
changeSingleSessionBtn.click(
fn=lambda value: gr.Checkbox.update(value=value),
inputs=[single_turn_checkbox],
Expand Down
3 changes: 3 additions & 0 deletions locale/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
"正在获取IP地址信息,请稍候...": "Getting IP address information, please wait...",
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Please clear the files in the knowledge base before trying to upload new files!",
"释放文件以上传": "Drop files to upload",
"关闭": "Close",
"立即重启": "Restart now",
"正在尝试重启...": "Trying to restart...",
"正在进行首次设置,请按照提示进行配置,配置将会被保存在": "First-time setup is in progress, please follow the prompts to configure, and the configuration will be saved in",
"中。": ".",
"在": "",
Expand Down
5 changes: 4 additions & 1 deletion locale/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,8 @@
"🧹 新的对话": "🧹 新しい会話",
"正在获取IP地址信息,请稍候...": "IPアドレス情報を取得しています、しばらくお待ちください...",
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ ナレッジベースの履歴ファイルを削除してから、アップロードを試してください!",
"释放文件以上传": "ファイルをアップロードするには、ここでドロップしてください"
"释放文件以上传": "ファイルをアップロードするには、ここでドロップしてください",
"关闭": "閉じる",
"立即重启": "今すぐ再起動",
"正在尝试重启...": "再起動を試みています..."
}
5 changes: 4 additions & 1 deletion locale/ko_KR.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,8 @@
"🧹 新的对话": "🧹 새로운 대화",
"正在获取IP地址信息,请稍候...": "IP 주소 정보를 가져오는 중입니다. 잠시만 기다려주세요...",
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ 먼저 지식 라이브러리에서 기록 파일을 삭제한 후 다시 업로드하세요!",
"释放文件以上传": "파일을 놓아 업로드"
"释放文件以上传": "파일을 놓아 업로드",
"关闭": "닫기",
"立即重启": "지금 재시작",
"正在尝试重启...": "재시작을 시도 중..."
}
5 changes: 4 additions & 1 deletion locale/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,8 @@
"🧹 新的对话": "🧹 Новый диалог",
"正在获取IP地址信息,请稍候...": "Получение информации об IP-адресе, пожалуйста, подождите...",
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Сначала удалите исторические файлы из базы знаний, а затем попробуйте загрузить!",
"释放文件以上传": "Отпустите файл для загрузки"
"释放文件以上传": "Отпустите файл для загрузки",
"关闭": "Закрыть",
"立即重启": "Перезапустить сейчас",
"正在尝试重启...": "Попытка перезапуска..."
}
5 changes: 4 additions & 1 deletion locale/sv_SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,8 @@
"🧹 新的对话": "🧹 Ny Dialog",
"正在获取IP地址信息,请稍候...": "Hämtar IP-adressinformation, vänta...",
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Ta bort historikfilen i kunskapsbanken innan du försöker ladda upp!",
"释放文件以上传": "Släpp filen för att ladda upp"
"释放文件以上传": "Släpp filen för att ladda upp",
"关闭": "Stäng",
"立即重启": "Starta om nu",
"正在尝试重启...": "Försöker starta om..."
}
5 changes: 4 additions & 1 deletion locale/vi_VN.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,8 @@
"🧹 新的对话": "🧹 Cuộc trò chuyện mới",
"正在获取IP地址信息,请稍候...": "Đang lấy thông tin địa chỉ IP, vui lòng đợi...",
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Vui lòng xóa tệp lịch sử trong cơ sở kiến thức trước khi tải lên!",
"释放文件以上传": "Thả tệp để tải lên"
"释放文件以上传": "Thả tệp để tải lên",
"关闭": "Đóng",
"立即重启": "Khởi động lại ngay",
"正在尝试重启...": "Đang cố gắng khởi động lại..."
}
5 changes: 5 additions & 0 deletions modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1405,3 +1405,8 @@ def setup_wizard():
wizard.save()
print(colorama.Back.GREEN + i18n("设置完成。现在请重启本程序。") + colorama.Style.RESET_ALL)
exit()

def reboot_chuanhu():
import sys
print(colorama.Back.GREEN + i18n("正在尝试重启...") + colorama.Style.RESET_ALL)
os.execl(sys.executable, sys.executable, *sys.argv)
4 changes: 4 additions & 0 deletions web_assets/html/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@
<button class="btn-update lg secondary svelte-cmf5ev" id="seenew-button" onclick="getUpdateInfo()">{seenew_btn}</button>
<button class="btn-update lg primary svelte-cmf5ev" id="ok-button" onclick="cancelUpdate()">{ok_btn}</button>
</div>
<div id="success-update-btn" class="btn-update-group hideK">
<button class="btn-update lg secondary svelte-cmf5ev" id="close-button" onclick="cancelUpdate()">{close_btn}</button>
<button class="btn-update lg primary svelte-cmf5ev" id="reboot-button" onclick="bgRebootChuanhu()">{reboot_btn}</button>
</div>
</div>
</div>
2 changes: 2 additions & 0 deletions web_assets/javascript/ChuanhuChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var sendBtn = null;
var cancelBtn = null;
var sliders = null;
var updateChuanhuBtn = null;
var rebootChuanhuBtn = null;
var statusDisplay = null;

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

historySelector = gradioApp().querySelector('#history-select-dropdown');
Expand Down
4 changes: 4 additions & 0 deletions web_assets/javascript/fake-gradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,7 @@ function bgSelectHistory(a,b){
let file = historySelectorInput.value;
return [a,file]
}

function bgRebootChuanhu() {
rebootChuanhuBtn.click()
}
12 changes: 10 additions & 2 deletions web_assets/javascript/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ var statusObserver = new MutationObserver(function (mutationsList) {
if (mutation.type === 'attributes' || mutation.type === 'childList') {
if (statusDisplay.innerHTML.includes('id="update-status"')) {
if (getUpdateStatus() === "success") {
updatingInfoElement.innerText = i18n(updateSuccess_i18n);
noUpdateHtml();
// noUpdateHtml();
updateSuccessHtml();
localStorage.setItem('isLatestVersion', 'true');
isLatestVersion = true;
gradioApp().classList.remove('is-outdated');
Expand Down Expand Up @@ -187,6 +187,14 @@ function manualCheckUpdate() {
currentTime = new Date().getTime();
localStorage.setItem('lastCheckTime', currentTime);
}

function updateSuccessHtml() {
updatingInfoElement.innerText = i18n(updateSuccess_i18n);
const gotoUpdateBtn = document.getElementById('goto-update-btn');
const successUpdateBtn = document.getElementById('success-update-btn');
gotoUpdateBtn.classList.add('hideK');
successUpdateBtn.classList.remove('hideK');
}
function noUpdate(message="") {
localStorage.setItem('isLatestVersion', 'true');
isLatestVersion = true;
Expand Down
8 changes: 8 additions & 0 deletions web_assets/javascript/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ function bindFancyBox() {
});
}

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

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

0 comments on commit 74da1a0

Please sign in to comment.