popup.js 881 B

12345678910111213141516171819
  1. document.addEventListener('DOMContentLoaded', function () {
  2. var element = document.getElementById('myButton');
  3. chrome.storage.sync.get(['local_llm_url', 'local_llm_apiKey'], function (items) {
  4. document.getElementById('url').value = items.local_llm_url || 'http://llmtest.yangzhiqiang.tech/api/chat/generation';
  5. document.getElementById('apiKey').value = items.local_llm_apiKey || 'f2054ac961234ab1b3fd480125043472';
  6. })
  7. element.addEventListener('click', function () {
  8. var url = document.getElementById('url').value;
  9. var apiKey = document.getElementById('apiKey').value;
  10. if (!url || !apiKey) {
  11. alert('请输入url和apiKey');
  12. } else {
  13. chrome.storage.sync.set({ 'local_llm_url': url, 'local_llm_apiKey': apiKey }, function () {
  14. chrome.runtime.sendMessage({ action: "configFinish" });
  15. window.close();
  16. });
  17. }
  18. });
  19. });