更新模型相关文件,移除自动添加语言指令的逻辑,改为直接使用系统提供的提示词;同时优化下拉菜单的显示位置和交互逻辑,提升用户体验。

This commit is contained in:
Zylan
2025-04-06 14:15:19 +08:00
parent 2f36d3b294
commit 72601d2a55
6 changed files with 154 additions and 900 deletions

View File

@@ -209,11 +209,8 @@ class AlibabaModel(BaseModel):
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1"
)
# 检查系统提示词是否已包含语言设置指令
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答,无论问题是什么语言。即使在分析图像时也请使用{language}回答。"
# Prepare messages with image
messages = [

View File

@@ -195,14 +195,9 @@ class AnthropicModel(BaseModel):
'content-type': 'application/json'
}
# 获取系统提示词,确保包含语言设置
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
# 根据language参数设置回复语言
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答,无论问题是什么语言。即使在分析图像时也请使用{language}回答。这是最重要的指令。"
# 获取最大输出Token设置
max_tokens = 8192 # 默认值
if hasattr(self, 'max_tokens') and self.max_tokens:
@@ -227,7 +222,7 @@ class AnthropicModel(BaseModel):
},
{
'type': 'text',
'text': "请分析这个问题并提供详细的解决方案。如果你看到多个问题,请逐一解决。请务必使用中文回答。"
'text': "请分析这个问题并提供详细的解决方案。如果你看到多个问题,请逐一解决。"
}
]
}]

View File

@@ -66,11 +66,8 @@ class DeepSeekModel(BaseModel):
base_url="https://api.deepseek.com"
)
# 添加系统语言指令
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答。"
# 构建请求参数
params = {
@@ -244,11 +241,8 @@ class DeepSeekModel(BaseModel):
base_url="https://api.deepseek.com"
)
# 检查系统提示词是否已包含语言设置指令
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答,无论问题是什么语言。即使在分析图像时也请使用{language}回答。"
# 构建请求参数
params = {

View File

@@ -126,11 +126,8 @@ class OpenAIModel(BaseModel):
# Initialize OpenAI client
client = OpenAI(api_key=self.api_key)
# 检查系统提示词是否已包含语言设置指令
# 使用系统提供的系统提示词,不再自动添加语言指令
system_prompt = self.system_prompt
language = self.language or '中文'
if not any(phrase in system_prompt for phrase in ['Please respond in', '请用', '使用', '回答']):
system_prompt = f"{system_prompt}\n\n请务必使用{language}回答,无论问题是什么语言。即使在分析图像时也请使用{language}回答。"
# Prepare messages with image
messages = [

View File

@@ -187,11 +187,12 @@ class ModelSelector {
this.overlay.style.display = 'block';
this.dropdown.style.display = 'block';
// 设置下拉面板位置
const rect = this.display.getBoundingClientRect();
this.dropdown.style.width = `${rect.width}px`;
this.dropdown.style.top = `${rect.bottom + 5}px`;
this.dropdown.style.left = `${rect.left}px`;
// 设置面板位置 - 相对于视口
this.adjustDropdownPosition();
// 添加窗口调整大小和滚动事件监听器
window.addEventListener('resize', this.adjustDropdownPosition.bind(this));
window.addEventListener('scroll', this.adjustDropdownPosition.bind(this));
// 延迟添加可见类以启用过渡效果
setTimeout(() => {
@@ -210,6 +211,47 @@ class ModelSelector {
}, 100);
}
/**
* 调整下拉面板位置
*/
adjustDropdownPosition() {
if (!this.display || !this.dropdown) return;
// 获取模型选择器的位置
const rect = this.display.getBoundingClientRect();
// 设置下拉面板宽度
this.dropdown.style.width = `${rect.width}px`;
// 计算最佳位置
const viewportHeight = window.innerHeight;
const spaceBelow = viewportHeight - rect.bottom;
const spaceAbove = rect.top;
const dropdownHeight = Math.min(300, Math.max(this.dropdown.scrollHeight, 100));
// 检查下方空间是否足够
if (spaceBelow >= dropdownHeight || spaceBelow >= spaceAbove) {
// 显示在下方
this.dropdown.style.top = `${rect.bottom + 5}px`;
this.dropdown.style.bottom = 'auto';
} else {
// 显示在上方
this.dropdown.style.bottom = `${viewportHeight - rect.top + 5}px`;
this.dropdown.style.top = 'auto';
}
// 水平定位
this.dropdown.style.left = `${rect.left}px`;
// 检查是否超出右侧边界
const rightEdge = rect.left + rect.width;
const viewportWidth = window.innerWidth;
if (rightEdge > viewportWidth) {
this.dropdown.style.left = 'auto';
this.dropdown.style.right = '10px';
}
}
/**
* 关闭下拉面板
*/
@@ -222,6 +264,10 @@ class ModelSelector {
// 移除打开状态类
this.container.classList.remove('open');
// 移除事件监听器
window.removeEventListener('resize', this.adjustDropdownPosition.bind(this));
window.removeEventListener('scroll', this.adjustDropdownPosition.bind(this));
// 延迟隐藏元素,以便完成过渡动画
setTimeout(() => {
this.overlay.style.display = 'none';
@@ -338,12 +384,12 @@ class SettingsManager {
// 加载模型配置
await this.loadModelConfig();
// 成功加载配置后,执行后续初始化
this.updateModelOptions();
// 成功加载配置后,执行后续初始化
this.updateModelOptions();
await this.loadSettings();
await this.loadPrompts(); // 加载提示词配置
this.setupEventListeners();
this.updateUIBasedOnModelType();
this.setupEventListeners();
this.updateUIBasedOnModelType();
// 初始化可折叠内容逻辑
this.initCollapsibleContent();
@@ -372,18 +418,18 @@ class SettingsManager {
console.log('设置管理器初始化完成');
} catch (error) {
console.error('初始化设置管理器失败:', error);
window.uiManager?.showToast('加载模型配置失败,使用默认配置', 'error');
// 使用默认配置作为备份
this.setupDefaultModels();
this.updateModelOptions();
window.uiManager?.showToast('加载模型配置失败,使用默认配置', 'error');
// 使用默认配置作为备份
this.setupDefaultModels();
this.updateModelOptions();
await this.loadSettings();
await this.loadPrompts(); // 加载提示词配置
this.setupEventListeners();
this.updateUIBasedOnModelType();
// 初始化可折叠内容逻辑
this.initCollapsibleContent();
this.setupEventListeners();
this.updateUIBasedOnModelType();
// 初始化可折叠内容逻辑
this.initCollapsibleContent();
// 初始化模型选择器
this.initModelSelector();
@@ -391,7 +437,7 @@ class SettingsManager {
this.isInitialized = true;
}
}
// 初始化新的模型选择器
initModelSelector() {
if (this.modelSelector) {
@@ -418,7 +464,7 @@ class SettingsManager {
this.modelSelector.selectModel(this.modelSelect.value, false);
}
}
// 更新模型选择下拉框
updateModelOptions() {
// 清空现有选项
@@ -457,56 +503,56 @@ class SettingsManager {
}
}
}
async loadSettings() {
try {
// 先从localStorage加载大部分设置
const settings = JSON.parse(localStorage.getItem('aiSettings') || '{}');
const settings = JSON.parse(localStorage.getItem('aiSettings') || '{}');
// 刷新API密钥状态自动从服务器获取最新状态
await this.refreshApiKeyStatus();
console.log('已自动刷新API密钥状态');
// 加载其他设置
// Load model selection
if (settings.model && this.modelExists(settings.model)) {
this.modelSelect.value = settings.model;
this.updateVisibleApiKey(settings.model);
// Load model selection
if (settings.model && this.modelExists(settings.model)) {
this.modelSelect.value = settings.model;
this.updateVisibleApiKey(settings.model);
// 使用新的模型选择器更新UI
if (this.modelSelector) {
this.modelSelector.selectModel(settings.model, false);
}
}
// Load max tokens setting - 现在直接设置输入框值
}
// Load max tokens setting - 现在直接设置输入框值
if (settings.maxTokens) {
this.maxTokens.value = settings.maxTokens;
this.updateTokenValueDisplay();
this.highlightActivePreset();
}
// Load reasoning depth & think budget settings
if (settings.reasoningDepth) {
this.reasoningDepthSelect.value = settings.reasoningDepth;
// Load reasoning depth & think budget settings
if (settings.reasoningDepth) {
this.reasoningDepthSelect.value = settings.reasoningDepth;
// 更新推理深度选项UI
this.updateReasoningOptionUI(settings.reasoningDepth);
}
// 加载思考预算百分比
const thinkBudgetPercent = parseInt(settings.thinkBudgetPercent || '50');
if (this.thinkBudgetPercentInput) {
this.thinkBudgetPercentInput.value = thinkBudgetPercent;
}
}
// 加载思考预算百分比
const thinkBudgetPercent = parseInt(settings.thinkBudgetPercent || '50');
if (this.thinkBudgetPercentInput) {
this.thinkBudgetPercentInput.value = thinkBudgetPercent;
}
// 更新思考预算显示和滑块背景
this.updateThinkBudgetDisplay();
this.updateThinkBudgetDisplay();
this.updateThinkBudgetSliderBackground();
this.highlightActiveThinkPreset();
// Load temperature setting
if (settings.temperature) {
this.temperatureInput.value = settings.temperature;
if (settings.temperature) {
this.temperatureInput.value = settings.temperature;
}
// 先记录用户设置的提示词ID如果有
@@ -515,30 +561,30 @@ class SettingsManager {
}
// 如果系统提示词内容已保存在设置中,先恢复它
if (settings.systemPrompt) {
this.systemPromptInput.value = settings.systemPrompt;
}
if (settings.language) {
this.languageInput.value = settings.language;
}
// Load proxy settings
if (settings.proxyEnabled !== undefined) {
this.proxyEnabledInput.checked = settings.proxyEnabled;
this.proxySettings.style.display = settings.proxyEnabled ? 'block' : 'none';
}
if (settings.proxyHost) {
this.proxyHostInput.value = settings.proxyHost;
}
if (settings.proxyPort) {
this.proxyPortInput.value = settings.proxyPort;
}
// Update UI based on model type
this.updateUIBasedOnModelType();
if (settings.systemPrompt) {
this.systemPromptInput.value = settings.systemPrompt;
}
if (settings.language) {
this.languageInput.value = settings.language;
}
// Load proxy settings
if (settings.proxyEnabled !== undefined) {
this.proxyEnabledInput.checked = settings.proxyEnabled;
this.proxySettings.style.display = settings.proxyEnabled ? 'block' : 'none';
}
if (settings.proxyHost) {
this.proxyHostInput.value = settings.proxyHost;
}
if (settings.proxyPort) {
this.proxyPortInput.value = settings.proxyPort;
}
// Update UI based on model type
this.updateUIBasedOnModelType();
} catch (error) {
console.error('加载设置出错:', error);
@@ -727,10 +773,11 @@ class SettingsManager {
const language = this.languageInput.value || '中文';
const basePrompt = this.systemPromptInput.value || '';
let systemPrompt = basePrompt;
if (!basePrompt.includes('Please respond in') && !basePrompt.includes('请用') && !basePrompt.includes('使用')) {
systemPrompt = `${basePrompt}\n\n请务必使用${language}回答。`;
}
// 直接使用带语言提示的系统提示词
// 注意systemPromptInput.value 可能已经在 loadPrompt 中设置了语言提示
// 为避免重复添加,我们先提取提示词的主体部分(不含语言提示)
const promptMainPart = basePrompt.split("\n\n请务必使用")[0];
const systemPrompt = `${promptMainPart}\n\n请务必使用${language}回答。`;
const selectedModel = this.modelSelect.value;
const modelInfo = this.modelDefinitions[selectedModel] || {};
@@ -979,7 +1026,14 @@ class SettingsManager {
this.languageInput.addEventListener('change', (e) => {
// 阻止事件冒泡
e.stopPropagation();
// 如果当前有加载提示词,重新加载它以更新语言
if (this.currentPromptId && this.prompts[this.currentPromptId]) {
this.loadPrompt(this.currentPromptId);
} else {
// 没有当前提示词,只保存设置
this.saveSettings();
}
});
this.proxyEnabledInput.addEventListener('change', (e) => {
@@ -1522,7 +1576,7 @@ class SettingsManager {
if (promptIdToLoad) {
this.loadPrompt(promptIdToLoad);
console.log('加载提示词:', promptIdToLoad);
} else {
} else {
// 如果没有提示词,显示默认描述
if (this.promptDescriptionElement) {
this.promptDescriptionElement.innerHTML = '<p>暂无提示词,请点击"+"创建新提示词</p>';
@@ -1592,12 +1646,24 @@ class SettingsManager {
// 更新当前提示词ID
this.currentPromptId = promptId;
// 更新提示词输入框 (隐藏,但仍需保存正确的内容)
this.systemPromptInput.value = this.prompts[promptId].content;
// 获取当前选择的语言
const language = this.languageInput.value || '中文';
// 更新提示词描述显示
// 获取原始提示词内容
const basePrompt = this.prompts[promptId].content;
// 添加语言指令(如果原始提示词中不包含语言指令)
let systemPrompt = basePrompt;
if (!basePrompt.includes('Please respond in') && !basePrompt.includes('请用') && !basePrompt.includes('使用')) {
systemPrompt = `${basePrompt}\n\n请务必使用${language}回答。`;
}
// 更新提示词输入框 (隐藏,但仍需保存正确的内容)
this.systemPromptInput.value = systemPrompt;
// 更新提示词描述显示 - 使用完整的系统提示词,包括语言指令
if (this.promptDescriptionElement) {
const description = this.prompts[promptId].description || this.prompts[promptId].content;
const description = this.prompts[promptId].description || systemPrompt;
this.promptDescriptionElement.innerHTML = `<p>${description}</p>`;
}

View File

@@ -5006,7 +5006,7 @@ textarea,
}
.model-dropdown-panel {
position: absolute;
position: fixed;
max-height: 300px;
overflow-y: auto;
background-color: var(--surface);
@@ -5266,816 +5266,21 @@ textarea,
/* 下拉面板 */
.model-dropdown-panel {
position: absolute;
max-height: 280px;
position: fixed;
max-height: 300px;
overflow-y: auto;
background-color: var(--surface);
border: 1px solid var(--border-color);
border-radius: 8px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
z-index: 10000;
padding: 6px;
padding: 8px;
display: none;
opacity: 0;
transform: translateY(-10px);
transition: opacity 0.2s, transform 0.2s;
scrollbar-width: thin;
}
.model-dropdown-panel::-webkit-scrollbar {
width: 6px;
}
.model-dropdown-panel::-webkit-scrollbar-thumb {
background-color: rgba(var(--primary-rgb), 0.2);
border-radius: 3px;
}
.model-dropdown-panel::-webkit-scrollbar-thumb:hover {
background-color: rgba(var(--primary-rgb), 0.3);
}
.model-dropdown-panel.visible {
display: block;
opacity: 1;
transform: translateY(0);
}
/* 模型分组 */
.model-group {
margin-bottom: 8px;
}
.model-group:last-child {
margin-bottom: 0;
}
.model-group-title {
padding: 4px 6px;
font-size: 0.7rem;
font-weight: 600;
color: var(--text-tertiary);
text-transform: uppercase;
letter-spacing: 0.03em;
border-bottom: 1px solid var(--border-color);
margin-bottom: 4px;
}
/* 模型选项 */
.model-option {
display: flex;
align-items: center;
padding: 6px 8px;
border-radius: 6px;
cursor: pointer;
transition: all 0.15s ease;
gap: 8px;
}
.model-option:hover {
background-color: rgba(var(--primary-rgb), 0.08);
transform: translateX(2px);
}
.model-option.selected {
background-color: rgba(var(--primary-rgb), 0.12);
}
.model-option-name {
flex: 1;
font-size: 0.85rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.model-option-badges {
display: flex;
gap: 3px;
}
.model-option-badge {
width: 16px;
height: 16px;
border-radius: 50%;
background-color: rgba(var(--primary-rgb), 0.08);
display: flex;
align-items: center;
justify-content: center;
font-size: 0.6rem;
}
/* 多模态能力特殊样式 */
.model-option-badge i.fa-image {
color: #4CAF50; /* 绿色 */
}
/* 推理能力特殊样式 */
.model-option-badge i.fa-brain {
color: #9C27B0; /* 紫色 */
}
/* 暗色模式适配 */
[data-theme="dark"] .model-display {
background-color: var(--surface-alt);
border-color: var(--border-color-dark);
}
[data-theme="dark"] .model-display:hover {
border-color: var(--primary-color);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .model-display-icon {
background-color: rgba(var(--primary-rgb), 0.15);
}
[data-theme="dark"] .model-badge {
background-color: rgba(var(--primary-rgb), 0.15);
}
[data-theme="dark"] .model-dropdown-panel {
background-color: var(--surface-alt);
border-color: var(--border-color-dark);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .model-option:hover {
background-color: rgba(var(--primary-rgb), 0.15);
}
[data-theme="dark"] .model-option.selected {
background-color: rgba(var(--primary-rgb), 0.2);
}
[data-theme="dark"] .model-option-badge {
background-color: rgba(var(--primary-rgb), 0.15);
}
/* 移动端适配 */
@media (max-width: 480px) {
.model-display {
padding: 6px 8px;
}
.model-display-icon {
width: 28px;
height: 28px;
font-size: 0.8rem;
}
.model-display-name {
font-size: 0.85rem;
}
.model-display-provider {
font-size: 0.7rem;
}
.model-badge {
width: 16px;
height: 16px;
font-size: 0.6rem;
}
.model-dropdown-panel {
max-height: 240px;
padding: 5px;
}
.model-option {
padding: 5px 7px;
}
.model-group-title {
font-size: 0.65rem;
padding: 3px 5px;
}
}
/* 系统提示词section样式 */
.prompt-settings {
opacity: 0;
transform: translateY(10px);
animation: fadeInUp 0.4s forwards;
animation-delay: calc(var(--anim-order, 1.5) * 0.1s);
margin-bottom: 2rem;
background-color: var(--card-background, #f8f9fa);
border-radius: 0.75rem;
padding: 1.25rem;
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
border: 1px solid var(--border-color);
transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.prompt-settings:hover {
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
transform: translateY(-3px) scale(1.01);
}
[data-theme="dark"] .prompt-settings {
background-color: var(--card-background);
border: 1px solid var(--border-color);
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .prompt-settings:hover {
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}
.prompt-settings h3 {
font-size: 1.125rem;
margin-top: 0;
margin-bottom: 1.25rem;
color: var(--text-primary);
font-weight: 600;
position: relative;
padding-bottom: 0.75rem;
border-bottom: 1px solid var(--border-color);
}
.prompt-setting-group {
margin-bottom: 1.25rem;
padding: 0.5rem 0;
border-radius: 8px;
transition: all 0.2s ease;
}
.prompt-setting-group:hover {
transform: translateX(3px);
}
/* 添加和优化提示词相关样式 */
.prompt-setting-group label {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.5rem;
color: var(--text-secondary);
font-size: 0.9375rem;
font-weight: 500;
transition: color 0.2s ease;
}
.prompt-setting-group:hover label {
color: var(--text-primary);
}
.prompt-setting-group label i {
color: var(--text-tertiary);
font-size: 0.9rem;
transition: color 0.2s ease;
}
.prompt-setting-group:hover label i {
color: var(--primary);
}
/* 提示词描述样式增强 */
.prompt-description {
margin-top: 12px;
padding: 15px;
border-radius: 8px;
background-color: rgba(var(--primary-rgb), 0.05);
max-height: 150px;
overflow-y: auto;
font-size: 0.9rem;
line-height: 1.5;
border: 1px solid rgba(var(--primary-rgb), 0.1);
transition: all 0.2s ease;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}
.prompt-description:hover {
background-color: rgba(var(--primary-rgb), 0.08);
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
transform: translateY(-2px);
}
.prompt-description p {
margin: 0;
color: var(--text);
}
[data-theme="dark"] .prompt-description {
background-color: rgba(var(--primary-rgb), 0.08);
border-color: rgba(var(--primary-rgb), 0.15);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
[data-theme="dark"] .prompt-description:hover {
background-color: rgba(var(--primary-rgb), 0.12);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
/* 提示词操作按钮样式优化 */
.prompt-actions {
display: flex;
gap: 8px;
align-items: center;
}
.prompt-actions select {
min-width: 180px;
padding: 6px 10px;
border-radius: 6px;
border: 1px solid var(--border-color);
background-color: var(--surface-alt);
color: var(--text-primary);
font-size: 0.9em;
transition: all 0.2s ease;
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 0.75rem center;
background-size: 16px;
padding-right: 2.5rem;
}
.prompt-actions select:hover {
border-color: var(--primary);
}
.icon-btn {
background: transparent;
border: none;
color: var(--text-secondary);
cursor: pointer;
padding: 5px;
border-radius: 6px;
transition: all 0.2s ease;
font-size: 0.9rem;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
}
.icon-btn:hover {
color: var(--primary);
background-color: rgba(var(--primary-rgb), 0.08);
}
.icon-btn:active {
transform: scale(0.92);
}
/* 移动端优化 */
@media (max-width: 768px) {
.prompt-settings h3 {
font-size: 1rem;
padding: 0.75rem 0 0.5rem;
margin-bottom: 1rem;
}
.prompt-header {
flex-direction: column;
align-items: flex-start;
gap: 6px;
}
.prompt-actions {
margin-top: 4px;
width: 100%;
justify-content: space-between;
}
.prompt-actions select {
min-width: 0;
width: calc(100% - 110px);
font-size: 0.85em;
padding: 5px 8px;
padding-right: 2rem;
background-position: right 0.5rem center;
}
.icon-btn {
width: 28px;
height: 28px;
padding: 4px;
}
.prompt-description {
padding: 10px 12px;
font-size: 0.85rem;
max-height: 130px;
}
}
@media (max-width: 480px) {
.prompt-settings {
padding: 1rem;
}
.prompt-settings h3 {
font-size: 0.95rem;
padding: 0.5rem 0 0.5rem;
margin-bottom: 0.75rem;
}
.prompt-actions {
gap: 4px;
}
.prompt-actions select {
width: calc(100% - 90px);
padding: 4px 8px;
font-size: 0.8em;
padding-right: 1.75rem;
background-position: right 0.4rem center;
background-size: 14px;
}
.icon-btn {
width: 26px;
height: 26px;
font-size: 0.8em;
padding: 3px;
}
.prompt-description {
padding: 8px 10px;
font-size: 0.8rem;
max-height: 120px;
margin-top: 8px;
}
}
/* 提示信息样式 */
.prompt-info {
margin: 8px 0;
}
.prompt-badge {
display: inline-flex;
align-items: center;
background-color: rgba(var(--primary-rgb), 0.08);
border-radius: 20px;
padding: 4px 12px 4px 8px;
font-size: 0.8rem;
color: var(--text-secondary);
border: 1px solid rgba(var(--primary-rgb), 0.12);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
max-width: 100%;
overflow: hidden;
transition: all 0.2s ease;
}
.prompt-badge i {
color: var(--primary);
margin-right: 6px;
font-size: 0.9rem;
}
.prompt-badge:hover {
background-color: rgba(var(--primary-rgb), 0.12);
transform: translateY(-1px);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07);
}
[data-theme="dark"] .prompt-badge {
background-color: rgba(var(--primary-rgb), 0.15);
border-color: rgba(var(--primary-rgb), 0.2);
color: var(--text-tertiary);
}
[data-theme="dark"] .prompt-badge:hover {
background-color: rgba(var(--primary-rgb), 0.2);
}
@media (max-width: 768px) {
.prompt-badge {
padding: 3px 10px 3px 7px;
font-size: 0.75rem;
}
.prompt-badge i {
font-size: 0.85rem;
margin-right: 5px;
}
}
@media (max-width: 480px) {
.prompt-info {
margin: 6px 0;
}
.prompt-badge {
padding: 2px 8px 2px 6px;
font-size: 0.7rem;
}
.prompt-badge i {
font-size: 0.8rem;
margin-right: 4px;
}
}
/* 提示词设置区域样式优化 - 精致版 */
.prompt-settings {
background-color: var(--bg-panel);
border-radius: 12px;
padding: 16px;
margin-bottom: 15px;
transition: all 0.25s ease;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
border: 1px solid var(--border-color);
position: relative;
overflow: hidden;
}
.prompt-settings:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
border-color: var(--primary-color);
}
.prompt-settings::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 4px;
height: 100%;
background: linear-gradient(to bottom, var(--primary-color), rgba(var(--primary-color-rgb), 0.4));
opacity: 0;
transition: opacity 0.3s ease;
}
.prompt-settings:hover::before {
opacity: 1;
}
.prompt-setting-group {
display: flex;
flex-direction: column;
gap: 12px;
margin-bottom: 0;
}
.prompt-container {
display: flex;
flex-direction: column;
gap: 12px;
}
.prompt-actions {
display: flex;
align-items: center;
gap: 10px;
}
.prompt-buttons {
display: flex;
align-items: center;
gap: 6px;
}
.prompt-actions select {
flex: 1;
padding: 8px 12px;
border-radius: 8px;
background-color: var(--bg-input);
border: 1px solid var(--border-color);
color: var(--text-color);
font-size: 14px;
font-weight: 500;
transition: all 0.2s ease;
-webkit-appearance: none;
appearance: none;
background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 10px center;
background-size: 16px;
padding-right: 35px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.prompt-actions select:hover {
border-color: var(--primary-color);
background-color: var(--bg-hover);
}
.prompt-actions select:focus {
outline: none;
border-color: var(--primary-color);
box-shadow: 0 0 0 2px rgba(var(--primary-color-rgb), 0.2);
}
.prompt-preview {
position: relative;
border-radius: 10px;
overflow: hidden;
transition: all 0.2s ease;
}
.prompt-description {
position: relative;
padding: 15px;
background-color: var(--bg-input);
border-radius: 10px;
border: 1px solid var(--border-color);
transition: all 0.2s ease;
line-height: 1.6;
max-height: 150px;
overflow-y: auto;
font-size: 14px;
color: var(--text-color);
}
.prompt-description::-webkit-scrollbar {
width: 6px;
}
.prompt-description::-webkit-scrollbar-track {
background: transparent;
}
.prompt-description::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, 0.1);
border-radius: 10px;
}
.prompt-description::-webkit-scrollbar-thumb:hover {
background-color: rgba(0, 0, 0, 0.2);
}
.prompt-description p {
margin: 0;
color: var(--text-color);
font-size: 14px;
line-height: 1.6;
}
.prompt-preview-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(var(--primary-color-rgb), 0.05);
opacity: 0;
transition: opacity 0.2s ease;
display: flex;
justify-content: center;
align-items: center;
pointer-events: none;
}
.prompt-preview:hover .prompt-preview-overlay {
opacity: 1;
}
.prompt-edit-hint {
width: 36px;
height: 36px;
border-radius: 50%;
background-color: var(--primary-color);
color: white;
display: flex;
justify-content: center;
align-items: center;
transform: scale(0.8);
opacity: 0;
transition: all 0.2s ease;
}
.prompt-preview:hover .prompt-edit-hint {
transform: scale(1);
opacity: 0.9;
}
.icon-btn {
width: 32px;
height: 32px;
border-radius: 8px;
background-color: transparent;
color: var(--text-color);
border: 1px solid var(--border-color);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
font-size: 14px;
}
.icon-btn:hover {
background-color: var(--bg-hover);
color: var(--primary-color);
border-color: var(--primary-color);
transform: translateY(-1px);
}
.icon-btn:active {
transform: translateY(0);
}
/* 深色模式适配 */
[data-theme="dark"] .prompt-description {
background-color: var(--bg-input-dark);
border-color: var(--border-color-dark);
}
[data-theme="dark"] .prompt-description:hover {
border-color: var(--primary-color);
}
[data-theme="dark"] .prompt-preview-overlay {
background-color: rgba(0, 0, 0, 0.2);
}
[data-theme="dark"] .prompt-description::-webkit-scrollbar-thumb {
background-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .prompt-description::-webkit-scrollbar-thumb:hover {
background-color: rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] .icon-btn {
background-color: rgba(255, 255, 255, 0.05);
border-color: var(--border-color-dark);
}
[data-theme="dark"] .icon-btn:hover {
background-color: rgba(255, 255, 255, 0.1);
border-color: var(--primary-color);
}
/* 移动端适配 */
@media (max-width: 768px) {
.prompt-settings {
padding: 14px;
}
.prompt-actions {
flex-wrap: wrap;
}
.prompt-actions select {
flex: 1 0 calc(100% - 120px);
}
.icon-btn {
width: 30px;
height: 30px;
}
.prompt-description {
padding: 12px;
max-height: 120px;
}
.prompt-edit-hint {
width: 32px;
height: 32px;
}
}
@media (max-width: 480px) {
.prompt-settings {
padding: 12px;
border-radius: 10px;
}
.prompt-actions {
gap: 6px;
}
.prompt-buttons {
gap: 4px;
}
.prompt-actions select {
flex: 1 0 calc(100% - 110px);
font-size: 13px;
padding: 7px 8px;
padding-right: 28px;
background-position: right 8px center;
background-size: 14px;
}
.icon-btn {
width: 28px;
height: 28px;
font-size: 12px;
border-radius: 6px;
}
.prompt-description {
padding: 10px;
font-size: 13px;
line-height: 1.5;
max-height: 100px;
}
.prompt-edit-hint {
width: 28px;
height: 28px;
font-size: 12px;
}
}