Use set() instead *write()

This commit is contained in:
Spxg
2025-05-17 09:20:43 +08:00
parent ba9bcd6e4d
commit 333155f7a2
5 changed files with 13 additions and 11 deletions

View File

@@ -65,14 +65,16 @@ pub fn ConfigMenu() -> impl IntoView {
let theme_change = move |event: Event| {
if let Some(target) = event.target() {
let select = HtmlSelectElement::from(JsValue::from(target));
*state.theme().write() = Theme::from_value(&select.value());
state.theme().set(Theme::from_value(&select.value()));
}
};
let orientation_change = move |event: Event| {
if let Some(target) = event.target() {
let select = HtmlSelectElement::from(JsValue::from(target));
*state.orientation().write() = Orientation::from_value(&select.value());
state
.orientation()
.set(Orientation::from_value(&select.value()));
}
};

View File

@@ -16,7 +16,7 @@ pub fn ContextMenu() -> impl IntoView {
current_value=move || { *state.keep_ctx().read() }
this_value=false
change_value=move || {
*state.keep_ctx().write() = false;
state.keep_ctx().set(false);
}
>
"Each execution is in a new DB."
@@ -26,7 +26,7 @@ pub fn ContextMenu() -> impl IntoView {
current_value=move || { *state.keep_ctx().read() }
this_value=true
change_value=move || {
*state.keep_ctx().write() = true;
state.keep_ctx().set(true);
}
>
"Keep the results of each execution."

View File

@@ -178,7 +178,7 @@ fn ShareButton() -> impl IntoView {
url.set_search(&params.to_string().as_string().unwrap());
Ok(url.href())
}) {
*state.share_href().write() = Some(href);
state.share_href().set(Some(href));
change_focus(state, Some(Focus::Share));
}
};

View File

@@ -95,11 +95,11 @@ fn handle_system_theme(state: Store<GlobalState>) {
if let Ok(Some(query)) = window().match_media("(prefers-color-scheme: dark)") {
let f = move |query: web_sys::MediaQueryList| {
if state.theme().get_untracked().is_system() {
*state.theme().write() = if query.matches() {
state.theme().set(if query.matches() {
Theme::SystemDark
} else {
Theme::SystemLight
};
});
}
};
f(query.clone());
@@ -123,11 +123,11 @@ fn handle_automic_orientation(state: Store<GlobalState>) {
if let Ok(Some(query)) = window().match_media("(max-width: 1600px)") {
let f = move |query: web_sys::MediaQueryList| {
if state.orientation().get_untracked().is_auto() {
*state.orientation().write() = if query.matches() {
state.orientation().set(if query.matches() {
Orientation::AutoHorizontal
} else {
Orientation::AutoVertical
};
});
}
};
f(query.clone());

View File

@@ -16,7 +16,7 @@ pub fn VfsMenu() -> impl IntoView {
current_value=move || { *state.vfs().read() }
this_value=Vfs::Memory
change_value=move || {
*state.vfs().write() = Vfs::Memory;
state.vfs().set(Vfs::Memory);
}
>
"Data will be lost after refreshing."
@@ -26,7 +26,7 @@ pub fn VfsMenu() -> impl IntoView {
current_value=move || { *state.vfs().read() }
this_value=Vfs::OPFS
change_value=move || {
*state.vfs().write() = Vfs::OPFS;
state.vfs().set(Vfs::OPFS);
}
>
"Persistent Storage."