确保用户设置的提示词ID优先加载

This commit is contained in:
Zylan
2025-04-06 13:57:51 +08:00
parent 6f1f1ccce6
commit 2f36d3b294

View File

@@ -486,58 +486,59 @@ class SettingsManager {
this.highlightActivePreset(); this.highlightActivePreset();
} }
// Load reasoning depth & think budget settings // Load reasoning depth & think budget settings
if (settings.reasoningDepth) { if (settings.reasoningDepth) {
this.reasoningDepthSelect.value = settings.reasoningDepth; this.reasoningDepthSelect.value = settings.reasoningDepth;
// 更新推理深度选项UI // 更新推理深度选项UI
this.updateReasoningOptionUI(settings.reasoningDepth); this.updateReasoningOptionUI(settings.reasoningDepth);
} }
// 加载思考预算百分比 // 加载思考预算百分比
const thinkBudgetPercent = parseInt(settings.thinkBudgetPercent || '50'); const thinkBudgetPercent = parseInt(settings.thinkBudgetPercent || '50');
if (this.thinkBudgetPercentInput) { if (this.thinkBudgetPercentInput) {
this.thinkBudgetPercentInput.value = thinkBudgetPercent; this.thinkBudgetPercentInput.value = thinkBudgetPercent;
} }
// 更新思考预算显示和滑块背景 // 更新思考预算显示和滑块背景
this.updateThinkBudgetDisplay(); this.updateThinkBudgetDisplay();
this.updateThinkBudgetSliderBackground(); this.updateThinkBudgetSliderBackground();
this.highlightActiveThinkPreset(); this.highlightActiveThinkPreset();
// Load temperature setting // Load temperature setting
if (settings.temperature) { if (settings.temperature) {
this.temperatureInput.value = settings.temperature; this.temperatureInput.value = settings.temperature;
} }
if (settings.systemPrompt) { // 先记录用户设置的提示词ID如果有
this.systemPromptInput.value = settings.systemPrompt; if (settings.currentPromptId) {
} this.currentPromptId = settings.currentPromptId;
}
if (settings.language) { // 如果系统提示词内容已保存在设置中,先恢复它
this.languageInput.value = settings.language; if (settings.systemPrompt) {
} this.systemPromptInput.value = settings.systemPrompt;
}
// Load proxy settings if (settings.language) {
if (settings.proxyEnabled !== undefined) { this.languageInput.value = settings.language;
this.proxyEnabledInput.checked = settings.proxyEnabled; }
this.proxySettings.style.display = settings.proxyEnabled ? 'block' : 'none';
}
if (settings.proxyHost) { // Load proxy settings
this.proxyHostInput.value = settings.proxyHost; if (settings.proxyEnabled !== undefined) {
} this.proxyEnabledInput.checked = settings.proxyEnabled;
this.proxySettings.style.display = settings.proxyEnabled ? 'block' : 'none';
}
if (settings.proxyPort) { if (settings.proxyHost) {
this.proxyPortInput.value = settings.proxyPort; this.proxyHostInput.value = settings.proxyHost;
} }
// 加载当前选中的提示词ID if (settings.proxyPort) {
if (settings.currentPromptId) { this.proxyPortInput.value = settings.proxyPort;
this.currentPromptId = settings.currentPromptId; }
}
// Update UI based on model type // Update UI based on model type
this.updateUIBasedOnModelType(); this.updateUIBasedOnModelType();
} catch (error) { } catch (error) {
console.error('加载设置出错:', error); console.error('加载设置出错:', error);
@@ -1501,12 +1502,26 @@ class SettingsManager {
this.updatePromptSelect(); this.updatePromptSelect();
} }
// 如果有默认提示词,加载它 // 确定要加载的提示词ID
if (this.prompts.default) { let promptIdToLoad = null;
this.loadPrompt('default');
} else if (Object.keys(this.prompts).length > 0) { // 优先使用之前保存的currentPromptId
// 否则加载第一个提示词 if (this.currentPromptId && this.prompts[this.currentPromptId]) {
this.loadPrompt(Object.keys(this.prompts)[0]); promptIdToLoad = this.currentPromptId;
}
// 其次使用default提示词
else if (this.prompts.default) {
promptIdToLoad = 'default';
}
// 最后使用第一个可用的提示词
else if (Object.keys(this.prompts).length > 0) {
promptIdToLoad = Object.keys(this.prompts)[0];
}
// 如果找到了要加载的提示词,加载它
if (promptIdToLoad) {
this.loadPrompt(promptIdToLoad);
console.log('加载提示词:', promptIdToLoad);
} else { } else {
// 如果没有提示词,显示默认描述 // 如果没有提示词,显示默认描述
if (this.promptDescriptionElement) { if (this.promptDescriptionElement) {