From a1f0fc91544e78cee331ea84ecd20921bc1f4b61 Mon Sep 17 00:00:00 2001
From: kaiyohugo <41114603+KAIYOHUGO@users.noreply.github.com>
Date: Thu, 8 Aug 2024 11:39:37 +0800
Subject: [PATCH 01/18] chore(Frontend): :construction: Mpve navbar and footer
into nest router
---
frontend/src/app.rs | 3 +-
frontend/src/pages/about.rs | 1 -
frontend/src/pages/contest.rs | 2 -
frontend/src/pages/contests.rs | 1 -
frontend/src/pages/create/problem.rs | 2 -
frontend/src/pages/home.rs | 1 -
frontend/src/pages/login.rs | 1 -
frontend/src/pages/pages.rs | 56 +++++++++++++++++++---------
frontend/src/pages/problems.rs | 2 -
frontend/src/pages/rank.rs | 1 -
frontend/src/pages/submission.rs | 1 -
11 files changed, 40 insertions(+), 31 deletions(-)
diff --git a/frontend/src/app.rs b/frontend/src/app.rs
index e96a5e72..3d046602 100644
--- a/frontend/src/app.rs
+++ b/frontend/src/app.rs
@@ -2,7 +2,7 @@ use leptos::*;
use leptos_meta::*;
use leptos_router::*;
-use crate::{components::*, config::ProvideConfig, pages::Pages};
+use crate::{components::ProvideToast, config::ProvideConfig, pages::Pages};
// use tracing_subscriber::fmt::format::Pretty;
// use tracing_subscriber::prelude::*;
// use tracing_web::{performance_layer, MakeWebConsoleWriter};
@@ -20,7 +20,6 @@ pub fn App() -> impl IntoView {
diff --git a/frontend/src/pages/about.rs b/frontend/src/pages/about.rs
index f34fe697..ee7f57cb 100644
--- a/frontend/src/pages/about.rs
+++ b/frontend/src/pages/about.rs
@@ -6,6 +6,5 @@ use crate::components::*;
pub fn About() -> impl IntoView {
view! {
About
-
}
}
diff --git a/frontend/src/pages/contest.rs b/frontend/src/pages/contest.rs
index d9dc5e61..e7ff3446 100644
--- a/frontend/src/pages/contest.rs
+++ b/frontend/src/pages/contest.rs
@@ -4,7 +4,5 @@ use leptos::*;
pub fn About() -> impl IntoView {
view! {
About
-
-
}
}
diff --git a/frontend/src/pages/contests.rs b/frontend/src/pages/contests.rs
index 2f8637ee..d239ab2e 100644
--- a/frontend/src/pages/contests.rs
+++ b/frontend/src/pages/contests.rs
@@ -6,6 +6,5 @@ use crate::components::*;
pub fn Contests() -> impl IntoView {
view! {
Contest
-
}
}
diff --git a/frontend/src/pages/create/problem.rs b/frontend/src/pages/create/problem.rs
index 0f5e34af..5647bd41 100644
--- a/frontend/src/pages/create/problem.rs
+++ b/frontend/src/pages/create/problem.rs
@@ -131,7 +131,5 @@ pub fn Problem() -> impl IntoView {
-
-
}
}
diff --git a/frontend/src/pages/home.rs b/frontend/src/pages/home.rs
index 5b410295..61a88a2d 100644
--- a/frontend/src/pages/home.rs
+++ b/frontend/src/pages/home.rs
@@ -12,6 +12,5 @@ pub fn Home() -> impl IntoView {
ToastVariant::Error,
view! { "This is a error message............." }.into_view(),
)>Click Me
-
}
}
diff --git a/frontend/src/pages/login.rs b/frontend/src/pages/login.rs
index 42dc69ca..19b3a8e3 100644
--- a/frontend/src/pages/login.rs
+++ b/frontend/src/pages/login.rs
@@ -109,6 +109,5 @@ pub fn Login() -> impl IntoView {
-
}
}
diff --git a/frontend/src/pages/pages.rs b/frontend/src/pages/pages.rs
index 6d815a73..3386b96f 100644
--- a/frontend/src/pages/pages.rs
+++ b/frontend/src/pages/pages.rs
@@ -3,7 +3,7 @@ use leptos_router::*;
use leptos_use::*;
use problem::ProblemRouter;
-use crate::{errors::NotFound, grpc, pages::*, session::*};
+use crate::{components::*, errors::NotFound, grpc, pages::*, session::*};
/// |Permission|Root|Admin|SuperUser|User|Guest
/// |:-|:-:|:-:|:-:|:-:|:-:|
@@ -29,26 +29,48 @@ pub fn Pages() -> impl IntoView {
})
};
+ let show_footer = move || {
+ !use_location()
+ .pathname
+ .with(|path| path.starts_with("/problem/"))
+ };
+ let page_wrapper = move || {
+ view! {
+
+
+
+
+
+ }
+ };
+
view! {
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
- // Fallback
-
+ // Fallback
+
+
}
}
diff --git a/frontend/src/pages/problems.rs b/frontend/src/pages/problems.rs
index 6104745d..62c10c3e 100644
--- a/frontend/src/pages/problems.rs
+++ b/frontend/src/pages/problems.rs
@@ -7,7 +7,5 @@ use crate::components::*;
pub fn Problems() -> impl IntoView {
view! {
-
-
}
}
diff --git a/frontend/src/pages/rank.rs b/frontend/src/pages/rank.rs
index 354ea4c0..49e50a4b 100644
--- a/frontend/src/pages/rank.rs
+++ b/frontend/src/pages/rank.rs
@@ -6,6 +6,5 @@ use crate::components::*;
pub fn Rank() -> impl IntoView {
view! {
Rank
-
}
}
diff --git a/frontend/src/pages/submission.rs b/frontend/src/pages/submission.rs
index f6bc8264..84abd797 100644
--- a/frontend/src/pages/submission.rs
+++ b/frontend/src/pages/submission.rs
@@ -6,6 +6,5 @@ use crate::components::*;
pub fn Submission() -> impl IntoView {
view! {
Submission
-
}
}
From fc2f5df2a9c93a281c6df809304a5b4eca99c1f6 Mon Sep 17 00:00:00 2001
From: kaiyohugo <41114603+KAIYOHUGO@users.noreply.github.com>
Date: Wed, 21 Aug 2024 00:38:26 +0800
Subject: [PATCH 02/18] chore(Frontend): :heavy_plus_sign: Add leptos query
---
Cargo.lock | 42 ++++++++++++++++++++++++++++++++++++++++++
frontend/Cargo.toml | 22 ++++++++++++++++++++--
frontend/src/main.rs | 4 ++--
grpc/build.rs | 8 ++++++++
4 files changed, 72 insertions(+), 4 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index fbefa136..c3ab037e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -567,6 +567,12 @@ dependencies = [
"syn 2.0.72",
]
+[[package]]
+name = "async_cell"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "834eee9ce518130a3b4d5af09ecc43e9d6b57ee76613f227a1ddd6b77c7a62bc"
+
[[package]]
name = "atoi"
version = "2.0.0"
@@ -1887,6 +1893,7 @@ dependencies = [
"actix-web",
"cfg-if",
"console_error_panic_hook",
+ "cookie 0.18.1",
"gloo",
"grpc",
"http 0.2.12",
@@ -1898,6 +1905,8 @@ dependencies = [
"leptos_animated_for",
"leptos_icons",
"leptos_meta",
+ "leptos_query",
+ "leptos_query_devtools",
"leptos_router",
"lol_alloc",
"num-traits",
@@ -3390,6 +3399,39 @@ dependencies = [
"web-sys",
]
+[[package]]
+name = "leptos_query"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "210f99102170bc3d227148d78c2fdd79e89f724981a697c526f294c85a0b0521"
+dependencies = [
+ "async-trait",
+ "async_cell",
+ "cfg-if",
+ "futures",
+ "futures-channel",
+ "gloo-timers 0.3.0",
+ "js-sys",
+ "leptos",
+ "slotmap",
+ "tokio",
+ "web-sys",
+]
+
+[[package]]
+name = "leptos_query_devtools"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "03da420d373103de2681e69a15d040054a9023e5135a9a39bfaa0adf2af41fd2"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "leptos",
+ "leptos_query",
+ "wasm-bindgen",
+ "web-sys",
+]
+
[[package]]
name = "leptos_reactive"
version = "0.6.13"
diff --git a/frontend/Cargo.toml b/frontend/Cargo.toml
index 83150c77..89cc1a6b 100644
--- a/frontend/Cargo.toml
+++ b/frontend/Cargo.toml
@@ -35,6 +35,9 @@ turf = "0.9.2"
leptos_animated_for = "0.4.7"
num-traits = "0.2.19"
lol_alloc = "0.4.1"
+leptos_query = "0.5.3"
+cookie = "0.18.1"
+leptos_query_devtools = "0.1.3"
[dependencies.uuid]
version = "1.7.0"
@@ -79,8 +82,22 @@ features = ["prost"]
workspace = true
[features]
-csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr", "uuid/js"]
-hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
+csr = [
+ "leptos/csr",
+ "leptos_meta/csr",
+ "leptos_router/csr",
+ "uuid/js",
+ "leptos_query/csr",
+ "leptos_query_devtools/csr",
+]
+hydrate = [
+ "leptos/hydrate",
+ "leptos_meta/hydrate",
+ "leptos_router/hydrate",
+ "leptos_query/hydrate",
+ # This is intended, hydrate feature for devtool is csr
+ "leptos_query_devtools/csr",
+]
ssr = [
"dep:actix-files",
"dep:actix-web",
@@ -93,6 +110,7 @@ ssr = [
"leptos_router/ssr",
"leptos-use/ssr",
"leptos-use/actix",
+ "leptos_query/ssr",
]
compress = []
diff --git a/frontend/src/main.rs b/frontend/src/main.rs
index 32c0a288..596e3d85 100644
--- a/frontend/src/main.rs
+++ b/frontend/src/main.rs
@@ -16,9 +16,9 @@ async fn main() -> Result<(), Box> {
let conf = get_configuration(None).await?;
let addr = conf.leptos_options.site_addr;
// Generate the list of routes in your Leptos App
- let routes = generate_route_list(App);
+ let routes =
+ leptos_query::with_query_suppression(|| generate_route_list(App));
println!("listening on http://{}", &addr);
- init_config().await?;
HttpServer::new(move || {
let leptos_options: &LeptosOptions = &conf.leptos_options;
diff --git a/grpc/build.rs b/grpc/build.rs
index d50d711a..2a4bc214 100644
--- a/grpc/build.rs
+++ b/grpc/build.rs
@@ -25,6 +25,14 @@ fn main() {
".",
r#"#[cfg_attr(feature = "extra_trait", derive(derive_more::IsVariant, derive_more::Unwrap))]"#,
)
+ .message_attribute(
+ "Create",
+ r#"#[cfg_attr(feature = "extra_trait", derive(Hash))]"#,
+ )
+ .message_attribute(
+ "Query",
+ r#"#[cfg_attr(feature = "extra_trait", derive(Hash))]"#,
+ )
.extern_path(".google.protobuf.Any", "::prost_wkt_types::Any")
.extern_path(".google.protobuf.Timestamp", "::prost_wkt_types::Timestamp")
.extern_path(".google.protobuf.Value", "::prost_wkt_types::Value")
From aad5201a0e654d6a0f2e7f646cbdc9b5b4579d5e Mon Sep 17 00:00:00 2001
From: kaiyohugo <41114603+KAIYOHUGO@users.noreply.github.com>
Date: Wed, 21 Aug 2024 00:39:42 +0800
Subject: [PATCH 03/18] fix(Frontend): :bug: Fix cookie path not set
---
frontend/src/session.rs | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/frontend/src/session.rs b/frontend/src/session.rs
index 456c1272..56c0b02c 100644
--- a/frontend/src/session.rs
+++ b/frontend/src/session.rs
@@ -19,7 +19,10 @@ pub fn use_token_info(
) -> (Signal