feat: 重构提示词选择区布局,快捷按钮与下拉框同排,显示提示词名称和内容,结果区改为'大模型返回结果'
This commit is contained in:
@@ -190,36 +190,57 @@ impl FlomoAiApp {
|
||||
|
||||
ui.separator();
|
||||
|
||||
ui.label(egui::RichText::new("快速操作").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(6.0);
|
||||
|
||||
// 提示词选择区:左侧标签+下拉框,右侧快捷按钮
|
||||
ui.horizontal(|ui| {
|
||||
let buttons = vec![
|
||||
("🔍", "检查错别字"),
|
||||
("📋", "总结"),
|
||||
("🌐", "翻译"),
|
||||
("✨", "润色"),
|
||||
];
|
||||
ui.vertical(|ui| {
|
||||
ui.label(egui::RichText::new("提示词").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(4.0);
|
||||
|
||||
for (emoji, name) in buttons {
|
||||
let btn = egui::Button::new(egui::RichText::new(emoji).size(16.0))
|
||||
.fill(ui.style().visuals.widgets.inactive.bg_fill)
|
||||
.stroke(egui::Stroke::new(1.0, egui::Color32::from_rgb(210, 210, 220)))
|
||||
.rounding(6.0)
|
||||
.min_size(egui::vec2(36.0, 36.0));
|
||||
let selected_text = if self.selected_prompt_index == 0 {
|
||||
"无系统提示词".to_string()
|
||||
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
||||
self.settings.prompt_configs[self.selected_prompt_index - 1].title.clone()
|
||||
} else {
|
||||
"无系统提示词".to_string()
|
||||
};
|
||||
|
||||
if ui.add(btn).on_hover_text(name).clicked() {
|
||||
self.select_prompt_by_name(name, ctx);
|
||||
egui::ComboBox::from_id_salt("prompt_selector")
|
||||
.selected_text(&selected_text)
|
||||
.width(180.0)
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut self.selected_prompt_index, 0, "无系统提示词");
|
||||
for (i, prompt) in self.settings.prompt_configs.iter().enumerate() {
|
||||
ui.selectable_value(&mut self.selected_prompt_index, i + 1, &prompt.title);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let buttons = vec![
|
||||
("🔍", "检查错别字"),
|
||||
("📋", "总结"),
|
||||
("🌐", "翻译"),
|
||||
("✨", "润色"),
|
||||
];
|
||||
|
||||
for (emoji, name) in buttons {
|
||||
let btn = egui::Button::new(egui::RichText::new(emoji).size(16.0))
|
||||
.fill(ui.style().visuals.widgets.inactive.bg_fill)
|
||||
.stroke(egui::Stroke::new(1.0, egui::Color32::from_rgb(210, 210, 220)))
|
||||
.rounding(6.0)
|
||||
.min_size(egui::vec2(36.0, 36.0));
|
||||
|
||||
if ui.add(btn).on_hover_text(name).clicked() {
|
||||
self.select_prompt_by_name(name, ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ui.add_space(14.0);
|
||||
|
||||
ui.label(egui::RichText::new("提示词").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(6.0);
|
||||
|
||||
let selected_text = if self.selected_prompt_index == 0 {
|
||||
// 提示词详情:显示名称和内容
|
||||
let prompt_name = if self.selected_prompt_index == 0 {
|
||||
"无系统提示词".to_string()
|
||||
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
||||
self.settings.prompt_configs[self.selected_prompt_index - 1].title.clone()
|
||||
@@ -227,17 +248,6 @@ impl FlomoAiApp {
|
||||
"无系统提示词".to_string()
|
||||
};
|
||||
|
||||
egui::ComboBox::from_id_salt("prompt_selector")
|
||||
.selected_text(&selected_text)
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut self.selected_prompt_index, 0, "无系统提示词");
|
||||
for (i, prompt) in self.settings.prompt_configs.iter().enumerate() {
|
||||
ui.selectable_value(&mut self.selected_prompt_index, i + 1, &prompt.title);
|
||||
}
|
||||
});
|
||||
|
||||
ui.separator();
|
||||
|
||||
let prompt_content = if self.selected_prompt_index == 0 {
|
||||
"无特殊指令".to_string()
|
||||
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
||||
@@ -246,10 +256,23 @@ impl FlomoAiApp {
|
||||
"无特殊指令".to_string()
|
||||
};
|
||||
|
||||
ui.label(egui::RichText::new(&prompt_content).size(11.0).color(egui::Color32::GRAY));
|
||||
egui::Frame::none()
|
||||
.fill(ui.style().visuals.widgets.inactive.bg_fill)
|
||||
.stroke(egui::Stroke::new(1.0, egui::Color32::from_rgb(210, 210, 220)))
|
||||
.rounding(6.0)
|
||||
.inner_margin(egui::Margin::same(12.0))
|
||||
.show(ui, |ui: &mut egui::Ui| {
|
||||
ui.label(egui::RichText::new(&prompt_name).size(13.0).strong());
|
||||
ui.add_space(6.0);
|
||||
ui.add_sized([ui.available_width(), 1.0], egui::Separator::default());
|
||||
ui.add_space(6.0);
|
||||
ui.label(egui::RichText::new(&prompt_content).size(11.0).color(egui::Color32::GRAY));
|
||||
});
|
||||
|
||||
ui.add_space(14.0);
|
||||
|
||||
ui.label(egui::RichText::new("输入").size(11.0).color(egui::Color32::GRAY));
|
||||
// 大模型返回结果
|
||||
ui.label(egui::RichText::new("大模型返回结果").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(4.0);
|
||||
|
||||
egui::Frame::none()
|
||||
@@ -293,7 +316,7 @@ impl FlomoAiApp {
|
||||
|
||||
ui.add_space(14.0);
|
||||
|
||||
ui.label(egui::RichText::new("优化结果").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.label(egui::RichText::new("大模型返回结果").size(11.0).color(egui::Color32::GRAY));
|
||||
ui.add_space(6.0);
|
||||
|
||||
let status_text = match &self.status {
|
||||
|
||||
Reference in New Issue
Block a user