项目正式改名为Agent_For_Supmea,更新API URL、Key、model的添加位置
This commit is contained in:
parent
4d07077ea2
commit
ea1cfd0fa7
@ -6,6 +6,10 @@
|
|||||||
"background": {
|
"background": {
|
||||||
"service_worker": "background.js"
|
"service_worker": "background.js"
|
||||||
},
|
},
|
||||||
|
"action": {
|
||||||
|
"default_popup": "popup.html",
|
||||||
|
"default_title": "AI 配置"
|
||||||
|
},
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["*://1718cloud.com/*"],
|
"matches": ["*://1718cloud.com/*"],
|
||||||
|
|||||||
42
options.html
42
options.html
@ -1,42 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>AI 配置中心</title>
|
|
||||||
<style>
|
|
||||||
body { padding: 30px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; width: 400px; }
|
|
||||||
h2 { color: #333; border-bottom: 2px solid #409eff; padding-bottom: 10px; }
|
|
||||||
.form-group { margin-bottom: 15px; }
|
|
||||||
label { display: block; margin-bottom: 5px; font-weight: bold; color: #666; font-size: 14px; }
|
|
||||||
input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; }
|
|
||||||
.btn { background: #409eff; color: white; border: none; padding: 10px 20px; border-radius: 4px; cursor: pointer; width: 100%; font-size: 16px; transition: background 0.3s; }
|
|
||||||
.btn:hover { background: #66b1ff; }
|
|
||||||
#status { margin-top: 10px; text-align: center; font-size: 13px; height: 20px; }
|
|
||||||
.note { font-size: 12px; color: #999; margin-top: 5px; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2>⚙️ 插件 AI 配置</h2>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>API Base URL</label>
|
|
||||||
<input type="text" id="apiUrl" placeholder="例如: https://dashscope.aliyuncs.com/compatible-mode/v1">
|
|
||||||
<div class="note">魔搭/阿里千问通常使用兼容模式地址</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>API Key</label>
|
|
||||||
<input type="password" id="apiKey" placeholder="sk-...">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Model Name</label>
|
|
||||||
<input type="text" id="modelName" placeholder="例如: qwen-plus">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="save" class="btn">保存配置</button>
|
|
||||||
<div id="status"></div>
|
|
||||||
|
|
||||||
<script src="options.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
33
options.js
33
options.js
@ -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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
40
popup.html
Normal file
40
popup.html
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
body { width: 320px; padding: 15px; font-family: sans-serif; margin: 0; background: #f9fafc; }
|
||||||
|
h3 { margin-top: 0; color: #303133; font-size: 16px; border-left: 4px solid #409eff; padding-left: 8px; }
|
||||||
|
.item { margin-bottom: 12px; }
|
||||||
|
label { display: block; font-size: 12px; color: #606266; margin-bottom: 4px; }
|
||||||
|
input { width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #dcdfe6; border-radius: 4px; outline: none; }
|
||||||
|
input:focus { border-color: #409eff; }
|
||||||
|
.btn { background: #409eff; color: white; border: none; padding: 10px; border-radius: 4px; cursor: pointer; width: 100%; font-weight: bold; margin-top: 5px; }
|
||||||
|
.btn:hover { background: #66b1ff; }
|
||||||
|
#status { font-size: 12px; text-align: center; margin-top: 8px; height: 14px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h3>AI 模型配置</h3>
|
||||||
|
|
||||||
|
<div class="item">
|
||||||
|
<label>API Base URL</label>
|
||||||
|
<input type="text" id="apiUrl" placeholder="https://api-inference.modelscope.cn/v1/">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item">
|
||||||
|
<label>Access Token (API Key)</label>
|
||||||
|
<input type="password" id="apiKey" placeholder="输入您的 Token">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="item">
|
||||||
|
<label>Model ID</label>
|
||||||
|
<input type="text" id="modelName" placeholder="Qwen/Qwen2.5-Coder-32B-Instruct">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button id="save" class="btn">保存并生效</button>
|
||||||
|
<div id="status"></div>
|
||||||
|
|
||||||
|
<script src="popup.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
42
popup.js
Normal file
42
popup.js
Normal file
@ -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);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user