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