feat: 重构提示词选择区布局,快捷按钮与下拉框同排,显示提示词名称和内容,结果区改为'大模型返回结果'
This commit is contained in:
@@ -190,10 +190,32 @@ impl FlomoAiApp {
|
|||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
||||||
ui.label(egui::RichText::new("快速操作").size(11.0).color(egui::Color32::GRAY));
|
// 提示词选择区:左侧标签+下拉框,右侧快捷按钮
|
||||||
ui.add_space(6.0);
|
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
|
ui.vertical(|ui| {
|
||||||
|
ui.label(egui::RichText::new("提示词").size(11.0).color(egui::Color32::GRAY));
|
||||||
|
ui.add_space(4.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()
|
||||||
|
};
|
||||||
|
|
||||||
|
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![
|
let buttons = vec![
|
||||||
("🔍", "检查错别字"),
|
("🔍", "检查错别字"),
|
||||||
("📋", "总结"),
|
("📋", "总结"),
|
||||||
@@ -213,13 +235,12 @@ impl FlomoAiApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
ui.add_space(14.0);
|
ui.add_space(14.0);
|
||||||
|
|
||||||
ui.label(egui::RichText::new("提示词").size(11.0).color(egui::Color32::GRAY));
|
// 提示词详情:显示名称和内容
|
||||||
ui.add_space(6.0);
|
let prompt_name = if self.selected_prompt_index == 0 {
|
||||||
|
|
||||||
let selected_text = if self.selected_prompt_index == 0 {
|
|
||||||
"无系统提示词".to_string()
|
"无系统提示词".to_string()
|
||||||
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
||||||
self.settings.prompt_configs[self.selected_prompt_index - 1].title.clone()
|
self.settings.prompt_configs[self.selected_prompt_index - 1].title.clone()
|
||||||
@@ -227,17 +248,6 @@ impl FlomoAiApp {
|
|||||||
"无系统提示词".to_string()
|
"无系统提示词".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 {
|
let prompt_content = if self.selected_prompt_index == 0 {
|
||||||
"无特殊指令".to_string()
|
"无特殊指令".to_string()
|
||||||
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
} else if self.selected_prompt_index <= self.settings.prompt_configs.len() {
|
||||||
@@ -246,10 +256,23 @@ impl FlomoAiApp {
|
|||||||
"无特殊指令".to_string()
|
"无特殊指令".to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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.label(egui::RichText::new(&prompt_content).size(11.0).color(egui::Color32::GRAY));
|
||||||
|
});
|
||||||
|
|
||||||
ui.add_space(14.0);
|
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);
|
ui.add_space(4.0);
|
||||||
|
|
||||||
egui::Frame::none()
|
egui::Frame::none()
|
||||||
@@ -293,7 +316,7 @@ impl FlomoAiApp {
|
|||||||
|
|
||||||
ui.add_space(14.0);
|
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);
|
ui.add_space(6.0);
|
||||||
|
|
||||||
let status_text = match &self.status {
|
let status_text = match &self.status {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
private lateinit var outputStatusLabel: TextView
|
private lateinit var outputStatusLabel: TextView
|
||||||
private lateinit var outputTextView: TextView
|
private lateinit var outputTextView: TextView
|
||||||
private lateinit var promptSelector: Spinner
|
private lateinit var promptSelector: Spinner
|
||||||
|
private lateinit var promptNameText: TextView
|
||||||
private lateinit var promptContentText: TextView
|
private lateinit var promptContentText: TextView
|
||||||
|
|
||||||
// Data classes matching SecondActivity
|
// Data classes matching SecondActivity
|
||||||
@@ -61,6 +62,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Log.d("MainActivity", "onCreate: Layout set")
|
Log.d("MainActivity", "onCreate: Layout set")
|
||||||
|
|
||||||
promptSelector = findViewById<Spinner>(R.id.promptSelector)
|
promptSelector = findViewById<Spinner>(R.id.promptSelector)
|
||||||
|
promptNameText = findViewById<TextView>(R.id.promptNameText)
|
||||||
promptContentText = findViewById<TextView>(R.id.promptContentText)
|
promptContentText = findViewById<TextView>(R.id.promptContentText)
|
||||||
inputEditText = findViewById<EditText>(R.id.inputEditText)
|
inputEditText = findViewById<EditText>(R.id.inputEditText)
|
||||||
val sendButton = findViewById<Button>(R.id.sendButton)
|
val sendButton = findViewById<Button>(R.id.sendButton)
|
||||||
@@ -90,7 +92,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onItemSelected(parent: android.widget.AdapterView<*>, view: android.view.View?, position: Int, id: Long) {
|
override fun onItemSelected(parent: android.widget.AdapterView<*>, view: android.view.View?, position: Int, id: Long) {
|
||||||
val selectedTitle = promptSelector.getItemAtPosition(position) as String
|
val selectedTitle = promptSelector.getItemAtPosition(position) as String
|
||||||
|
|
||||||
// Get the prompt map from tag
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val promptMap = promptSelector.tag as? MutableMap<String, String>
|
val promptMap = promptSelector.tag as? MutableMap<String, String>
|
||||||
|
|
||||||
@@ -100,11 +101,13 @@ class MainActivity : AppCompatActivity() {
|
|||||||
"无特殊指令"
|
"无特殊指令"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
promptNameText.text = selectedTitle
|
||||||
promptContentText.text = content
|
promptContentText.text = content
|
||||||
Log.d("MainActivity", "Prompt selected: $selectedTitle, content: $content")
|
Log.d("MainActivity", "Prompt selected: $selectedTitle, content: $content")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(parent: android.widget.AdapterView<*>) {
|
override fun onNothingSelected(parent: android.widget.AdapterView<*>) {
|
||||||
|
promptNameText.text = "无系统提示词"
|
||||||
promptContentText.text = "无特殊指令"
|
promptContentText.text = "无特殊指令"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -349,10 +352,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
promptNameText.text = promptName
|
||||||
promptContentText.text = content
|
promptContentText.text = content
|
||||||
Toast.makeText(this, "已选择: $promptName", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "已选择: $promptName", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
// Auto-trigger send if input is not empty
|
|
||||||
if (inputEditText.text.isNotEmpty()) {
|
if (inputEditText.text.isNotEmpty()) {
|
||||||
findViewById<Button>(R.id.sendButton).performClick()
|
findViewById<Button>(R.id.sendButton).performClick()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,22 +84,42 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="20dp">
|
android:padding="20dp">
|
||||||
|
|
||||||
<!-- 快速操作 -->
|
<!-- 提示词选择区:左侧标签+下拉框,右侧快捷按钮 -->
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="快速操作"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:textColor="@color/text_hint"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:letterSpacing="0.15"
|
|
||||||
android:layout_marginBottom="14dp"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginBottom="18dp">
|
android:gravity="center_vertical"
|
||||||
|
android:layout_marginBottom="14dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="提示词"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/text_hint"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:letterSpacing="0.15"/>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/promptSelector"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:spinnerMode="dropdown"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/btnCheckTypos"
|
android:id="@+id/btnCheckTypos"
|
||||||
@@ -108,7 +128,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:background="@drawable/button_quick_bg"
|
android:background="@drawable/button_quick_bg"
|
||||||
android:layout_marginEnd="10dp">
|
android:layout_marginEnd="6dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="20dp"
|
android:layout_width="20dp"
|
||||||
@@ -125,7 +145,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:background="@drawable/button_quick_bg"
|
android:background="@drawable/button_quick_bg"
|
||||||
android:layout_marginEnd="10dp">
|
android:layout_marginEnd="6dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="20dp"
|
android:layout_width="20dp"
|
||||||
@@ -142,7 +162,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:background="@drawable/button_quick_bg"
|
android:background="@drawable/button_quick_bg"
|
||||||
android:layout_marginEnd="10dp">
|
android:layout_marginEnd="6dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="20dp"
|
android:layout_width="20dp"
|
||||||
@@ -168,18 +188,9 @@
|
|||||||
android:gravity="center"/>
|
android:gravity="center"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 提示词 -->
|
<!-- 提示词详情:显示名称和内容 -->
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="提示词"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:textColor="@color/text_hint"
|
|
||||||
android:textAllCaps="true"
|
|
||||||
android:letterSpacing="0.15"
|
|
||||||
android:layout_marginBottom="14dp"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -188,13 +199,14 @@
|
|||||||
android:padding="14dp"
|
android:padding="14dp"
|
||||||
android:layout_marginBottom="18dp">
|
android:layout_marginBottom="18dp">
|
||||||
|
|
||||||
<Spinner
|
<TextView
|
||||||
android:id="@+id/promptSelector"
|
android:id="@+id/promptNameText"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="40dp"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:color/transparent"
|
android:textSize="13sp"
|
||||||
android:spinnerMode="dropdown"
|
android:textColor="@color/text_secondary"
|
||||||
android:padding="4dp"/>
|
android:textStyle="bold"
|
||||||
|
android:text="无系统提示词"/>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -210,14 +222,15 @@
|
|||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:textColor="@color/text_hint"
|
android:textColor="@color/text_hint"
|
||||||
android:minLines="1"
|
android:minLines="1"
|
||||||
android:maxLines="3"/>
|
android:maxLines="3"
|
||||||
|
android:text="无特殊指令"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- 优化结果 -->
|
<!-- 大模型返回结果 -->
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="优化结果"
|
android:text="大模型返回结果"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:textColor="@color/text_hint"
|
android:textColor="@color/text_hint"
|
||||||
android:textAllCaps="true"
|
android:textAllCaps="true"
|
||||||
|
|||||||
Reference in New Issue
Block a user