mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-24 18:23:07 +08:00
Chrome Dify Chatbot Plug-in (#1378)
Co-authored-by: luowei <glpat-EjySCyNjWiLqAED-YmwM> Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:
39
third-party/chrome plug-in/options.js
vendored
Normal file
39
third-party/chrome plug-in/options.js
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
document.getElementById('save-button').addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
var baseUrl = document.getElementById('base-url').value;
|
||||
var token = document.getElementById('token').value;
|
||||
var errorTip = document.getElementById('error-tip');
|
||||
|
||||
if (baseUrl.trim() === "" || token.trim() === "") {
|
||||
if (baseUrl.trim() === "") {
|
||||
errorTip.textContent = "Base URL cannot be empty.";
|
||||
} else {
|
||||
errorTip.textContent = "Token cannot be empty.";
|
||||
}
|
||||
} else {
|
||||
errorTip.textContent = "";
|
||||
|
||||
chrome.storage.sync.set({
|
||||
'baseUrl': baseUrl,
|
||||
'token': token
|
||||
}, function () {
|
||||
alert('Save Success!');
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Load parameters from chrome.storage when the page loads
|
||||
chrome.storage.sync.get(['baseUrl', 'token'], function (result) {
|
||||
const baseUrlInput = document.getElementById('base-url');
|
||||
const tokenInput = document.getElementById('token');
|
||||
|
||||
if (result.baseUrl) {
|
||||
baseUrlInput.value = result.baseUrl;
|
||||
}
|
||||
|
||||
if (result.token) {
|
||||
tokenInput.value = result.token;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user