Remove code to sql

This commit is contained in:
Spxg
2025-05-17 22:45:01 +08:00
parent 4848e73723
commit 3498171c0e
5 changed files with 14 additions and 14 deletions

View File

@@ -9,18 +9,18 @@ use crate::app::{
pub fn AdvancedOptionsMenu() -> impl IntoView { pub fn AdvancedOptionsMenu() -> impl IntoView {
let state = expect_context::<Store<GlobalState>>(); let state = expect_context::<Store<GlobalState>>();
let value = move || *state.run_selected_code().read(); let value = move || *state.run_selected_sql().read();
let is_default = move || !*state.run_selected_code().read(); let is_default = move || !*state.run_selected_sql().read();
let on_change = move |value: &bool| { let on_change = move |value: &bool| {
state.run_selected_code().set(*value); state.run_selected_sql().set(*value);
}; };
view! { view! {
<> <>
<MenuGroup title="Advanced options".into()> <MenuGroup title="Advanced options".into()>
<Either <Either
id="run_selected_code".into() id="run_selected_sql".into()
name="Run Selected Code".into() name="Run Selected SQL".into()
a=true a=true
b=false b=false
a_label=Some("On".to_string()) a_label=Some("On".to_string())

View File

@@ -34,7 +34,7 @@ pub fn Editor() -> impl IntoView {
"ace/keyboard/{}", "ace/keyboard/{}",
state.editor_config().read_untracked().keyboard state.editor_config().read_untracked().keyboard
)) ))
.value(&shared_code().unwrap_or_else(|| state.code().get_untracked())) .value(&shared_code().unwrap_or_else(|| state.sql().get_untracked()))
.build(); .build();
match aceditor::Editor::open("ace_editor", Some(&opt)) { match aceditor::Editor::open("ace_editor", Some(&opt)) {

View File

@@ -65,9 +65,9 @@ pub fn execute(state: Store<GlobalState>) -> Box<dyn Fn() + Send + 'static> {
return; return;
}; };
let run_selected_code = state.run_selected_code().get(); let run_selected_code = state.run_selected_sql().get();
state.code().set(code.clone()); state.sql().set(code.clone());
change_focus(state, Some(Focus::Execute)); change_focus(state, Some(Focus::Execute));
std::mem::take(&mut *state.output().write()); std::mem::take(&mut *state.output().write());

View File

@@ -57,8 +57,8 @@ fn hanlde_save_state(state: Store<GlobalState>) {
state.orientation().track(); state.orientation().track();
state.theme().track(); state.theme().track();
state.keep_ctx().track(); state.keep_ctx().track();
state.code().track(); state.sql().track();
state.run_selected_code().track(); state.run_selected_sql().track();
state.read_untracked().save(); state.read_untracked().save();
}); });

View File

@@ -17,8 +17,8 @@ pub struct GlobalState {
orientation: Orientation, orientation: Orientation,
theme: Theme, theme: Theme,
keep_ctx: bool, keep_ctx: bool,
code: String, sql: String,
run_selected_code: bool, run_selected_sql: bool,
// runtime state below // runtime state below
#[serde(skip)] #[serde(skip)]
worker: Option<WorkerHandle>, worker: Option<WorkerHandle>,
@@ -44,7 +44,7 @@ impl Default for GlobalState {
fn default() -> Self { fn default() -> Self {
Self { Self {
editor_config: EditorConfig::default(), editor_config: EditorConfig::default(),
code: DEFAULT_CODE.into(), sql: DEFAULT_CODE.into(),
focus: None, focus: None,
show_something: false, show_something: false,
orientation: Orientation::Automatic, orientation: Orientation::Automatic,
@@ -58,7 +58,7 @@ impl Default for GlobalState {
worker: None, worker: None,
editor: None, editor: None,
last_error: None, last_error: None,
run_selected_code: false, run_selected_sql: false,
} }
} }
} }