From ea1cfd0fa7644f32088e762b553f9faa63022206 Mon Sep 17 00:00:00 2001
From: Cx330 <1487537121@qq.com>
Date: Sun, 11 Jan 2026 12:33:46 +0800
Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=AD=A3=E5=BC=8F=E6=94=B9?=
=?UTF-8?q?=E5=90=8D=E4=B8=BAAgent=5FFor=5FSupmea=EF=BC=8C=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0API=20URL=E3=80=81Key=E3=80=81model=E7=9A=84=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E4=BD=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
manifest.json | 4 ++++
options.html | 42 ------------------------------------------
options.js | 33 ---------------------------------
popup.html | 40 ++++++++++++++++++++++++++++++++++++++++
popup.js | 42 ++++++++++++++++++++++++++++++++++++++++++
5 files changed, 86 insertions(+), 75 deletions(-)
delete mode 100644 options.html
delete mode 100644 options.js
create mode 100644 popup.html
create mode 100644 popup.js
diff --git a/manifest.json b/manifest.json
index 0102021..e255e97 100644
--- a/manifest.json
+++ b/manifest.json
@@ -6,6 +6,10 @@
"background": {
"service_worker": "background.js"
},
+ "action": {
+ "default_popup": "popup.html",
+ "default_title": "AI 配置"
+ },
"content_scripts": [
{
"matches": ["*://1718cloud.com/*"],
diff --git a/options.html b/options.html
deleted file mode 100644
index f25d606..0000000
--- a/options.html
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
- AI 配置中心
-
-
-
- ⚙️ 插件 AI 配置
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/options.js b/options.js
deleted file mode 100644
index 1f4fba1..0000000
--- a/options.js
+++ /dev/null
@@ -1,33 +0,0 @@
-const defaultApiUrl = "https://dashscope.aliyuncs.com/compatible-mode/v1";
-const defaultModel = "qwen-plus";
-
-// 保存设置
-document.getElementById('save').addEventListener('click', () => {
- const config = {
- apiUrl: document.getElementById('apiUrl').value.trim() || defaultApiUrl,
- apiKey: document.getElementById('apiKey').value.trim(),
- modelName: document.getElementById('modelName').value.trim() || defaultModel
- };
-
- chrome.storage.sync.set({ aiConfig: config }, () => {
- const status = document.getElementById('status');
- status.textContent = '✅ 配置已保存,请刷新网页生效。';
- status.style.color = 'green';
- setTimeout(() => { status.textContent = ''; }, 3000);
- });
-});
-
-// 加载设置
-document.addEventListener('DOMContentLoaded', () => {
- chrome.storage.sync.get(['aiConfig'], (result) => {
- if (result.aiConfig) {
- document.getElementById('apiUrl').value = result.aiConfig.apiUrl;
- document.getElementById('apiKey').value = result.aiConfig.apiKey;
- document.getElementById('modelName').value = result.aiConfig.modelName;
- } else {
- // 默认填充
- document.getElementById('apiUrl').value = defaultApiUrl;
- document.getElementById('modelName').value = defaultModel;
- }
- });
-});
\ No newline at end of file
diff --git a/popup.html b/popup.html
new file mode 100644
index 0000000..52304e6
--- /dev/null
+++ b/popup.html
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+ AI 模型配置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/popup.js b/popup.js
new file mode 100644
index 0000000..6aa5145
--- /dev/null
+++ b/popup.js
@@ -0,0 +1,42 @@
+// popup.js
+const defaultUrl = "https://api-inference.modelscope.cn/v1/";
+const defaultModel = "Qwen/Qwen2.5-Coder-32B-Instruct";
+
+// 初始化加载
+document.addEventListener('DOMContentLoaded', () => {
+ chrome.storage.sync.get(['aiConfig'], (result) => {
+ if (result.aiConfig) {
+ document.getElementById('apiUrl').value = result.aiConfig.apiUrl || defaultUrl;
+ document.getElementById('apiKey').value = result.aiConfig.apiKey || "";
+ document.getElementById('modelName').value = result.aiConfig.modelName || defaultModel;
+ } else {
+ document.getElementById('apiUrl').value = defaultUrl;
+ document.getElementById('modelName').value = defaultModel;
+ }
+ });
+});
+
+// 保存逻辑
+document.getElementById('save').addEventListener('click', () => {
+ const config = {
+ apiUrl: document.getElementById('apiUrl').value.trim(),
+ apiKey: document.getElementById('apiKey').value.trim(),
+ modelName: document.getElementById('modelName').value.trim()
+ };
+
+ if (!config.apiKey) {
+ showStatus("❌ 请输入 API Key", "#f56c6c");
+ return;
+ }
+
+ chrome.storage.sync.set({ aiConfig: config }, () => {
+ showStatus("✅ 配置已保存,刷新页面后生效", "#67c23a");
+ });
+});
+
+function showStatus(text, color) {
+ const status = document.getElementById('status');
+ status.textContent = text;
+ status.style.color = color;
+ setTimeout(() => { status.textContent = ''; }, 3000);
+}
\ No newline at end of file