diff --git a/.vscode/settings.json b/.vscode/settings.json index bcad4d9..7ed0999 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,7 @@ "Frontend", "Backend", "Judger", - "Testsuit" + "Testsuit", + "Grpc" ], } \ No newline at end of file diff --git a/frontend/src/components/button.rs b/frontend/src/components/button.rs index f5c8b64..0a675ad 100644 --- a/frontend/src/components/button.rs +++ b/frontend/src/components/button.rs @@ -24,11 +24,10 @@ pub fn Button( disabled=disabled id=id on:click=move |e| { - on_click - .map(|f| { - e.stop_propagation(); - f(e); - }); + if let Some(f) = on_click { + e.stop_propagation(); + f(e); + } } > diff --git a/frontend/src/components/modal.rs b/frontend/src/components/modal.rs index f8f67d3..959837d 100644 --- a/frontend/src/components/modal.rs +++ b/frontend/src/components/modal.rs @@ -14,6 +14,8 @@ pub fn Modal( #[prop(into, optional)] on_close: Option>, children: Children, ) -> impl IntoView { + // FIXME: what is level for? color? + let _level = level; view! { {children()} diff --git a/frontend/src/components/select.rs b/frontend/src/components/select.rs index 416ca61..60e5d23 100644 --- a/frontend/src/components/select.rs +++ b/frontend/src/components/select.rs @@ -1,5 +1,7 @@ use leptos::*; +use crate::components::Merge; + #[derive(Debug, Clone, PartialEq, Eq)] struct SelectedValue(ReadSignal); @@ -15,7 +17,7 @@ pub fn Select( provide_context(SelectedValue(get)); view! {
diff --git a/frontend/src/config.rs b/frontend/src/config.rs index d8b3aac..39cf32a 100644 --- a/frontend/src/config.rs +++ b/frontend/src/config.rs @@ -1,3 +1,6 @@ +#[cfg(feature = "ssr")] +use std::sync::OnceLock; + use cfg_if::cfg_if; use leptos::*; use leptos_use::{utils::JsonCodec, *}; @@ -5,9 +8,6 @@ use serde::{Deserialize, Serialize}; use tonic::{IntoRequest, Request}; use crate::{error::*, grpc}; - -#[cfg(feature = "ssr")] -use std::sync::OnceLock; #[cfg(feature = "ssr")] static CONFIG: OnceLock = OnceLock::new(); diff --git a/frontend/src/pages/problem.rs b/frontend/src/pages/problem.rs index 74a7a57..f43bbbc 100644 --- a/frontend/src/pages/problem.rs +++ b/frontend/src/pages/problem.rs @@ -44,7 +44,7 @@ pub fn Problem() -> impl IntoView { }); let submit_langs = - create_resource(id_and_token, |(id, token)| async move { + create_resource(id_and_token, |(_id, token)| async move { let mut client = submit_set_client::SubmitSetClient::new( grpc::new_client().await?, ); diff --git a/frontend/src/pages/problems.rs b/frontend/src/pages/problems.rs index 4f317f7..9d73055 100644 --- a/frontend/src/pages/problems.rs +++ b/frontend/src/pages/problems.rs @@ -303,7 +303,8 @@ pub fn ProblemSearch() -> impl IntoView { let start_from_end = create_rw_signal(false); let sort_by = create_rw_signal((ProblemSortBy::AcRate as i32).to_string()); - let submit = Memo::new(move |_| { + // FIXME: What is this? + let _submit = Memo::new(move |_| { let start_from_end = start_from_end.get(); let text = filter_text.get(); let sort_by: ProblemSortBy = sort_by @@ -337,7 +338,7 @@ pub fn ProblemSearch() -> impl IntoView { Difficulty Public - // a form with a text input and a dropdown list and a toggle + // a form with a text input and a dropdown list and a toggle } @@ -351,9 +352,12 @@ pub fn ProblemList() -> impl IntoView { _ => "red", }; view! { - - {difficulty} - + {difficulty} } } @@ -364,59 +368,85 @@ pub fn ProblemList() -> impl IntoView { Loading

} }> - {move || { - r.get() - .map(|v| v.map(|v|view!{ -
-
-
-
Title
- - -
Difficulty
-
-
-
- { - v.list.into_iter().map(|info| { + {move || { + r.get() + .map(|v| { + v + .map(|v| { view! { -
-
- {info.title} +
+
+
+
Title
+ + +
Difficulty
+
+
+
+ + {v + .list + .into_iter() + .map(|info| { + view! { +
+ + + +
+ {difficulty_color(info.difficulty)} +
+
+ } + }) + .collect_view()} +
- - -
{difficulty_color(info.difficulty)}
+
    + + {v + .previous_queries + .into_iter() + .enumerate() + .map(|(n, query)| { + view! { +
  • + back {n + 1} page +
  • + } + }) + .collect_view()} + +
+
    + + {v + .next_queries + .into_iter() + .enumerate() + .map(|(n, query)| { + view! { +
  • + next {n + 1} page +
  • + } + }) + .collect_view()} + +
} }) - .collect_view() - } -
-
-
    - { - v.previous_queries.into_iter().enumerate() - .map(|(n,query)|view!{ -
  • - back {n+1} page -
  • - }).collect_view() - } -
-
    - { - v.next_queries.into_iter().enumerate() - .map(|(n,query)|view!{ -
  • - next {n+1} page -
  • - }).collect_view() - } -
- })) - } - } + }) + }} +
} diff --git a/grpc/build.rs b/grpc/build.rs index 46c98c6..bf4368b 100644 --- a/grpc/build.rs +++ b/grpc/build.rs @@ -28,8 +28,7 @@ fn main() { .file_descriptor_set_path(&descriptor_file) .compile(&["proto/backend.proto", "proto/judger.proto"], &["proto"]) .unwrap(); - #[cfg(feature = "serde")] - #[cfg(feature = "wkt")] + #[cfg(all(feature = "wkt", feature = "serde"))] { use prost_wkt_build::*; let descriptor_bytes = std::fs::read(descriptor_file).unwrap(); diff --git a/grpc/src/lib.rs b/grpc/src/lib.rs index c813a10..0f64bea 100644 --- a/grpc/src/lib.rs +++ b/grpc/src/lib.rs @@ -1,15 +1,18 @@ #[cfg(feature = "wkt")] +#[allow(clippy::all, non_local_definitions)] pub mod backend { tonic::include_proto!("oj.backend"); } #[cfg(feature = "backend")] #[cfg(not(feature = "wkt"))] +#[allow(clippy::all, non_local_definitions)] pub mod backend { tonic::include_proto!("oj.backend"); } #[cfg(feature = "backend")] +#[allow(clippy::all, non_local_definitions)] pub mod judger { tonic::include_proto!("oj.judger"); }