默认关闭语音播放功能
This commit is contained in:
1 parent
c43b5e5ac1
commit
1b8f833789
6 files changed
+176
-112
No files matched your search
+23
-2
@@ -13,6 +13,20 @@
|
||||
.btn:hover { background: #66b1ff; }
|
||||
#status { font-size: 12px; text-align: center; margin-top: 8px; height: 14px; }
|
||||
.note { font-size: 11px; color: #999; margin-top: 4px; }
|
||||
|
||||
/* 语音开关专属样式 */
|
||||
.switch-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: #fff;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #dcdfe6;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.switch-item label { margin-bottom: 0; cursor: pointer; flex: 1; }
|
||||
.switch-item input { width: auto; cursor: pointer; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -21,7 +35,6 @@
|
||||
<div class="item">
|
||||
<label>API Base URL</label>
|
||||
<input type="text" id="apiUrl" placeholder="https://api-inference.modelscope.cn/v1">
|
||||
<div class="note">通常使用兼容模式地址</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
@@ -31,12 +44,20 @@
|
||||
|
||||
<div class="item">
|
||||
<label>Model Name</label>
|
||||
<input type="text" id="modelName" placeholder="deepseek-ai/DeepSeek-V3.2">
|
||||
<input type="text" id="modelName" placeholder="deepseek-ai/DeepSeek-V3">
|
||||
</div>
|
||||
|
||||
<div class="item switch-item">
|
||||
<label for="voiceEnabled">开启语音回复</label>
|
||||
<input type="checkbox" id="voiceEnabled">
|
||||
</div>
|
||||
|
||||
<button id="save" class="btn">保存并生效</button>
|
||||
|
||||
<div id="status"></div>
|
||||
|
||||
<div class="note">提示:保存配置后,请刷新目标页面使设置生效。</div>
|
||||
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+15
-4
@@ -1,12 +1,16 @@
|
||||
// 页面加载时读取存储的配置
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
chrome.storage.sync.get(['aiConfig'], (result) => {
|
||||
// 同时获取 aiConfig 和 voiceEnabled 状态
|
||||
chrome.storage.sync.get(['aiConfig', 'voiceEnabled'], (result) => {
|
||||
const config = result.aiConfig || {};
|
||||
|
||||
// 如果没有存储的值,则显示默认占位符或默认值
|
||||
// 填充 API 配置
|
||||
document.getElementById('apiUrl').value = config.apiUrl || DEFAULT_URL;
|
||||
document.getElementById('apiKey').value = config.apiKey || "";
|
||||
document.getElementById('modelName').value = config.modelName || DEFAULT_MODEL;
|
||||
|
||||
// 填充语音开关状态(默认为关闭 false)
|
||||
document.getElementById('voiceEnabled').checked = result.voiceEnabled || false;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,14 +22,19 @@ document.getElementById('save').addEventListener('click', () => {
|
||||
modelName: document.getElementById('modelName').value.trim() || DEFAULT_MODEL
|
||||
};
|
||||
|
||||
const isVoiceEnabled = document.getElementById('voiceEnabled').checked;
|
||||
|
||||
// 验证 API Key 是否填写
|
||||
if (!config.apiKey) {
|
||||
showStatus("❌ 请输入 API Key", "#f56c6c");
|
||||
return;
|
||||
}
|
||||
|
||||
// 存储到 chrome.storage
|
||||
chrome.storage.sync.set({ aiConfig: config }, () => {
|
||||
// 存储到 chrome.storage.sync
|
||||
chrome.storage.sync.set({
|
||||
aiConfig: config,
|
||||
voiceEnabled: isVoiceEnabled
|
||||
}, () => {
|
||||
showStatus("✅ 配置已保存,刷新页面生效", "#67c23a");
|
||||
});
|
||||
});
|
||||
@@ -35,6 +44,8 @@ function showStatus(text, color) {
|
||||
const status = document.getElementById('status');
|
||||
status.textContent = text;
|
||||
status.style.color = color;
|
||||
|
||||
// 3秒后清除提示
|
||||
setTimeout(() => {
|
||||
status.textContent = '';
|
||||
}, 3000);
|
||||
|
||||
Reference in new issue
Block a user