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

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

View File

@@ -509,6 +509,12 @@ class SettingsManager {
this.temperatureInput.value = settings.temperature; this.temperatureInput.value = settings.temperature;
} }
// 先记录用户设置的提示词ID如果有
if (settings.currentPromptId) {
this.currentPromptId = settings.currentPromptId;
}
// 如果系统提示词内容已保存在设置中,先恢复它
if (settings.systemPrompt) { if (settings.systemPrompt) {
this.systemPromptInput.value = settings.systemPrompt; this.systemPromptInput.value = settings.systemPrompt;
} }
@@ -531,11 +537,6 @@ class SettingsManager {
this.proxyPortInput.value = settings.proxyPort; this.proxyPortInput.value = settings.proxyPort;
} }
// 加载当前选中的提示词ID
if (settings.currentPromptId) {
this.currentPromptId = settings.currentPromptId;
}
// Update UI based on model type // Update UI based on model type
this.updateUIBasedOnModelType(); this.updateUIBasedOnModelType();
@@ -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) {