From 5c5d61560a59a4b4666a96d4587450f800c031ef Mon Sep 17 00:00:00 2001 From: stingshen Date: Sat, 6 Jan 2024 12:04:20 +0800 Subject: [PATCH] buxfix: set autocomplete attribute to api-key input (#1024) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * buxfix: set autocomplete attribute to api-key input * 调整变量名 --------- Co-authored-by: Keldos --- ChuanhuChatbot.py | 1 + web_assets/javascript/ChuanhuChat.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/ChuanhuChatbot.py b/ChuanhuChatbot.py index f515fbef..6c2a35d2 100644 --- a/ChuanhuChatbot.py +++ b/ChuanhuChatbot.py @@ -205,6 +205,7 @@ def create_new_model(): type="password", visible=not HIDE_MY_KEY, label="API-Key", + elem_id="api-key" ) if multi_api_key: usageTxt = gr.Markdown(i18n( diff --git a/web_assets/javascript/ChuanhuChat.js b/web_assets/javascript/ChuanhuChat.js index 93979a0c..a35e3d37 100644 --- a/web_assets/javascript/ChuanhuChat.js +++ b/web_assets/javascript/ChuanhuChat.js @@ -109,6 +109,7 @@ function initialize() { setPopupBoxPosition(); setSlider(); setCheckboxes(); + setAutocomplete(); checkModel(); settingBox.classList.add('hideBox'); @@ -336,6 +337,12 @@ function setChatbotScroll() { chatbotWrap.scrollTo(0,scrollHeight) } +function setAutocomplete() { + // 避免API Key被当成密码导致的模型下拉框被当成用户名而引发的浏览器自动填充行为 + const apiKeyInput = gradioApp().querySelector("#api-key input"); + apiKeyInput.setAttribute("autocomplete", "new-password"); +} + function clearChatbot(a, b) { clearHistoryHtml(); // clearMessageRows();