mirror of
https://github.com/Zippland/Snap-Solver.git
synced 2026-03-03 16:45:26 +08:00
移除API密钥验证相关的代码和样式,删除无用的图片文件,优化进度指示器的样式和动画效果,调整设置面板的布局,简化API密钥管理功能,提升用户体验。
This commit is contained in:
@@ -230,45 +230,6 @@ class SettingsManager {
|
||||
});
|
||||
});
|
||||
|
||||
// Initialize API key validate buttons
|
||||
document.querySelectorAll('.validate-api-key').forEach(button => {
|
||||
button.addEventListener('click', (e) => {
|
||||
const keyType = e.currentTarget.getAttribute('data-key-type');
|
||||
const input = e.currentTarget.closest('.input-group').querySelector('input');
|
||||
const keyValue = input.value;
|
||||
|
||||
if (keyValue.trim() === '') {
|
||||
window.uiManager?.showToast('请先输入API密钥', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示验证中状态
|
||||
const icon = e.currentTarget.querySelector('i');
|
||||
const originalClass = icon.className;
|
||||
icon.className = 'fas fa-spinner fa-spin';
|
||||
e.currentTarget.disabled = true;
|
||||
|
||||
this.validateApiKey(keyType, keyValue)
|
||||
.then(result => {
|
||||
if (result.success) {
|
||||
window.uiManager?.showToast(result.message, 'success');
|
||||
// 更新状态显示
|
||||
this.saveSettings();
|
||||
} else {
|
||||
window.uiManager?.showToast(result.message, 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
window.uiManager?.showToast(`验证失败: ${error.message}`, 'error');
|
||||
})
|
||||
.finally(() => {
|
||||
// 恢复按钮状态
|
||||
icon.className = originalClass;
|
||||
e.currentTarget.disabled = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// 存储API密钥的对象
|
||||
this.apiKeyValues = {
|
||||
'AnthropicApiKey': '',
|
||||
@@ -1005,36 +966,6 @@ class SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证API密钥
|
||||
* @param {string} keyType 密钥类型
|
||||
* @param {string} keyValue 密钥值
|
||||
* @returns {Promise<Object>} 验证结果
|
||||
*/
|
||||
async validateApiKey(keyType, keyValue) {
|
||||
try {
|
||||
const response = await fetch('/api/keys/validate', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
key_type: keyType,
|
||||
key_value: keyValue
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`服务器响应错误: ${response.status}`);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error('验证API密钥时出错:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建一个Toast提示消息
|
||||
* @param {string} message 提示消息内容
|
||||
|
||||
Reference in New Issue
Block a user