copy text and other small changes
This commit is contained in:
@ -1,30 +0,0 @@
|
||||
use crate::Route;
|
||||
use dioxus::prelude::*;
|
||||
use crate::components::{Hero};
|
||||
|
||||
//const BLOG_CSS: Asset = asset!("/assets/styling/blog.css");
|
||||
|
||||
#[component]
|
||||
pub fn Blog(id: i32) -> Element {
|
||||
rsx! {
|
||||
// document::Link { rel: "stylesheet", href: BLOG_CSS }
|
||||
|
||||
div {
|
||||
id: "blog",
|
||||
|
||||
h1 { "This is blog #{id}!" }
|
||||
p { "In blog #{id}, we show how the Dioxus router works and how URL parameters can be passed as props to our route components." }
|
||||
|
||||
Link {
|
||||
to: Route::Blog { id: id - 1 },
|
||||
"Previous"
|
||||
}
|
||||
span { " <---> " }
|
||||
Link {
|
||||
to: Route::Blog { id: id + 1 },
|
||||
"Next"
|
||||
}
|
||||
}
|
||||
Hero{}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
use dioxus::prelude::*;
|
||||
use crate::components::{Hero, Echo};
|
||||
|
||||
/// The Home page component that will be rendered when the current route is `[Route::Home]`
|
||||
#[component]
|
||||
pub fn Home() -> Element {
|
||||
rsx! {
|
||||
Hero {}
|
||||
Echo {}
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,2 @@
|
||||
mod home;
|
||||
pub use home::Home;
|
||||
|
||||
mod blog;
|
||||
pub use blog::Blog;
|
||||
|
||||
mod navbar;
|
||||
pub use navbar::Navbar;
|
||||
|
||||
mod upload;
|
||||
pub use upload::Upload;
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
use crate::Route;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
//const NAVBAR_CSS: Asset = asset!("/assets/styling/navbar.css");
|
||||
|
||||
#[component]
|
||||
pub fn Navbar() -> Element {
|
||||
rsx! {
|
||||
// document::Link { rel: "stylesheet", href: NAVBAR_CSS }
|
||||
|
||||
div {
|
||||
id: "navbar",
|
||||
Link {
|
||||
to: Route::Home {},
|
||||
"Home"
|
||||
}
|
||||
Link {
|
||||
to: Route::Blog { id: 1 },
|
||||
"Blog"
|
||||
}
|
||||
}
|
||||
|
||||
Outlet::<Route> {}
|
||||
}
|
||||
}
|
||||
@ -45,8 +45,10 @@ async fn upload_file(mut upload: FileStream) -> Result<String, HttpError> {
|
||||
}
|
||||
};
|
||||
|
||||
if upload.size().unwrap() > UPLOAD_SIZE_LIMIT {
|
||||
return HttpError::payload_too_large("this file is too large");
|
||||
if let Some(size) = upload.size() {
|
||||
if size > UPLOAD_SIZE_LIMIT {
|
||||
return HttpError::payload_too_large("this file is too large");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +62,7 @@ async fn upload_file(mut upload: FileStream) -> Result<String, HttpError> {
|
||||
Ok(bytes) => {
|
||||
total_len += bytes.len() as u64;
|
||||
if total_len > UPLOAD_SIZE_LIMIT {
|
||||
error = Some("Uploaded file to large");
|
||||
error = Some("Uploaded file too large");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -97,7 +99,11 @@ pub fn build_table(files: Vec<(String, String, Option<Result<String, HttpError>>
|
||||
td { class: "px-2",
|
||||
match &file.2 {
|
||||
Some(res) => { match res {
|
||||
Ok(file_id) => { rsx! { input { type:"button" , "/upload/dl/{file_id}"} } },
|
||||
Ok(file_url) => {let url = file_url.clone(); rsx! { input {
|
||||
type:"button",
|
||||
onclick: move |_| { web_sys::window().unwrap().navigator().clipboard().write_text(&url); },
|
||||
value: "{file_url}"
|
||||
} } },
|
||||
Err(e) => {
|
||||
let msg = e.message.clone().unwrap();
|
||||
rsx! { p { "Upload failed, reason : {msg}" } }
|
||||
@ -144,7 +150,13 @@ pub fn Upload() -> Element {
|
||||
return ;
|
||||
}
|
||||
|
||||
let res = upload_file(file.clone().into()).await;
|
||||
let res = match upload_file(file.clone().into()).await {
|
||||
Ok(file_id) => {
|
||||
let host = web_sys::window().unwrap().location().host().expect("unknown_host");
|
||||
Ok(host + "/upload/" + &file_id)
|
||||
},
|
||||
Err(err) => { Err(err) }
|
||||
};
|
||||
selected.with_mut(|files| { files[idx].2 = Some(res) });
|
||||
}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user